diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index 513d964014a..bf5233c0c6e 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -218,25 +218,25 @@ class FormMargin if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } elseif (empty($reshook)) { - if (!empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) { // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better - print $langs->trans('ShowMarginInfos') . ' : '; + if (!empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) { + print $langs->trans('ShowMarginInfos') . ' '; $hidemargininfos = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']); // Clean cookie - print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; - print '' . img_picto($langs->trans("Enabled"), 'switch_on') . ''; + print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print '' . img_picto($langs->trans("Enabled"), 'switch_on') . ''; print ''; if (!empty($hidemargininfos)) { - print ''; + print ''; } } print '
'; print '' . "\n"; - print ''; + print '
'; print ''; print ''; print ''; diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 53b153ae025..cf055f8382c 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -420,9 +420,13 @@ $sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - $i = 0; + $i = 0; $j = 0; $oldmod = ''; + $cookietohidegroup = (empty($_COOKIE["DOLUSER_PERMS_HIDE_GRP"]) ? '' : preg_replace('/^,/', '', $_COOKIE["DOLUSER_PERMS_HIDE_GRP"])); + $cookietohidegrouparray = explode(',', $cookietohidegroup); + //var_dump($cookietohidegrouparray); + while ($i < $num) { $obj = $db->fetch_object($result); @@ -472,26 +476,39 @@ if ($result) { } */ - /*$isexpanded = ($updatedmodulename == $obj->module || $module == "allmodules"); - if (!$action) { - $isexpanded = 1; // By default (no action done) we have lines expanded - }*/ - $ishidden = GETPOST('forbreakperms_'.$obj->module, 'int'); + if (GETPOSTISSET('forbreakperms_'.$obj->module)) { + $ishidden = GETPOST('forbreakperms_'.$obj->module, 'int'); + } elseif (in_array($j, $cookietohidegrouparray)) { // If j is among list of hidden group + $ishidden = 1; + } else { + $ishidden = 0; + } $isexpanded = ! $ishidden; - //var_dump($isexpanded); + //var_dump("isexpanded=".$isexpanded); // Break found, it's a new module to catch if (isset($obj->module) && ($oldmod <> $obj->module)) { $oldmod = $obj->module; + $j++; + if (GETPOSTISSET('forbreakperms_'.$obj->module)) { + $ishidden = GETPOST('forbreakperms_'.$obj->module, 'int'); + } elseif (in_array($j, $cookietohidegrouparray)) { // If j is among list of hidden group + $ishidden = 1; + } else { + $ishidden = 0; + } + $isexpanded = ! $ishidden; + //var_dump('$obj->module='.$obj->module.' isexpanded='.$isexpanded); + // Break detected, we get objMod $objMod = $modules[$obj->module]; $picto = ($objMod->picto ? $objMod->picto : 'generic'); // Show break line - print ''; - print ''; + print ''; @@ -502,11 +519,11 @@ if ($result) { print ' / '; print 'module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("None").""; print ''; - print ''; + print ''; } else { - print ''; + print ''; } - print ''; + print ''; } else { if ($caneditperms) { print ''; - print ''; + print ''; } else { - print ''; + print ''; } - print ''; + print ''; } - print ''; + print ''; - print '
' . $langs->trans('Margins') . '' . $langs->trans('SellingPrice') . '
'; - print ''; + print '
'; + print ''; print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName(); print ''; print '        '; + print ''; print ''; @@ -640,69 +657,71 @@ print '
'; print '
'; print '