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