diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 2f416e2e296..fce9702d6c9 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -537,9 +537,9 @@ function reWriteAllPermissions($file, $permissions, $key, $right, $objectname, $ } else { $permsToadd = array(); $perms = array( - 'read' => 'Read objects of '.ucfirst($module), - 'write' => 'Create/Update objects of '.ucfirst($module), - 'delete' => 'Delete objects of '.ucfirst($module) + 'read' => 'Read '.$objectname.' object of '.ucfirst($module), + 'write' => 'Create/Update '.$objectname.' object of '.ucfirst($module), + 'delete' => 'Delete '.$objectname.' object of '.ucfirst($module) ); $i = 0; foreach ($perms as $index => $value) { @@ -681,8 +681,8 @@ function writePropsInAsciiDoc($file, $objectname, $destfile) $table .= implode("|", $values) . "\n"; } // end table - $table .= "|==="; - $table .= "__ end table for object $objectname"; + $table .= "|===\n"; + $table .= "__ end table for object $objectname\n"; //write in file $writeInFile = dolReplaceInFile($destfile, array('== DATA SPECIFICATIONS'=> $table)); if ($writeInFile<0) { @@ -925,16 +925,6 @@ function removeObjectFromApiFile($file, $objectname, $modulename) return 1; } -/** - * Compare menus by their object - * @param mixed $a first value - * @param mixed $b seconde value - * @return int 1 if OK, -1 if KO - */ -function compareMenus($a, $b) -{ - return strcmp($a['fk_menu'], $b['fk_menu']); -} /** * @param string $file path of filename @@ -995,9 +985,6 @@ function reWriteAllMenus($file, $menus, $menuWantTo, $key, $action) $allMenus = getFromFile($file, $beginMenu, $endMenu); dolReplaceInFile($file, array($allMenus => '')); - // orders menu with other menus that have the same object - usort($menus, 'compareMenus'); - //prepare each menu and stock them in string $str_menu = ""; foreach ($menus as $index =>$menu) { diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index d6527adc0a8..9056b129d6d 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2019,20 +2019,6 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { $objectForPerms = strtolower(GETPOST('permissionObj', 'alpha')); $crud = GETPOST('crud', 'alpha'); - // check coherence between crud and label - if ($label == "Read objects of $module" && $crud != "read") { - $crud = "read"; - $label == "Read objects of $module"; - } - if ($label == "Create/Update objects of $module" && $crud != "write") { - $crud = "write"; - $label == "Create/Update objects of $module"; - } - if ($label == "Delete objects of $module" && $crud != "delete") { - $crud = "delete"; - $label == "Delete objects of $module"; - } - //check existing object permission $counter = 0; $permsForObject =array(); @@ -2054,9 +2040,9 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { // check if label of object already exists $countPermsObj = count($permsForObject); for ($j = 0; $j<$countPermsObj; $j++) { - if (in_array($label, $permsForObject[$j])) { + if (in_array($crud, $permsForObject[$j])) { $error++; - setEventMessages($langs->trans("ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)), null, 'errors'); + setEventMessages($langs->trans("ErrorExistingPermission", $langs->transnoentities($crud), $langs->transnoentities($objectForPerms)), null, 'errors'); } } @@ -4688,24 +4674,24 @@ if ($module == 'initmodule') { print '