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
This commit is contained in:
plegall 2010-02-12 23:05:37 +00:00
parent bde6e61531
commit ddf51992f0

View file

@ -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);