28 if (!defined(
'CSRFCHECK_WITH_TOKEN')) {
29 define(
'CSRFCHECK_WITH_TOKEN',
'1');
32 require
'../../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
39 $langs->loadLangs(array(
'users',
'admin'));
42 $action =
GETPOST(
'action',
'aZ09');
43 $confirm =
GETPOST(
'confirm',
'alpha');
44 $module =
GETPOST(
'module',
'alpha');
45 $rights =
GETPOST(
'rights',
'int');
46 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'groupperms';
48 if (!isset($id) || empty($id)) {
53 $canreadperms = ($user->admin || $user->rights->user->user->lire);
55 $caneditperms = ($user->admin || $user->rights->user->user->creer);
57 $advancedpermsactive =
false;
58 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
59 $advancedpermsactive =
true;
60 $canreadperms = ($user->admin || ($user->rights->user->group_advance->read && $user->rights->user->group_advance->readperms));
61 $caneditperms = ($user->admin || $user->rights->user->group_advance->write);
70 $object =
new Usergroup($db);
74 $entity = $conf->entity;
77 $hookmanager->initHooks(array(
'groupperms',
'globalcard'));
84 $parameters = array();
85 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
90 if (empty($reshook)) {
91 if ($action ==
'addrights' && $caneditperms) {
92 $editgroup =
new Usergroup($db);
93 $result = $editgroup->fetch($object->id);
95 $result = $editgroup->addrights($rights, $module,
'', $entity);
103 $user->clearrights();
107 if ($action ==
'delrights' && $caneditperms) {
108 $editgroup =
new Usergroup($db);
109 $result = $editgroup->fetch($id);
111 $result = $editgroup->delrights($rights, $module,
'', $entity);
119 $user->clearrights();
131 llxHeader(
'', $langs->trans(
"Permissions"));
133 if ($object->id > 0) {
135 $title = $langs->trans(
"Group");
144 foreach ($modulesdir as $dir) {
146 if (is_resource($handle)) {
147 while (($file = readdir($handle)) !==
false) {
148 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
149 $modName = substr($file, 0,
dol_strlen($file) - 10);
152 include_once $dir.$file;
153 $objMod =
new $modName($db);
155 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
156 foreach ($objMod->langfiles as $domain) {
157 $langs->load($domain);
161 if ($objMod->rights_class) {
162 $ret = $objMod->insert_permissions(0, $entity);
163 $modules[$objMod->rights_class] = $objMod;
174 $permsgroupbyentity = array();
176 $sql =
"SELECT DISTINCT r.id, r.libelle, r.module, gr.entity";
177 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r,";
178 $sql .=
" ".MAIN_DB_PREFIX.
"usergroup_rights as gr";
179 $sql .=
" WHERE gr.fk_id = r.id";
180 $sql .=
" AND gr.entity = ".((int) $entity);
181 $sql .=
" AND gr.fk_usergroup = ".((int) $object->id);
184 $result = $db->query($sql);
186 $num = $db->num_rows($result);
189 $obj = $db->fetch_object($result);
190 if (!isset($permsgroupbyentity[$obj->entity])) {
191 $permsgroupbyentity[$obj->entity] = array();
193 array_push($permsgroupbyentity[$obj->entity], $obj->id);
205 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/group/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
207 dol_banner_tab($object,
'id', $linkback, $user->rights->user->user->lire || $user->admin);
209 print
'<div class="fichecenter">';
210 print
'<div class="underbanner clearboth"></div>';
213 print
'<table class="border centpercent tableforfield">';
216 if (!empty($conf->mutlicompany->enabled)) {
217 print
'<tr><td class="titlefield">'.$langs->trans(
"Name").
'</td>';
218 print
'<td colspan="2">'.$object->name.
'';
219 if (!$object->entity) {
220 print
img_picto($langs->trans(
"GlobalGroup"),
'redstar');
222 print
"</td></tr>\n";
226 print
'<tr><td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td>';
227 print
'<td class="valeur sensiblehtmlcontent">';
232 print
'</table><br>';
235 print
info_admin($langs->trans(
"WarningOnlyPermissionOfActivatedModules"));
238 $parameters = array();
239 $reshook = $hookmanager->executeHooks(
'insertExtraHeader', $parameters, $object, $action);
245 print
'<div class="div-table-responsive-no-min">';
246 print
'<table class="noborder centpercent">';
247 print
'<tr class="liste_titre">';
248 print
'<td>'.$langs->trans(
"Module").
'</td>';
250 print
'<td class="center nowrap">';
251 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&token='.
newToken().
'&entity='.$entity.
'&module=allmodules&confirm=yes">'.$langs->trans(
"All").
"</a>";
253 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&&token='.
newToken().
'&entity='.$entity.
'&module=allmodules&confirm=yes">'.$langs->trans(
"None").
"</a>";
256 print
'<td class="center" width="24"> </td>';
257 print
'<td>'.$langs->trans(
"Permissions").
'</td>';
259 print
'<td class="right"></td>';
263 $sql =
"SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault";
264 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
265 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
266 $sql .=
" AND r.entity = ".((int) $entity);
267 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
268 $sql .=
" AND r.perms NOT LIKE '%_advance'";
270 $sql .=
" ORDER BY r.family_position, r.module_position, r.module, r.id";
272 $result = $db->query($sql);
274 $num = $db->num_rows($result);
279 $obj = $db->fetch_object($result);
282 if (empty($modules[$obj->module])) {
287 $objMod = $modules[$obj->module];
290 if (isset($obj->module) && ($oldmod <> $obj->module)) {
291 $oldmod = $obj->module;
294 $objMod = $modules[$obj->module];
295 $picto = ($objMod->picto ? $objMod->picto :
'generic');
298 print
'<tr class="oddeven trforbreak">';
299 print
'<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
300 print
img_object(
'', $picto,
'class="pictoobjectwidth paddingright"').
' '.$objMod->getName();
301 print
'<a name="'.$objMod->getName().
'"></a>';
304 print
'<td class="center nowrap">';
305 print
'<a class="reposition" title="'.dol_escape_htmltag($langs->trans(
"All")).
'" alt="'.$langs->trans(
"All").
'" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=addrights&entity='.$entity.
'&module='.$obj->module.
'&token='.
newToken().
'">'.$langs->trans(
"All").
"</a>";
307 print
'<a class="reposition" title="'.dol_escape_htmltag($langs->trans(
"None")).
'" alt="'.$langs->trans(
"None").
'" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delrights&entity='.$entity.
'&module='.$obj->module.
'&token='.
newToken().
'">'.$langs->trans(
"None").
"</a>";
310 print
'<td> </td>';
312 print
'<td> </td>';
313 print
'<td> </td>';
317 print
'<td class="right"></td>';
323 print
'<!-- '.$obj->module.
'->'.$obj->perms.($obj->subperms ?
'->'.$obj->subperms :
'').
' -->'.
"\n";
324 print
'<tr class="oddeven">';
327 print
'<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
331 if (!empty($permsgroupbyentity[$entity]) && is_array($permsgroupbyentity[$entity])) {
332 if (in_array($obj->id, $permsgroupbyentity[$entity])) {
335 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delrights&token='.
newToken().
'&entity='.$entity.
'&rights='.$obj->id.
'&confirm=yes">';
337 print
img_picto($langs->trans(
"Remove"),
'switch_on');
340 print
'<td class="center nowrap">';
341 print
img_picto($langs->trans(
"Active"),
'tick');
346 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=addrights&token='.
newToken().
'&entity='.$entity.
'&rights='.$obj->id.
'&confirm=yes">';
348 print
img_picto($langs->trans(
"Add"),
'switch_off');
351 print
'<td> </td>';
356 print
'<td class="center"><a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=addrights&entity='.$entity.
'&rights='.$obj->id.
'&confirm=yes&token='.
newToken().
'">';
358 print
img_picto($langs->trans(
"Add"),
'switch_off');
361 print
'<td> </td>';
365 $permlabel = (!empty($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)));
368 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
369 if (preg_match(
'/_advance$/', $obj->perms)) {
370 print
' <span class="opacitymedium">('.$langs->trans(
"AdvancedModeOnly").
')</span>';
377 print
'<td class="right">';
378 $htmltext = $langs->trans(
"ID").
': '.$obj->id;
379 $htmltext .=
'<br>'.$langs->trans(
"Permission").
': user->rights->'.$obj->module.
'->'.$obj->perms.($obj->subperms ?
'->'.$obj->subperms :
'');
380 print
$form->textwithpicto(
'', $htmltext);
395 $parameters = array();
396 $reshook = $hookmanager->executeHooks(
'insertExtraFooter', $parameters, $object, $action);
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.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
dolGetModulesDirs($subdir= '')
Return list of modules directories.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0)
Clean a string to keep only desirable HTML tags.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
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...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= 'hideonsmartphone', $textfordropdown= '')
Show information for admin users or standard users.
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 ...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.