28 if (!defined(
'CSRFCHECK_WITH_TOKEN')) {
29 define(
'CSRFCHECK_WITH_TOKEN',
'1');
33 require
'../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
40 $langs->loadLangs(array(
'users',
'admin'));
43 $action =
GETPOST(
'action',
'aZ09');
44 $confirm =
GETPOST(
'confirm',
'alpha');
45 $module =
GETPOST(
'module',
'alpha');
46 $rights =
GETPOST(
'rights',
'int');
47 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'groupperms';
49 if (!isset($id) || empty($id)) {
54 $canreadperms = ($user->admin || $user->hasRight(
"user",
"user",
"read"));
56 $caneditperms = ($user->admin || $user->hasRight(
"user",
"user",
"write"));
58 $advancedpermsactive =
false;
59 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
60 $advancedpermsactive =
true;
61 $canreadperms = ($user->admin || ($user->hasRight(
"user",
"group_advance",
"read") && $user->hasRight(
"user",
"group_advance",
"readperms")));
62 $caneditperms = ($user->admin || $user->hasRight(
"user",
"group_advance",
"write"));
71 $object =
new Usergroup($db);
75 $entity = $conf->entity;
78 $hookmanager->initHooks(array(
'groupperms',
'globalcard'));
86 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
91 if (empty($reshook)) {
92 if ($action ==
'addrights' && $caneditperms) {
93 $editgroup =
new Usergroup($db);
94 $result = $editgroup->fetch($object->id);
96 $result = $editgroup->addrights($rights, $module,
'', $entity);
104 $user->clearrights();
108 if ($action ==
'delrights' && $caneditperms) {
109 $editgroup =
new Usergroup($db);
110 $result = $editgroup->fetch($id);
112 $result = $editgroup->delrights($rights, $module,
'', $entity);
120 $user->clearrights();
132 $title = $object->name.
" - ".$langs->trans(
'Permissions');
136 if ($object->id > 0) {
138 $title = $langs->trans(
"Group");
147 foreach ($modulesdir as $dir) {
149 if (is_resource($handle)) {
150 while (($file = readdir($handle)) !==
false) {
151 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
152 $modName = substr($file, 0,
dol_strlen($file) - 10);
155 include_once $dir.$file;
156 $objMod =
new $modName($db);
158 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
159 foreach ($objMod->langfiles as $domain) {
160 $langs->load($domain);
164 if ($objMod->rights_class) {
165 $ret = $objMod->insert_permissions(0, $entity);
166 $modules[$objMod->rights_class] = $objMod;
177 $permsgroupbyentity = array();
179 $sql =
"SELECT DISTINCT r.id, r.libelle, r.module, gr.entity";
180 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r,";
181 $sql .=
" ".MAIN_DB_PREFIX.
"usergroup_rights as gr";
182 $sql .=
" WHERE gr.fk_id = r.id";
183 $sql .=
" AND gr.entity = ".((int) $entity);
184 $sql .=
" AND gr.fk_usergroup = ".((int) $object->id);
187 $result = $db->query($sql);
189 $num = $db->num_rows($result);
192 $obj = $db->fetch_object($result);
193 if (!isset($permsgroupbyentity[$obj->entity])) {
194 $permsgroupbyentity[$obj->entity] = array();
196 array_push($permsgroupbyentity[$obj->entity], $obj->id);
208 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/group/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
210 dol_banner_tab($object,
'id', $linkback, $user->hasRight(
"user",
"user",
"read") || $user->admin);
212 print
'<div class="fichecenter">';
213 print
'<div class="underbanner clearboth"></div>';
216 print
'<table class="border centpercent tableforfield">';
219 if (!empty($conf->mutlicompany->enabled)) {
220 print
'<tr><td class="titlefield">'.$langs->trans(
"Name").
'</td>';
221 print
'<td colspan="2">'.$object->name;
222 if (!$object->entity) {
223 print
img_picto($langs->trans(
"GlobalGroup"),
'redstar');
225 print
"</td></tr>\n";
229 print
'<tr><td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td>';
230 print
'<td class="valeur sensiblehtmlcontent">';
235 print
'</table><br>';
238 print
info_admin($langs->trans(
"WarningOnlyPermissionOfActivatedModules"));
242 $reshook = $hookmanager->executeHooks(
'insertExtraHeader',
$parameters, $object, $action);
248 print
'<div class="div-table-responsive-no-min">';
249 print
'<table class="noborder centpercent">';
250 print
'<tr class="liste_titre">';
251 print
'<td>'.$langs->trans(
"Module").
'</td>';
253 print
'<td class="center nowrap">';
254 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>";
256 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>";
259 print
'<td class="center" width="24"> </td>';
260 print
'<td>'.$langs->trans(
"Permissions").
'</td>';
262 print
'<td class="right"></td>';
266 $sql =
"SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault";
267 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
268 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
269 $sql .=
" AND r.entity = ".((int) $entity);
270 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
271 $sql .=
" AND r.perms NOT LIKE '%_advance'";
273 $sql .=
" ORDER BY r.family_position, r.module_position, r.module, r.id";
275 $result = $db->query($sql);
277 $num = $db->num_rows($result);
282 $obj = $db->fetch_object($result);
285 if (empty($modules[$obj->module])) {
290 $objMod = $modules[$obj->module];
293 if (isset($obj->module) && ($oldmod <> $obj->module)) {
294 $oldmod = $obj->module;
297 $objMod = $modules[$obj->module];
298 $picto = ($objMod->picto ? $objMod->picto :
'generic');
301 print
'<tr class="oddeven trforbreak">';
302 print
'<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
303 print
img_object(
'', $picto,
'class="pictoobjectwidth paddingright"').
' '.$objMod->getName();
304 print
'<a name="'.$objMod->getName().
'"></a>';
307 print
'<td class="center nowrap">';
308 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>";
310 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>";
313 print
'<td> </td>';
315 print
'<td> </td>';
316 print
'<td> </td>';
320 print
'<td class="right"></td>';
326 print
'<!-- '.$obj->module.
'->'.$obj->perms.($obj->subperms ?
'->'.$obj->subperms :
'').
' -->'.
"\n";
327 print
'<tr class="oddeven">';
330 print
'<td class="maxwidthonsmartphone tdoverflowonsmartphone">';
334 if (!empty($permsgroupbyentity[$entity]) && is_array($permsgroupbyentity[$entity])) {
335 if (in_array($obj->id, $permsgroupbyentity[$entity])) {
338 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">';
340 print
img_picto($langs->trans(
"Remove"),
'switch_on');
343 print
'<td class="center nowrap">';
344 print
img_picto($langs->trans(
"Active"),
'tick');
349 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">';
351 print
img_picto($langs->trans(
"Add"),
'switch_off');
354 print
'<td> </td>';
359 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().
'">';
361 print
img_picto($langs->trans(
"Add"),
'switch_off');
364 print
'<td> </td>';
368 $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)));
371 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
372 if (preg_match(
'/_advance$/', $obj->perms)) {
373 print
' <span class="opacitymedium">('.$langs->trans(
"AdvancedModeOnly").
')</span>';
380 print
'<td class="right">';
381 $htmltext = $langs->trans(
"ID").
': '.$obj->id;
382 $htmltext .=
'<br>'.$langs->trans(
"Permission").
': user->rights->'.$obj->module.
'->'.$obj->perms.($obj->subperms ?
'->'.$obj->subperms :
'');
383 print
$form->textwithpicto(
'', $htmltext);
399 $reshook = $hookmanager->executeHooks(
'insertExtraFooter',
$parameters, $object, $action);
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dolGetModulesDirs($subdir='')
Return list of modules directories.
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
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.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array())
Clean a string to keep only desirable HTML tags.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
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_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
group_prepare_head($object)
Prepare array with list of tabs.