aboutsummaryrefslogtreecommitdiffstats
path: root/include/ws_functions.inc.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2010-02-12 23:04:07 +0000
committerplegall <plg@piwigo.org>2010-02-12 23:04:07 +0000
commitac67da8a03724aad4126d2aace6414cf77c65578 (patch)
tree9a661e78a891ea8a87c1beb08099074805bcc07b /include/ws_functions.inc.php
parent903b9cab2dfc8c1ea4dfaa7ad9e3360a55566f67 (diff)
bug 1431: Community users now can see empty categories just like any admin.
git-svn-id: http://piwigo.org/svn/branches/2.0@4883 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/ws_functions.inc.php20
1 files changed, 15 insertions, 5 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 402a52a60..063e42d7e 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);