From 6c521073ea9215fb7baddca5e48345b20b1ab5a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Apr 2021 13:52:19 +0200 Subject: [PATCH] Fix perm id and sort of modules by id. --- htdocs/admin/system/modules.php | 71 ++++++++---------- htdocs/core/modules/modBlockedLog.class.php | 2 +- htdocs/core/modules/modBom.class.php | 2 +- htdocs/core/modules/modDebugBar.class.php | 2 +- .../modules/modEventOrganization.class.php | 3 +- htdocs/core/modules/modLoan.class.php | 2 +- htdocs/core/modules/modMailing.class.php | 2 +- htdocs/core/modules/modMrp.class.php | 2 +- htdocs/core/modules/modNotification.class.php | 2 +- .../core/modules/modReceiptPrinter.class.php | 2 +- htdocs/core/modules/modWorkstation.class.php | 5 +- htdocs/core/modules/modZapier.class.php | 2 +- htdocs/theme/eldy/img/object_zapier.png | Bin 459 -> 3516 bytes htdocs/user/class/user.class.php | 5 +- htdocs/user/perms.php | 4 +- 15 files changed, 50 insertions(+), 56 deletions(-) diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index f9b8bdb65c8..51f3b4577cf 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -228,26 +228,26 @@ print ''; if ($arrayfields['name']['checked']) { print ''; - print ''; + print ''; print ''; } if ($arrayfields['version']['checked']) { print ''; - print ''; + print ''; print ''; } if ($arrayfields['id']['checked']) { print ''; - print ''; - print ''; -} -if ($arrayfields['module_position']['checked']) { - print ''; + print ''; print ''; } if ($arrayfields['permission']['checked']) { print ''; - print ''; + print ''; + print ''; +} +if ($arrayfields['module_position']['checked']) { + print ''; print ''; } @@ -267,14 +267,14 @@ if ($arrayfields['version']['checked']) { print_liste_field_titre($arrayfields['version']['label'], $_SERVER["PHP_SELF"], "version", "", "", "", $sortfield, $sortorder); } if ($arrayfields['id']['checked']) { - print_liste_field_titre($arrayfields['id']['label'], $_SERVER["PHP_SELF"], "id", "", "", "", $sortfield, $sortorder); -} -if ($arrayfields['module_position']['checked']) { - print_liste_field_titre($arrayfields['module_position']['label'], $_SERVER["PHP_SELF"], "module_position", "", "", "", $sortfield, $sortorder); + print_liste_field_titre($arrayfields['id']['label'], $_SERVER["PHP_SELF"], "id", "", "", "", $sortfield, $sortorder, 'nowraponall '); } if ($arrayfields['permission']['checked']) { print_liste_field_titre($arrayfields['permission']['label'], $_SERVER["PHP_SELF"], "permission", "", "", "", $sortfield, $sortorder); } +if ($arrayfields['module_position']['checked']) { + print_liste_field_titre($arrayfields['module_position']['label'], $_SERVER["PHP_SELF"], "module_position", "", "", "", $sortfield, $sortorder); +} // Fields from hook $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); @@ -289,37 +289,30 @@ if ($sortfield == "name" && $sortorder == "asc") { usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($a->name, $b->name); }); -} -if ($sortfield == "name" && $sortorder == "desc") { +} elseif ($sortfield == "name" && $sortorder == "desc") { usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($b->name, $a->name); }); -} -if ($sortfield == "version" && $sortorder == "asc") { +} elseif ($sortfield == "version" && $sortorder == "asc") { usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($a->version, $b->version); }); -} -if ($sortfield == "version" && $sortorder == "desc") { +} elseif ($sortfield == "version" && $sortorder == "desc") { usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($b->version, $a->version); }); -} -if ($sortfield == "id" && $sortorder == "asc") { +} elseif ($sortfield == "id" && $sortorder == "asc") { usort($moduleList, "compareIdAsc"); -} -if ($sortfield == "id" && $sortorder == "desc") { +} elseif ($sortfield == "id" && $sortorder == "desc") { usort($moduleList, "compareIdDesc"); -} -if ($sortfield == "permission" && $sortorder == "asc") { +} elseif ($sortfield == "permission" && $sortorder == "asc") { usort($moduleList, "comparePermissionIdsAsc"); -} -if ($sortfield == "permission" && $sortorder == "desc") { +} elseif ($sortfield == "permission" && $sortorder == "desc") { usort($moduleList, "comparePermissionIdsDesc"); +} else { + $moduleList = dol_sort_array($moduleList, 'module_position'); } -$moduleList = dol_sort_array($moduleList, 'module_position'); - foreach ($moduleList as $module) { print ''; @@ -338,10 +331,6 @@ foreach ($moduleList as $module) { print ''.$module->id.''; } - if ($arrayfields['module_position']['checked']) { - print ''.$module->module_position.''; - } - if ($arrayfields['permission']['checked']) { $idperms = ''; @@ -357,7 +346,11 @@ foreach ($moduleList as $module) { } } - print ''.($idperms ? $idperms : " ").''; + print ''.($idperms ? $idperms : " ").''; + } + + if ($arrayfields['module_position']['checked']) { + print ''.$module->module_position.''; } print ''; @@ -394,11 +387,11 @@ $db->close(); */ function compareIdAsc(stdClass $a, stdClass $b) { - if ($a->id == $b->id) { + if ((int) $a->id == (int) $b->id) { return 0; } - return $a->id > $b->id ? -1 : 1; + return ((int) $a->id < (int) $b->id) ? -1 : 1; } /** @@ -410,11 +403,11 @@ function compareIdAsc(stdClass $a, stdClass $b) */ function compareIdDesc(stdClass $a, stdClass $b) { - if ($a->id == $b->id) { + if ((int) $a->id == (int) $b->id) { return 0; } - return $b->id > $a->id ? -1 : 1; + return ((int) $b->id < (int) $a->id) ? -1 : 1; } /** @@ -441,7 +434,7 @@ function comparePermissionIdsAsc(stdClass $a, stdClass $b) return 0; } - return $a->permission[0] > $b->permission[0] ? -1 : 1; + return $a->permission[0] < $b->permission[0] ? -1 : 1; } /** @@ -468,5 +461,5 @@ function comparePermissionIdsDesc(stdClass $a, stdClass $b) return 0; } - return $a->permission[0] > $b->permission[0] ? 1 : -1; + return $b->permission[0] < $a->permission[0] ? -1 : 1; } diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 16f95a5e926..9a90fa945bb 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -113,7 +113,7 @@ class modBlockedLog extends DolibarrModules // ----------------- $this->rights = array(); // Permission array used by this module - $r = 0; + $r = 1; $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Read archived events and fingerprints'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index 67a480dcc08..6b69c6b7af0 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -205,7 +205,7 @@ class modBom extends DolibarrModules // Permissions provided by this module $this->rights = array(); // Permission array used by this module - $r = 0; + $r = 1; $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Read bom of Bom'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) diff --git a/htdocs/core/modules/modDebugBar.class.php b/htdocs/core/modules/modDebugBar.class.php index 1b591f02da1..ae2bdcfffc8 100644 --- a/htdocs/core/modules/modDebugBar.class.php +++ b/htdocs/core/modules/modDebugBar.class.php @@ -79,7 +79,7 @@ class modDebugBar extends DolibarrModules // Permissions $this->rights = array(); - $this->rights[1][0] = 430; // id de la permission + $this->rights[1][0] = 431; // id de la permission $this->rights[1][1] = 'Use Debug Bar'; // libelle de la permission $this->rights[1][2] = 'u'; // type de la permission (deprecie a ce jour) $this->rights[1][3] = 1; // La permission est-elle une permission par defaut diff --git a/htdocs/core/modules/modEventOrganization.class.php b/htdocs/core/modules/modEventOrganization.class.php index 9ee0cb1b74f..3a81102f4bd 100644 --- a/htdocs/core/modules/modEventOrganization.class.php +++ b/htdocs/core/modules/modEventOrganization.class.php @@ -224,7 +224,8 @@ class modEventOrganization extends DolibarrModules // Permissions provided by this module $this->rights = array(); - $r = 0; + $r = 1; + // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) diff --git a/htdocs/core/modules/modLoan.class.php b/htdocs/core/modules/modLoan.class.php index 30aa547cb3a..b061e1b73a6 100644 --- a/htdocs/core/modules/modLoan.class.php +++ b/htdocs/core/modules/modLoan.class.php @@ -97,7 +97,7 @@ class modLoan extends DolibarrModules $r = 0; $r++; - $this->rights[$r][0] = 520; + $this->rights[$r][0] = 521; $this->rights[$r][1] = 'Read loans'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index 9d590631fe4..ad14724d154 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -48,7 +48,7 @@ class modMailing extends DolibarrModules // It is used to group modules by family in module setup page $this->family = "interface"; // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '22'; + $this->module_position = '23'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); diff --git a/htdocs/core/modules/modMrp.class.php b/htdocs/core/modules/modMrp.class.php index 0a4a7592a20..eb3baae78cd 100644 --- a/htdocs/core/modules/modMrp.class.php +++ b/htdocs/core/modules/modMrp.class.php @@ -236,7 +236,7 @@ class modMrp extends DolibarrModules // Permissions provided by this module $this->rights = array(); - $r = 0; + $r = 1; // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) diff --git a/htdocs/core/modules/modNotification.class.php b/htdocs/core/modules/modNotification.class.php index e124b8304f3..072e0607b60 100644 --- a/htdocs/core/modules/modNotification.class.php +++ b/htdocs/core/modules/modNotification.class.php @@ -45,7 +45,7 @@ class modNotification extends DolibarrModules // It is used to group modules in module setup page $this->family = "interface"; // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '01'; + $this->module_position = '22'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "EMail notifications (push) on business Dolibarr events"; diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php index 4fe437700e4..ee87f4c57ba 100644 --- a/htdocs/core/modules/modReceiptPrinter.class.php +++ b/htdocs/core/modules/modReceiptPrinter.class.php @@ -95,7 +95,7 @@ class modReceiptPrinter extends DolibarrModules // $this->rights[$r][5] Niveau 2 pour nommer permission dans code $r++; - $this->rights[$r][0] = 67000; + $this->rights[$r][0] = 67001; $this->rights[$r][1] = 'ReceiptPrinter'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; diff --git a/htdocs/core/modules/modWorkstation.class.php b/htdocs/core/modules/modWorkstation.class.php index 02f5e059297..84234a9f6a3 100755 --- a/htdocs/core/modules/modWorkstation.class.php +++ b/htdocs/core/modules/modWorkstation.class.php @@ -45,7 +45,7 @@ class modWorkstation extends DolibarrModules // Id for module (must be unique). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 500000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve an id number for your module + $this->numero = 690; // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'workstation'; // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' @@ -239,7 +239,7 @@ class modWorkstation extends DolibarrModules // Permissions provided by this module $this->rights = array(); - $r = 0; + $r = 1; // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) @@ -330,6 +330,7 @@ class modWorkstation extends DolibarrModules // This is a Left menu entry 'type'=>'left', 'titre'=>$langs->trans('Workstations'), + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'), 'mainmenu'=>'mrp', 'leftmenu'=>'workstation_workstation', 'url'=>'', diff --git a/htdocs/core/modules/modZapier.class.php b/htdocs/core/modules/modZapier.class.php index 5685a30c701..430622465ca 100644 --- a/htdocs/core/modules/modZapier.class.php +++ b/htdocs/core/modules/modZapier.class.php @@ -242,7 +242,7 @@ class modZapier extends DolibarrModules // Permission array used by this module $this->rights = array(); - $r = 0; + $r = 1; // Permission id (must not be already used) $this->rights[$r][0] = $this->numero + $r; // Permission label diff --git a/htdocs/theme/eldy/img/object_zapier.png b/htdocs/theme/eldy/img/object_zapier.png index b1337750b6732d01fcc1b04daab1612b71e20c85..b244cb1d5d675f0ae90fbe86e9b637842c15b961 100644 GIT binary patch delta 3352 zcmV+z4d?R91H2oMBYz4DdQ@0+Qek%>aB^>EX>4U6ba`-PAZ2)IW&i+q+U1yQmfX4x zg#U9DS%UZgK`w{SbFzahKOZP{d&c&}zSsGcjNC1?T1|qeLZN84{`Jr8{=r`iS8z$R z4AFuOX?g*m2d~BT4c^97ZF>)PacIQ@k1|uP#miIbe*T)2XO7iQjOK??C)xfr z3=c9$isxsULwO0;dXCCbu67L|pVzo-%HgXIpt7A$e){IOU*|mhAjA|_P|hI?fU$aQHDMTX_RdoP;`f7_oCLp)2mb2=f1oM|%1Lu!f$i$|5MBH?ZpDLhGd zmymZlp8-e_a|^-v2m)93QGE87hM?Y)#{xi&$U{t_gMb$alORK)LW0v!g3Zlu)SqXA zgdFTP+J6KP5_43rsj&f8N&O;{-07jmp1SnhwU=Id8_;K@AtMhRWz^AT zm~kQ#Gf$mm*4dVK3#C|T$;wMtS#`Ay*LK`#%YV*WciDBfH);>6KOBDnHUFR%4pR1< zzER_@Q+*BLO-{rx1F?`ih^rw0p@U&|6`xWtcZFfAWs`!{yq zkozs%oRr_fE&K{OXVCpOkaIxyBW^!IZCalj2eG>fEvHwc`go>=;&@#bZ-09JKOCr! zoPYb(`lxl~I{MC$(%IG(bOwpbucdu2P@!j(pl)7@vl+We?+Il|EAQ^XY8yybt0T@) z^PWIzBc+}5nXk_rR~~2TX13M`_m-hWpLSy$buw<5XDob4S7wmzX?x>vXQ*khci zTq`r=HJE`GxW&r~Q`U?!X2~OMie%N?{iItD5-rgJ>%>NpP(|a(l3Oi~{kL%6KDQ+! z(UfNqM{&-vt;d#Yx4EMN2QxL6NM2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+ // If we are changing our own permissions, we reload permissions and menu if ($object->id == $user->id) { $user->clearrights(); $user->getrights(); @@ -124,7 +124,7 @@ if (empty($reshook)) { setEventMessages($edituser->error, $edituser->errors, 'errors'); } - // If we are changing our own permissions, we reload + // If we are changing our own permissions, we reload permissions and menu if ($object->id == $user->id) { $user->clearrights(); $user->getrights();