diff options
author | plegall <plg@piwigo.org> | 2010-02-12 23:05:37 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2010-02-12 23:05:37 +0000 |
commit | ddf51992f0787e92d9f6fa1dba2bbb31e50a685d (patch) | |
tree | 35eb7e07068e48e7d6aabb93904db934d25b1044 /include | |
parent | bde6e615311caaa4d5723b424926c4162324ea71 (diff) |
merge r4883 from branch 2.0 to trunk
bug 1431: Community users now can see empty categories just like any admin.
git-svn-id: http://piwigo.org/svn/trunk@4884 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r-- | include/ws_functions.inc.php | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index 66cd950ef..4a9208905 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -365,7 +365,9 @@ function ws_categories_getList($params, &$service) { global $user,$conf; - $where = array(); + $where = array('1=1'); + $join_type = 'INNER'; + $join_user = $user['id']; if (!$params['recursive']) { @@ -386,11 +388,19 @@ function ws_categories_getList($params, &$service) { $where[] = 'status = "public"'; $where[] = 'visible = "true"'; - $where[]= 'user_id='.$conf['guest_id']; + + $join_user = $conf['guest_id']; } - else + elseif (is_admin()) { - $where[]= 'user_id='.$user['id']; + // in this very specific case, we don't want to hide empty + // categories. Function calculate_permissions will only return + // categories that are either locked or private and not permitted + // + // calculate_permissions does not consider empty categories as forbidden + $forbidden_categories = calculate_permissions($user['id'], $user['status']); + $where[]= 'id NOT IN ('.$forbidden_categories.')'; + $join_type = 'LEFT'; } $query = ' @@ -398,7 +408,7 @@ SELECT id, name, permalink, uppercats, global_rank, nb_images, count_images AS total_nb_images, date_last, max_date_last, count_categories AS nb_categories FROM '.CATEGORIES_TABLE.' - INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ON id=cat_id + '.$join_type.' JOIN '.USER_CACHE_CATEGORIES_TABLE.' ON id=cat_id AND user_id='.$join_user.' WHERE '. implode(' AND ', $where); |