feat(ACL) Sort classes correctly in ACL role edition dialog

issue #6028
parent b2a79281
......@@ -46,30 +46,6 @@ class acl
];
}
/*!
* \brief Function sort an array by elements priority
*
* \param Array $list Array to be sorted
*/
static function sort_by_priority ($list)
{
uksort($list,
function ($a, $b)
{
$infos_a = pluglist::pluginInfos(preg_replace('|^[^/]*/|', '', $a));
$infos_b = pluglist::pluginInfos(preg_replace('|^[^/]*/|', '', $b));
$pa = (isset($infos_a['plPriority']) ? $infos_a['plPriority'] : 0);
$pb = (isset($infos_b['plPriority']) ? $infos_b['plPriority'] : 0);
if ($pa == $pb) {
return 0;
}
return ($pa < $pb ? -1 : 1);
}
);
return $list;
}
/*!
* \brief Explode a role
*
......
......@@ -161,6 +161,10 @@ class pluglist
if (isset($infos['plFilter'])) {
$infos['plFilterObject'] = ldapFilter::parse($infos['plFilter']);
}
if (isset($infos['plObjectType']) && !isset($infos['plPriority']) && !is_numeric(key($infos['plObjectType']))) {
/* Set main tab priority to 0 */
$infos['plPriority'] = 0;
}
$infos['plForeignRefs'] = [];
$infos['INDEX'] = $index;
$this->info[$cname] = $infos;
......
......@@ -272,7 +272,6 @@ class ACLEditionDialog extends GenericDialog
$cols = 3;
$tmp = session::get('plist');
$plist = $tmp->info;
asort($plist);
/* Add select all/none buttons */
$style = 'style="width:100px;"';
......@@ -305,7 +304,6 @@ class ACLEditionDialog extends GenericDialog
$display .= '<input '.$style.' type="button" name="set_true_all_write" onClick="acl_set_all(\'[^0]_w$\',true);" value="W+"/>';
$display .= '<input '.$style.' type="button" name="set_false_all_write" onClick="acl_set_all(\'[^0]_w$\',false);" value="W-"/>';
$list = acl::sort_by_priority($list);
foreach ($list as $key => $name) {
/* Create sub acl if it does not exist */
if (!isset($this->aclContents[$key])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment