Changeset 4884


Ignore:
Timestamp:
02/13/10 00:05:37 (10 years ago)
Author:
plg
Message:

merge r4883 from branch 2.0 to trunk

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/ws_functions.inc.php

    r4781 r4884  
    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.