dolibarr 22.0.5
perms.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
4 * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
6 * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
8 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
9 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
30if (!defined('CSRFCHECK_WITH_TOKEN')) {
31 define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
32}
33
34// Load Dolibarr environment
35require '../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
40
49// Load translation files required by page
50$langs->loadLangs(array('users', 'admin'));
51
52$id = GETPOSTINT('id');
53$action = GETPOST('action', 'aZ09');
54$confirm = GETPOST('confirm', 'alpha');
55$module = GETPOST('module', 'alpha');
56$rights = GETPOSTINT('rights');
57$updatedmodulename = GETPOST('updatedmodulename', 'alpha');
58$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'groupperms'; // To manage different context of search
59
60if (!isset($id) || empty($id)) {
62}
63
64// Define if user can read permissions
65$permissiontoread = ($user->admin || $user->hasRight("user", "user", "read"));
66// Define if user can modify group permissions
67$permissiontoedit = ($user->admin || $user->hasRight("user", "user", "write"));
68// Advanced permissions
69$advancedpermsactive = false;
70if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
71 $advancedpermsactive = true;
72 $permissiontoread = ($user->admin || ($user->hasRight("user", "group_advance", "read") && $user->hasRight("user", "group_advance", "readperms")));
73 $permissiontoedit = ($user->admin || $user->hasRight("user", "group_advance", "write"));
74}
75
76// Security check
77$socid = 0;
78if (!empty($user->socid) && $user->socid > 0) {
79 $socid = $user->socid;
80}
81//$result = restrictedArea($user, 'user', $id, 'usergroup', '');
82if (!$permissiontoread) {
84}
85
86$object = new UserGroup($db);
87$object->fetch($id);
88$object->loadRights();
89
90$entity = $conf->entity;
91
92// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
93$hookmanager->initHooks(array('groupperms', 'globalcard'));
94
95
96/*
97 * Actions
98 */
99
100$parameters = array('socid' => $socid);
101$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
102if ($reshook < 0) {
103 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
104}
105
106if (empty($reshook)) {
107 if ($action == 'addrights' && $permissiontoedit) {
108 $editgroup = new UserGroup($db);
109 $result = $editgroup->fetch($object->id);
110 if ($result > 0) {
111 $result = $editgroup->addrights($rights, $module, '', $entity);
112 if ($result < 0) {
113 setEventMessages($editgroup->error, $editgroup->errors, 'errors');
114 }
115 } else {
116 dol_print_error($db);
117 }
118
119 $user->clearrights();
120 $user->loadRights();
121 }
122
123 if ($action == 'delrights' && $permissiontoedit) {
124 $editgroup = new UserGroup($db);
125 $result = $editgroup->fetch($id);
126 if ($result > 0) {
127 $result = $editgroup->delrights($rights, $module, '', $entity);
128 if ($result < 0) {
129 setEventMessages($editgroup->error, $editgroup->errors, 'errors');
130 }
131 } else {
132 dol_print_error($db);
133 }
134
135 $user->clearrights();
136 $user->loadRights();
137 }
138}
139
140
141/*
142 * View
143 */
144
145$form = new Form($db);
146
147$title = $object->name." - ".$langs->trans('Permissions');
148$help_url = '';
149llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-user page-group_perms');
150
151if ($object->id > 0) {
153 $title = $langs->trans("Group");
154 print dol_get_fiche_head($head, 'rights', $title, -1, 'group');
155
156 // Charge les modules soumis a permissions
157 $modules = array();
158 $modulesdir = dolGetModulesDirs();
159
160 $db->begin();
161
162 foreach ($modulesdir as $dir) {
163 $handle = @opendir(dol_osencode($dir));
164 if (is_resource($handle)) {
165 while (($file = readdir($handle)) !== false) {
166 if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') {
167 $modName = substr($file, 0, dol_strlen($file) - 10);
168
169 if ($modName) {
170 include_once $dir.$file;
171 $objMod = new $modName($db);
172 '@phan-var-force DolibarrModules $objMod';
173 // Load all lang files of module
174 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
175 foreach ($objMod->langfiles as $domain) {
176 $langs->load($domain);
177 }
178 }
179 // Load all permissions
180 if ($objMod->rights_class) {
181 $ret = $objMod->insert_permissions(0, $entity);
182 $modules[$objMod->rights_class] = $objMod;
183 }
184 }
185 }
186 }
187 }
188 }
189
190 $db->commit();
191
192 // Read permissions of group
193 $permsgroupbyentity = array();
194
195 $sql = "SELECT DISTINCT r.id, r.libelle, r.module, gr.entity";
196 $sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r,";
197 $sql .= " ".MAIN_DB_PREFIX."usergroup_rights as gr";
198 $sql .= " WHERE gr.fk_id = r.id";
199 $sql .= " AND gr.entity = ".((int) $entity);
200 $sql .= " AND gr.fk_usergroup = ".((int) $object->id);
201
202 dol_syslog("get user perms", LOG_DEBUG);
203 $result = $db->query($sql);
204 if ($result) {
205 $num = $db->num_rows($result);
206 $i = 0;
207 while ($i < $num) {
208 $obj = $db->fetch_object($result);
209 if (!isset($permsgroupbyentity[$obj->entity])) {
210 $permsgroupbyentity[$obj->entity] = array();
211 }
212 array_push($permsgroupbyentity[$obj->entity], $obj->id);
213 $i++;
214 }
215 $db->free($result);
216 } else {
217 dol_print_error($db);
218 }
219
220 /*
221 * Part to add/remove permissions
222 */
223
224 $linkback = '<a href="'.DOL_URL_ROOT.'/user/group/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
225
226 dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin);
227
228
229 print '<div class="fichehalfleft">';
230
231 print '<div class="underbanner clearboth"></div>';
232 print '<table class="border centpercent tableforfield">';
233
234 // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner)
235 if (isModEnabled('multicompany')) {
236 print '<tr><td class="titlefield">'.$langs->trans("Name").'</td>';
237 print '<td class="valeur">'.dol_escape_htmltag($object->name);
238 if (empty($object->entity)) {
239 print img_picto($langs->trans("GlobalGroup"), 'redstar');
240 }
241 print "</td></tr>\n";
242 }
243
244 // Multicompany
245 if (isModEnabled('multicompany') && is_object($mc) && !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1 && $user->admin && !$user->entity) {
246 $mc->getInfo($object->entity);
247 print "<tr>".'<td class="titlefield">'.$langs->trans("Entity").'</td>';
248 print '<td class="valeur">'.dol_escape_htmltag($mc->label);
249 print "</td></tr>\n";
250 }
251
252 unset($object->fields['nom']); // Name already displayed in banner
253
254 // Common attributes
255 $keyforbreak = '';
256 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
257
258 // Other attributes
259 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
260
261 print '</table>';
262
263 print '</div>';
264
265 print '<div class="clearboth"></div>';
266
267 print '<br>';
268
269
270 if ($user->admin) {
271 print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules")." ".$langs->trans("YouCanEnableModulesFrom"));
272 print '<br>';
273 }
274
275 $parameters = array();
276 $reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
277 if ($reshook < 0) {
278 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
279 }
280
281 print "\n";
282 print '<div class="div-table-responsive-no-min">';
283 print '<table class="noborder centpercent">';
284 print '<tr class="liste_titre">';
285 print '<td>'.$langs->trans("Module").'</td>';
286 if ($permissiontoedit) {
287 print '<td class="center nowrap">';
288 print '<a class="reposition commonlink addexpandedmodulesinparamlist" 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>";
289 print '/';
290 print '<a class="reposition commonlink addexpandedmodulesinparamlist" 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>";
291 print '</td>';
292 } else {
293 print '<td></td>';
294 }
295 print '<td class="center" width="24"></td>';
296 print '<td class="right nowrap" colspan="2">';
297 print '<a class="showallperms" title="'.dol_escape_htmltag($langs->trans("ShowAllPerms")).'" alt="'.dol_escape_htmltag($langs->trans("ShowAllPerms")).'" href="#">'.img_picto('', 'folder-open', 'class="paddingright"').'<span class="hideonsmartphone">'.$langs->trans("ExpandAll").'</span></a>';
298 print ' | ';
299 print '<a class="hideallperms" title="'.dol_escape_htmltag($langs->trans("HideAllPerms")).'" alt="'.dol_escape_htmltag($langs->trans("HideAllPerms")).'" href="#">'.img_picto('', 'folder', 'class="paddingright"').'<span class="hideonsmartphone">'.$langs->trans("UndoExpandAll").'</span></a>';
300 print '</td>';
301 print '</tr>'."\n";
302
303 $sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault";
304 $sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
305 $sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
306 $sql .= " AND r.entity = ".((int) $entity);
307 if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
308 $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled
309 }
310 $sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id";
311
312 $result = $db->query($sql);
313 if ($result) {
314 $num = $db->num_rows($result);
315 $i = 0;
316 $j = 0;
317 $oldmod = '';
318
319 $cookietohidegroup = (empty($_COOKIE["DOLUSER_PERMS_HIDE_GRP"]) ? '' : preg_replace('/^,/', '', $_COOKIE["DOLUSER_PERMS_HIDE_GRP"]));
320 $cookietohidegrouparray = explode(',', $cookietohidegroup);
321
322 while ($i < $num) {
323 $obj = $db->fetch_object($result);
324
325 // If line is for a module that does not exist anymore (absent of includes/module), we ignore it
326 if (empty($modules[$obj->module])) {
327 $i++;
328 continue;
329 }
330
331 $objMod = $modules[$obj->module];
332
333 if (GETPOSTISSET('forbreakperms_'.$obj->module)) {
334 $ishidden = GETPOSTINT('forbreakperms_'.$obj->module);
335 } elseif (in_array($j, $cookietohidegrouparray)) { // If j is among list of hidden group
336 $ishidden = 1;
337 } else {
338 $ishidden = 0;
339 }
340 $isexpanded = ! $ishidden;
341
342 // Break found, it's a new module to catch
343 if (isset($obj->module) && ($oldmod != $obj->module)) {
344 $oldmod = $obj->module;
345
346 $j++;
347 if (GETPOSTISSET('forbreakperms_'.$obj->module)) {
348 $ishidden = GETPOSTINT('forbreakperms_'.$obj->module);
349 } elseif (in_array($j, $cookietohidegrouparray)) { // If j is among list of hidden group
350 $ishidden = 1;
351 } else {
352 $ishidden = 0;
353 }
354 $isexpanded = ! $ishidden;
355 // Break detected, we get objMod
356 $objMod = $modules[$obj->module];
357 $picto = ($objMod->picto ? $objMod->picto : 'generic');
358
359 // Show break line
360 print '<tr class="oddeven trforbreakperms trforbreaknobg" data-hide-perms="'.$obj->module.'" data-j="'.$j.'">';
361 // Picto and label of module
362 print '<td class="maxwidthonsmartphone tdoverflowmax200 tdforbreakperms" data-hide-perms="'.dol_escape_htmltag($obj->module).'" title="'.dol_escape_htmltag($objMod->getName()).'">';
363 print '<input type="hidden" name="forbreakperms_'.$obj->module.'" id="idforbreakperms_'.$obj->module.'" css="cssforfieldishiden" data-j="'.$j.'" value="'.($isexpanded ? '0' : "1").'">';
364 print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName();
365 print '<a name="'.$objMod->getName().'"></a>';
366 print '</td>';
367
368 // Permission and tick (2 columns)
369 if ($permissiontoedit) {
370 print '<td class="tdforbreakperms tdforbreakpermsifnotempty center width50 nowraponall" data-hide-perms="'.dol_escape_htmltag($obj->module).'">';
371 print '<span class="permtohide_'.dol_escape_htmltag($obj->module).'" '.(!$isexpanded ? ' style="display:none"' : '').'>';
372 print '<a class="reposition alink addexpandedmodulesinparamlist" 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='.$obj->module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("All")."</a>";
373 print ' / ';
374 print '<a class="reposition alink addexpandedmodulesinparamlist" 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='.$obj->module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("None")."</a>";
375 print '</span>';
376 print '</td>';
377 print '<td class="tdforbreakperms" data-hide-perms="'.dol_escape_htmltag($obj->module).'">';
378 print '</td>';
379 } else {
380 print '<td class="tdforbreakperms" data-hide-perms="'.dol_escape_htmltag($obj->module).'"></td>';
381 print '<td class="tdforbreakperms" data-hide-perms="'.dol_escape_htmltag($obj->module).'"></td>';
382 }
383 // Description of permission (2 columns)
384 print '<td class="tdforbreakperms" data-hide-perms="'.dol_escape_htmltag($obj->module).'"></td>';
385 print '<td class="maxwidthonsmartphone right tdforbreakperms" data-hide-perms="'.dol_escape_htmltag($obj->module).'">';
386 print '<div class="switchfolderperms inline-block marginrightonly folderperms_'.dol_escape_htmltag($obj->module).'"'.($isexpanded ? ' style="display:none;"' : '').'>';
387 print img_picto('', 'folder', 'class="marginright"');
388 print '</div>';
389 print '<div class="switchfolderperms inline-block marginrightonly folderopenperms_'.dol_escape_htmltag($obj->module).'"'.(!$isexpanded ? ' style="display:none;"' : '').'>';
390 print img_picto('', 'folder-open', 'class="marginright"');
391 print '</div>';
392 print '</td>'; //Add picto + / - when open en closed
393 print '</tr>'."\n";
394 }
395
396 $permlabel = (getDolGlobalString('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)));
397
398 print '<!-- '.$obj->module.'->'.$obj->perms.($obj->subperms ? '->'.$obj->subperms : '').' -->'."\n";
399 print '<tr class="oddeven trtohide_'.$obj->module.'"'.(!$isexpanded ? ' style="display:none"' : '').'>';
400
401
402 // Picto and label of module
403 print '<td class="maxwidthonsmartphone">';
404 print '</td>';
405
406 // Permission and tick (2 columns)
407 if (!empty($permsgroupbyentity[$entity]) && is_array($permsgroupbyentity[$entity])) {
408 if (in_array($obj->id, $permsgroupbyentity[$entity])) {
409 // Own permission by group
410 if ($permissiontoedit) {
411 print '<td class="center nowrap">';
412 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&token='.newToken().'&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&updatedmodulename='.$obj->module.'">';
413 //print img_edit_remove($langs->trans("Remove"));
414 print img_picto($langs->trans("Remove"), 'switch_on');
415 print '</a>';
416 print '</td>';
417 } else {
418 print '<td></td>';
419 }
420 print '<td class="center nowrap">';
421 print img_picto($langs->trans("Active"), 'tick');
422 print '</td>';
423 } else {
424 // Do not own permission
425 if ($permissiontoedit) {
426 print '<td class="center nowrap">';
427 print '<a class="reposition addexpandedmodulesinparamlist" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&token='.newToken().'&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&updatedmodulename='.$obj->module.'">';
428 //print img_edit_add($langs->trans("Add"));
429 print img_picto($langs->trans("Add"), 'switch_off');
430 print '</a>';
431 print '</td>';
432 } else {
433 print '<td></td>';
434 }
435 print '<td></td>';
436 }
437 } else {
438 // Do not own permission
439 if ($permissiontoedit) {
440 print '<td class="center nowrap">';
441 print '<a class="reposition addexpandedmodulesinparamlist" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addrights&token='.newToken().'&entity='.$entity.'&rights='.$obj->id.'&confirm=yes&updatedmodulename='.$obj->module.'">';
442 //print img_edit_add($langs->trans("Add"));
443 print img_picto($langs->trans("Add"), 'switch_off');
444 print '</a></td>';
445 } else {
446 print '<td></td>';
447 }
448 print '<td></td>';
449 }
450
451 // Description of permission (1 column)
452 print '<td>';
453 print $permlabel;
454 $idtouse = $obj->id;
455 if (in_array($idtouse, array(121, 122, 125, 126))) { // Force message for the 3 permission on third parties
456 $idtouse = 122;
457 }
458 if ($langs->trans("Permission".$idtouse.'b') != "Permission".$idtouse.'b') {
459 print '<br><span class="opacitymedium">'.$langs->trans("Permission".$idtouse.'b').'</span>';
460 }
461 if ($langs->trans("Permission".$obj->id.'c') != "Permission".$obj->id.'c') {
462 print '<br><span class="opacitymedium">'.$langs->trans("Permission".$obj->id.'c').'</span>';
463 }
464 if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
465 if (preg_match('/_advance$/', $obj->perms)) {
466 print ' <span class="opacitymedium">('.$langs->trans("AdvancedModeOnly").')</span>';
467 }
468 }
469 print '</td>';
470
471 // Permission id
472 if ($user->admin) {
473 print '<td class="right">';
474 $htmltext = $langs->trans("ID").': '.$obj->id;
475 $htmltext .= '<br>'.$langs->trans("Permission").': user->hasRight(\''.dol_escape_htmltag($obj->module).'\', \''.dol_escape_htmltag($obj->perms).'\''.($obj->subperms ? ', \''.dol_escape_htmltag($obj->subperms).'\'' : '').')';
476 print $form->textwithpicto('', $htmltext, 1, 'help', 'inline-block marginrightonly');
477 //print '<span class="opacitymedium">'.$obj->id.'</span>';
478 print '</td>';
479 } else {
480 print '<td></td>';
481 }
482
483 print '</tr>'."\n";
484
485 $i++;
486 }
487 }
488 print '</table>';
489 print '</div>';
490
491 print '<script>';
492 print '$(".tdforbreakperms:not(.alink)").on("click", function(){
493 console.log("Click on tdforbreakperms");
494 moduletohide = $(this).data("hide-perms");
495 j = $(this).data("j");
496 if ($("#idforbreakperms_"+moduletohide).val() == 1) {
497 console.log("idforbreakperms_"+moduletohide+" has value hidden=1, so we show all lines");
498 $(".trtohide_"+moduletohide).show();
499 $(".permtoshow_"+moduletohide).hide();
500 $(".permtohide_"+moduletohide).show();
501 $(".folderperms_"+moduletohide).hide();
502 $(".folderopenperms_"+moduletohide).show();
503 $("#idforbreakperms_"+moduletohide).val("0");
504 } else if (! $(this).hasClass("tdforbreakpermsifnotempty")) {
505 console.log("idforbreakperms_"+moduletohide+" has value hidden=0, so we hide all lines");
506 $(".trtohide_"+moduletohide).hide();
507 $(".folderopenperms_"+moduletohide).hide();
508 $(".folderperms_"+moduletohide).show();
509 $(".permtoshow_"+moduletohide).show();
510 $(".permtohide_"+moduletohide).hide();
511 $("#idforbreakperms_"+moduletohide).val("1");
512 }
513
514 // Now rebuild the value for cookie
515 var hideuserperm="";
516 $(".trforbreakperms").each(function(index) {
517 //console.log( index + ": " + $( this ).data("j") + " " + $( this ).data("hide-perms") + " " + $("input[data-j="+(index+1)+"]").val());
518 if ($("input[data-j="+(index+1)+"]").val() == 1) {
519 hideuserperm=hideuserperm+","+(index+1);
520 }
521 });
522 // set cookie by js
523 date = new Date(); date.setTime(date.getTime()+(30*86400000));
524 if (hideuserperm) {
525 console.log("set cookie DOLUSER_PERMS_HIDE_GRP="+hideuserperm);
526 document.cookie = "DOLUSER_PERMS_HIDE_GRP=" + hideuserperm + "; expires=" + date.toGMTString() + "; path=/ ";
527 } else {
528 console.log("delete cookie DOLUSER_PERMS_HIDE_GRP");
529 document.cookie = "DOLUSER_PERMS_HIDE_GRP=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/ ";
530 }
531 });';
532 print "\n";
533
534 // Button expand / collapse all
535 print '$(".showallperms").on("click", function(){
536 console.log("Click on showallperms");
537
538 console.log("delete cookie DOLUSER_PERMS_HIDE_GRP from showallperms click");
539 document.cookie = "DOLUSER_PERMS_HIDE_GRP=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/ ";
540 $(".tdforbreakperms").each( function(){
541 moduletohide = $(this).data("hide-perms");
542 //console.log(moduletohide);
543 if ($("#idforbreakperms_"+moduletohide).val() != 0) {
544 $(this).trigger("click"); // emulate the click, so the cooki will be resaved
545 }
546 })
547 });
548
549 $(".hideallperms").on("click", function(){
550 console.log("Click on hideallperms");
551
552 $(".tdforbreakperms").each( function(){
553 moduletohide = $(this).data("hide-perms");
554 //console.log(moduletohide);
555 if ($("#idforbreakperms_"+moduletohide).val() != 1) {
556 $(this).trigger("click"); // emulate the click, so the cooki will be resaved
557 }
558 })
559 });';
560 print "\n";
561 print '</script>';
562
563 print '<style>';
564 print '.switchfolderperms{
565 cursor: pointer;
566 }';
567 print '</style>';
568
569 $parameters = array();
570 $reshook = $hookmanager->executeHooks('insertExtraFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
571 if ($reshook < 0) {
572 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
573 }
574
575 print dol_get_fiche_end();
576}
577
578// End of page
579llxFooter();
580$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage generation of HTML components Only common components must be here.
Class to manage user groups.
dolGetModulesDirs($subdir='')
Return list of directories that contain modules.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.