Ignore:
Timestamp:
Feb 13, 2010, 12:04:07 AM (15 years ago)
Author:
plg
Message:

bug 1431: Community users now can see empty categories just like any admin.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/include/ws_functions.inc.php

    r4684 r4883  
    366366  global $user,$conf;
    367367
    368   $where = array();
     368  $where = array('1=1');
     369  $join_type = 'INNER';
     370  $join_user = $user['id'];
    369371
    370372  if (!$params['recursive'])
     
    387389    $where[] = 'status = "public"';
    388390    $where[] = 'visible = "true"';
    389     $where[]= 'user_id='.$conf['guest_id'];
    390   }
    391   else
    392   {
    393     $where[]= 'user_id='.$user['id'];
     391   
     392    $join_user = $conf['guest_id'];
     393  }
     394  elseif (is_admin())
     395  {
     396    // in this very specific case, we don't want to hide empty
     397    // categories. Function calculate_permissions will only return
     398    // categories that are either locked or private and not permitted
     399    //
     400    // calculate_permissions does not consider empty categories as forbidden
     401    $forbidden_categories = calculate_permissions($user['id'], $user['status']);
     402    $where[]= 'id NOT IN ('.$forbidden_categories.')';
     403    $join_type = 'LEFT';
    394404  }
    395405
     
    399409    date_last, max_date_last, count_categories AS nb_categories
    400410  FROM '.CATEGORIES_TABLE.'
    401    INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ON id=cat_id
     411   '.$join_type.' JOIN '.USER_CACHE_CATEGORIES_TABLE.' ON id=cat_id AND user_id='.$join_user.'
    402412  WHERE '. implode('
    403413    AND ', $where);
Note: See TracChangeset for help on using the changeset viewer.