diff options
author | plegall <plg@piwigo.org> | 2005-08-17 15:25:32 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2005-08-17 15:25:32 +0000 |
commit | 3cf427b4d6733f39b5a8f89bcfc8e5c1851adf18 (patch) | |
tree | 976ce5ed95f4e90ded96e661fc881a96d918d7e7 /admin/user_perm.php | |
parent | 20f05416971676e5433da86f3f924d4efe2f92df (diff) |
- improvement : in admin/user_perm, already authorized categories thanks to
group associations are displayed and not taken into account for user
specific permissions.
git-svn-id: http://piwigo.org/svn/trunk@818 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/user_perm.php')
-rw-r--r-- | admin/user_perm.php | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/admin/user_perm.php b/admin/user_perm.php index 56af243bb..400678ce2 100644 --- a/admin/user_perm.php +++ b/admin/user_perm.php @@ -141,12 +141,56 @@ $template->assign_vars( ) ); + +// retrieve category ids authorized to the groups the user belongs to +$group_authorized = array(); + +$query = ' +SELECT DISTINCT cat_id, c.uppercats, c.global_rank + FROM '.USER_GROUP_TABLE.' AS ug + INNER JOIN '.GROUP_ACCESS_TABLE.' AS ga + ON ug.group_id = ga.group_id + INNER JOIN '.CATEGORIES_TABLE.' AS c + ON c.id = ga.cat_id + WHERE ug.user_id = '.$page['user'].' +;'; +$result = pwg_query($query); + +if (mysql_num_rows($result) > 0) +{ + $template->assign_block_vars('groups', array()); + + $cats = array(); + while ($row = mysql_fetch_array($result)) + { + array_push($cats, $row); + array_push($group_authorized, $row['cat_id']); + } + usort($cats, 'global_rank_compare'); + + foreach ($cats as $category) + { + $template->assign_block_vars( + 'groups.category', + array( + 'NAME' => get_cat_display_name_cache($category['uppercats'], '', false) + ) + ); + } +} + // only private categories are listed $query_true = ' SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_ACCESS_TABLE.' ON cat_id = id WHERE status = \'private\' - AND user_id = '.$page['user'].' + AND user_id = '.$page['user']; +if (count($group_authorized) > 0) +{ + $query_true.= ' + AND cat_id NOT IN ('.implode(',', $group_authorized).')'; +} +$query_true.= ' ;'; display_select_cat_wrapper($query_true,array(),'category_option_true'); @@ -166,6 +210,11 @@ if (count($authorized_ids) > 0) $query_false.= ' AND id NOT IN ('.implode(',', $authorized_ids).')'; } +if (count($group_authorized) > 0) +{ + $query_false.= ' + AND id NOT IN ('.implode(',', $group_authorized).')'; +} $query_false.= ' ;'; display_select_cat_wrapper($query_false,array(),'category_option_false'); |