From 4bd9a62a4408d08552b48da8690b6fc3f9cdcff9 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Tue, 18 Jul 2023 12:24:16 +0200 Subject: [PATCH] add select perms for each object when add menu --- htdocs/modulebuilder/index.php | 77 +++++++++++++++++++++++++++----- htdocs/theme/eldy/global.inc.php | 8 ++++ 2 files changed, 74 insertions(+), 11 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index c0be68b89cb..e02e3d191cb 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2505,7 +2505,7 @@ if ($dirins && $action == 'addmenu' && empty($cancel)) { 'langs' => strtolower($module)."@".strtolower($module), 'position' => '', 'enabled' => GETPOST('enabled', 'alpha'), - 'perms' => GETPOST('perms', 'alpha'), + 'perms' => '$user->hasRight("'.strtolower($module).'", "'.GETPOST('objects', 'alpha').'", "'.GETPOST('perms', 'alpha').'")', 'target' => GETPOST('target', 'alpha'), 'user' => GETPOST('user', 'alpha'), ); @@ -4350,6 +4350,17 @@ if ($module == 'initmodule') { $permissions = $moduleobj->rights; $crud = array('read'=>'CRUDRead', 'write'=>'CRUDCreateWrite', 'delete'=>'Delete'); + //grouped permissions + $groupedRights = array(); + foreach ($permissions as $right) { + $key = $right[4]; + if (!isset($groupedRights[$key])) { + $groupedRights[$key] = array(); + } + $groupedRights[$key][] = $right; + } + $groupedRights_json = json_encode($groupedRights); + if ($action == 'deletemenu') { $formconfirms = $form->formconfirm( $_SERVER["PHP_SELF"].'?menukey='.urlencode(GETPOST('menukey', 'int')).'&tab='.urlencode($tab).'&module='.urlencode($module), @@ -4434,12 +4445,15 @@ if ($module == 'initmodule') { print ''; print ''; print ''; - print ''; - print ''; + print ''; + foreach ($objects as $value) { + print ''; } print ''; + print ''; print ''; print ''; print ''; @@ -4470,6 +4484,7 @@ if ($module == 'initmodule') { //Perms $arguments = explode(",", $propPerms); $valPerms = trim($arguments[2], ' " "\)'); + $objPerms = trim($arguments[1], ' " "\)'); if ($action == 'editmenu' && GETPOST('menukey', 'int') == $i) { //var_dump($propPerms);exit; @@ -4522,14 +4537,17 @@ if ($module == 'initmodule') { } print ''; print ''; - print ''; - print ''; + print ''; + foreach ($objects as $value) { + if ($objPerms != strtolower($value)) { + print ''; } } + print ''; + print ''; print ''; print ''; @@ -4620,6 +4638,43 @@ if ($module == 'initmodule') { print ''; print ''; + // display permissions for each object + print ''; + print ''; } else { diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 644e183065f..a71d2697e23 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -7994,6 +7994,11 @@ table.jPicker { } } +/* for hide a select */ +.hideSelect { + display : none; +} + @media only screen and (max-width: 320px) { .dropdown dd ul { @@ -8035,3 +8040,6 @@ if (!empty($conf->global->THEME_CUSTOM_CSS)) { div.flot-text .flot-tick-label .tickLabel, .fa-color-unset { color: unset; } + + +