diff options
author | vdigital <vdigital@piwigo.org> | 2008-05-17 20:16:45 +0000 |
---|---|---|
committer | vdigital <vdigital@piwigo.org> | 2008-05-17 20:16:45 +0000 |
commit | 732c6965821b83d64fde2023cbd401a5a5004e2e (patch) | |
tree | 66cbb40bc4d0cf7bccd6ca56827abcc6ccddb063 /admin | |
parent | 4fca6fa23442a83b9ef53a19b5754959674ac0a6 (diff) |
Bug 703: Authorization system in Cat management works now with well ordered lists
git-svn-id: http://piwigo.org/svn/branches/branch-1_7@2348 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r-- | admin/cat_perm.php | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/admin/cat_perm.php b/admin/cat_perm.php index eb0efa3cd..66809ad05 100644 --- a/admin/cat_perm.php +++ b/admin/cat_perm.php @@ -243,7 +243,7 @@ SELECT group_id WHERE cat_id = '.$page['cat'].' ;'; $group_granted_ids = array_from_query($query, 'group_id'); - +$group_granted_ids = order_by_name($group_granted_ids, $groups); // groups granted to access the category foreach ($group_granted_ids as $group_id) { @@ -255,9 +255,10 @@ foreach ($group_granted_ids as $group_id) ) ); } - +$group_denied_ids = array_diff(array_keys($groups), $group_granted_ids); +$group_denied_ids = order_by_name($group_denied_ids, $groups); // groups denied -foreach (array_diff(array_keys($groups), $group_granted_ids) as $group_id) +foreach ($group_denied_ids as $group_id) { $template->assign_block_vars( 'group_denied', @@ -288,7 +289,7 @@ SELECT user_id WHERE cat_id = '.$page['cat'].' ;'; $user_granted_direct_ids = array_from_query($query, 'user_id'); - +$user_granted_direct_ids = order_by_name($user_granted_direct_ids, $users); foreach ($user_granted_direct_ids as $user_id) { $template->assign_block_vars( @@ -332,7 +333,8 @@ SELECT user_id, group_id $user_granted_indirect_ids = array_diff($user_granted_by_group_ids, $user_granted_direct_ids); - + $user_granted_indirect_ids = + order_by_name($user_granted_indirect_ids, $users); foreach ($user_granted_indirect_ids as $user_id) { $group = ''; @@ -359,7 +361,7 @@ SELECT user_id, group_id $user_denied_ids = array_diff(array_keys($users), $user_granted_indirect_ids, $user_granted_direct_ids); - +$user_denied_ids = order_by_name($user_denied_ids, $users); foreach ($user_denied_ids as $user_id) { $template->assign_block_vars( @@ -371,6 +373,19 @@ foreach ($user_denied_ids as $user_id) ); } +// Warning: this function breaks original keys +// This function should be move in the futur to ./include/functions_html.inc +function order_by_name($element_ids,$name) +{ + $ordered_element_ids = array(); + foreach ($element_ids as $k_id => $element_id) + { + $key = strtolower($name[$element_id]) .'-'. $name[$element_id] .'-'. $k_id; + $ordered_element_ids[$key] = $element_id; + } + ksort($ordered_element_ids); + return $ordered_element_ids; +} // +-----------------------------------------------------------------------+ // | sending html code | |