Skip to content

Commit

Permalink
merge r4883 from branch 2.0 to trunk
Browse files Browse the repository at this point in the history
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
  • Loading branch information
plegall committed Feb 12, 2010
1 parent bde6e61 commit ddf5199
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions include/ws_functions.inc.php
Expand Up @@ -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'])
{
Expand All @@ -386,19 +388,27 @@ 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 = '
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);

Expand Down

0 comments on commit ddf5199

Please sign in to comment.