Fix perm id and sort of modules by id.
This commit is contained in:
parent
f03190e23b
commit
6c521073ea
@ -228,26 +228,26 @@ print '<tr class="liste_titre_filter">';
|
||||
|
||||
if ($arrayfields['name']['checked']) {
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" name="search_name" size="8" value="'.$search_name.'">';
|
||||
print '<input class="flat" type="text" name="search_name" size="8" value="'.dol_escape_htmltag($search_name).'">';
|
||||
print '</td>';
|
||||
}
|
||||
if ($arrayfields['version']['checked']) {
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" name="search_version" size="8" value="'.$search_version.'">';
|
||||
print '<input class="flat" type="text" name="search_version" size="6" value="'.dol_escape_htmltag($search_version).'">';
|
||||
print '</td>';
|
||||
}
|
||||
if ($arrayfields['id']['checked']) {
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" name="search_id" size="8" value="'.$search_id.'">';
|
||||
print '</td>';
|
||||
}
|
||||
if ($arrayfields['module_position']['checked']) {
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" name="search_id" size="6 value="'.dol_escape_htmltag($search_id).'">';
|
||||
print '</td>';
|
||||
}
|
||||
if ($arrayfields['permission']['checked']) {
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" name="search_permission" size="8" value="'.$search_permission.'">';
|
||||
print '<input class="flat" type="text" name="search_permission" size="8" value="'.dol_escape_htmltag($search_permission).'">';
|
||||
print '</td>';
|
||||
}
|
||||
if ($arrayfields['module_position']['checked']) {
|
||||
print '<td class="liste_titre left">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
@ -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 '<tr class="oddeven">';
|
||||
|
||||
@ -338,10 +331,6 @@ foreach ($moduleList as $module) {
|
||||
print '<td class="center">'.$module->id.'</td>';
|
||||
}
|
||||
|
||||
if ($arrayfields['module_position']['checked']) {
|
||||
print '<td class="center">'.$module->module_position.'</td>';
|
||||
}
|
||||
|
||||
if ($arrayfields['permission']['checked']) {
|
||||
$idperms = '';
|
||||
|
||||
@ -357,7 +346,11 @@ foreach ($moduleList as $module) {
|
||||
}
|
||||
}
|
||||
|
||||
print '<td>'.($idperms ? $idperms : " ").'</td>';
|
||||
print '<td><span class="opacitymedium">'.($idperms ? $idperms : " ").'</span></td>';
|
||||
}
|
||||
|
||||
if ($arrayfields['module_position']['checked']) {
|
||||
print '<td class="center">'.$module->module_position.'</td>';
|
||||
}
|
||||
|
||||
print '<td></td>';
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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'=>'',
|
||||
|
||||
@ -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
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 459 B After Width: | Height: | Size: 3.4 KiB |
@ -673,8 +673,7 @@ class User extends CommonObject
|
||||
if (!empty($rid)) {
|
||||
$module = $perms = $subperms = '';
|
||||
|
||||
// Si on a demande ajout d'un droit en particulier, on recupere
|
||||
// les caracteristiques (module, perms et subperms) de ce droit.
|
||||
// Si on a demande ajout d'un droit en particulier, on recupere les caracteristiques (module, perms et subperms) de ce droit.
|
||||
$sql = "SELECT module, perms, subperms";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def";
|
||||
$sql .= " WHERE id = ".((int) $rid);
|
||||
@ -718,7 +717,7 @@ class User extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
// Ajout des droits trouves grace au critere whereforadd
|
||||
// Add automatically other permission using the criteria whereforadd
|
||||
if (!empty($whereforadd)) {
|
||||
//print "$module-$perms-$subperms";
|
||||
$sql = "SELECT id";
|
||||
|
||||
@ -105,7 +105,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();
|
||||
@ -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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user