28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
35 $langs->loadLangs(array(
'users',
'admin'));
38 $action =
GETPOST(
'action',
'aZ09');
39 $confirm =
GETPOST(
'confirm',
'alpha');
40 $module =
GETPOST(
'module',
'alpha');
41 $rights =
GETPOST(
'rights',
'int');
42 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'groupperms';
45 $canreadperms = ($user->admin || $user->rights->user->user->lire);
47 $caneditperms = ($user->admin || $user->rights->user->user->creer);
49 $advancedpermsactive =
false;
50 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS))
52 $advancedpermsactive =
true;
53 $canreadperms = ($user->admin || ($user->rights->user->group_advance->read && $user->rights->user->group_advance->readperms));
54 $caneditperms = ($user->admin || $user->rights->user->group_advance->write);
59 $object =
new Usergroup($db);
62 $entity = $conf->entity;
65 $hookmanager->initHooks(array(
'groupperms',
'globalcard'));
72 $parameters = array();
73 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
74 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
76 if (empty($reshook)) {
77 if ($action ==
'addrights' && $caneditperms) {
78 $editgroup =
new Usergroup($db);
79 $result = $editgroup->fetch($id);
81 $result = $editgroup->addrights($rights, $module,
'', $entity);
90 if ($action ==
'delrights' && $caneditperms) {
91 $editgroup =
new Usergroup($db);
92 $result = $editgroup->fetch($id);
94 $result = $editgroup->delrights($rights, $module,
'', $entity);
111 llxHeader(
'', $langs->trans(
"Permissions"));
118 $object->getrights();
121 $title = $langs->trans(
"Group");
130 foreach ($modulesdir as $dir)
133 if (is_resource($handle))
135 while (($file = readdir($handle)) !==
false)
137 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php')
139 $modName = substr($file, 0,
dol_strlen($file) - 10);
143 include_once $dir.$file;
144 $objMod =
new $modName($db);
146 if (isset($objMod->langfiles) && is_array($objMod->langfiles))
148 foreach ($objMod->langfiles as $domain)
150 $langs->load($domain);
154 if ($objMod->rights_class)
156 $ret = $objMod->insert_permissions(0, $entity);
157 $modules[$objMod->rights_class] = $objMod;
168 $permsgroupbyentity = array();
170 $sql =
"SELECT DISTINCT r.id, r.libelle, r.module, gr.entity";
171 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r,";
172 $sql .=
" ".MAIN_DB_PREFIX.
"usergroup_rights as gr";
173 $sql .=
" WHERE gr.fk_id = r.id";
174 $sql .=
" AND gr.entity = ".$entity;
175 $sql .=
" AND gr.fk_usergroup = ".$object->id;
178 $result = $db->query($sql);
181 $num = $db->num_rows($result);
185 $obj = $db->fetch_object($result);
186 if (!isset($permsgroupbyentity[$obj->entity]))
187 $permsgroupbyentity[$obj->entity] = array();
188 array_push($permsgroupbyentity[$obj->entity], $obj->id);
196 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/group/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
198 dol_banner_tab($object,
'id', $linkback, $user->rights->user->user->lire || $user->admin);
200 print '<div class="fichecenter">';
201 print '<div class="underbanner clearboth"></div>';
207 print '<table class="border centpercent tableforfield">';
210 if (!empty($conf->mutlicompany->enabled))
212 print '<tr><td class="titlefield">'.$langs->trans(
"Name").
'</td>';
213 print '<td colspan="2">'.$object->name.
'';
214 if (!$object->entity)
218 print "</td></tr>\n";
222 print '<tr><td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td>';
223 print '<td class="valeur sensiblehtmlcontent">';
228 print '</table><br>';
230 if ($user->admin)
print info_admin($langs->trans(
"WarningOnlyPermissionOfActivatedModules"));
232 $parameters = array();
233 $reshook = $hookmanager->executeHooks(
'insertExtraHeader', $parameters, $object, $action);
234 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
237 print '<div class="div-table-responsive-no-min">';
238 print '<table class="noborder centpercent">';
239 print '<tr class="liste_titre">';
240 print '<td>'.$langs->trans(
"Module").
'</td>';
243 print '<td class="center nowrap">';
244 print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans(
"All")).
'" alt="'.
dol_escape_htmltag($langs->trans(
"All")).
'" href="'.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=addrights&entity='.$entity.
'&module=allmodules">'.$langs->trans(
"All").
"</a>";
246 print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans(
"None")).
'" alt="'.
dol_escape_htmltag($langs->trans(
"None")).
'" href="'.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delrights&entity='.$entity.
'&module=allmodules">'.$langs->trans(
"None").
"</a>";
249 print '<td class="center" width="24"> </td>';
250 print '<td>'.$langs->trans(
"Permissions").
'</td>';
251 if ($user->admin)
print '<td class="right">'.$langs->trans(
"ID").
'</td>';
254 $sql =
"SELECT r.id, r.libelle as label, r.module";
255 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
256 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
257 $sql .=
" AND r.entity = ".$entity;
258 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql .=
" AND r.perms NOT LIKE '%_advance'";
259 $sql .=
" ORDER BY r.module, r.id";
261 $result = $db->query($sql);
264 $num = $db->num_rows($result);
270 $obj = $db->fetch_object($result);
273 if (empty($modules[$obj->module]))
279 if ($oldmod <> $obj->module)
281 $oldmod = $obj->module;
284 $objMod = $modules[$obj->module];
285 $picto = ($objMod->picto ? $objMod->picto :
'generic');
288 print '<tr class="oddeven trforbreak">';
289 print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
290 print img_object(
'', $picto,
'class="pictoobjectwidth paddingright"').
' '.$objMod->getName();
291 print '<a name="'.$objMod->getName().
'"></a>';
295 print '<td class="center nowrap">';
296 print '<a class="reposition" title='.$langs->trans(
"All").
' alt='.$langs->trans(
"All").
' href="'.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=addrights&entity='.$entity.
'&module='.$obj->module.
'">'.$langs->trans(
"All").
"</a>";
298 print '<a class="reposition" title='.$langs->trans(
"None").
' alt='.$langs->trans(
"None").
' href="'.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delrights&entity='.$entity.
'&module='.$obj->module.
'">'.$langs->trans(
"None").
"</a>";
301 print '<td> </td>';
303 print '<td colspan="2"> </td>';
306 if ($user->admin)
print '<td class="right"></td>';
311 print '<!-- '.$obj->module.
'->'.$obj->perms.($obj->subperms ?
'->'.$obj->subperms :
'').
' -->'.
"\n";
312 print '<tr class="oddeven">';
315 print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
319 if (is_array($permsgroupbyentity[$entity]))
321 if (in_array($obj->id, $permsgroupbyentity[$entity]))
326 print '<td class="center"><a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delrights&entity='.$entity.
'&rights='.$obj->id.
'">';
331 print '<td class="center nowrap">';
338 print '<td class="center"><a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=addrights&entity='.$entity.
'&rights='.$obj->id.
'">';
343 print '<td> </td>';
349 print '<td class="center"><a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=addrights&entity='.$entity.
'&rights='.$obj->id.
'">';
354 print '<td> </td>';
357 $permlabel = ($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans(
"PermissionAdvanced".$obj->id) != (
"PermissionAdvanced".$obj->id)) ? $langs->trans(
"PermissionAdvanced".$obj->id) : (($langs->trans(
"Permission".$obj->id) != (
"Permission".$obj->id)) ? $langs->trans(
"Permission".$obj->id) : $langs->trans($obj->label)));
358 print '<td class="maxwidthonsmartphone">'.$permlabel.
'</td>';
361 if ($user->admin)
print '<td class="right"><span class="opacitymedium">'.$obj->id.
'</span></td>';
373 $parameters = array();
374 $reshook = $hookmanager->executeHooks(
'insertExtraFooter', $parameters, $object, $action);
375 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolGetModulesDirs($subdir= '')
Return list of modules directories.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
group_prepare_head($object)
Prepare array with list of tabs.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0)
Clean a string to keep only desirable HTML tags.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...