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