Changeset 818


Ignore:
Timestamp:
Aug 17, 2005, 5:25:32 PM (19 years ago)
Author:
plg
Message:
  • improvement : in admin/user_perm, already authorized categories thanks to group associations are displayed and not taken into account for user specific permissions.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/user_perm.php

    r817 r818  
    142142  );
    143143
     144
     145// retrieve category ids authorized to the groups the user belongs to
     146$group_authorized = array();
     147
     148$query = '
     149SELECT DISTINCT cat_id, c.uppercats, c.global_rank
     150  FROM '.USER_GROUP_TABLE.' AS ug
     151    INNER JOIN '.GROUP_ACCESS_TABLE.' AS ga
     152      ON ug.group_id = ga.group_id
     153    INNER JOIN '.CATEGORIES_TABLE.' AS c
     154      ON c.id = ga.cat_id
     155  WHERE ug.user_id = '.$page['user'].'
     156;';
     157$result = pwg_query($query);
     158
     159if (mysql_num_rows($result) > 0)
     160{
     161  $template->assign_block_vars('groups', array());
     162
     163  $cats = array();
     164  while ($row = mysql_fetch_array($result))
     165  {
     166    array_push($cats, $row);
     167    array_push($group_authorized, $row['cat_id']);
     168  }
     169  usort($cats, 'global_rank_compare');
     170
     171  foreach ($cats as $category)
     172  {
     173    $template->assign_block_vars(
     174      'groups.category',
     175      array(
     176        'NAME' => get_cat_display_name_cache($category['uppercats'], '', false)
     177        )
     178      );
     179  }
     180}
     181
    144182// only private categories are listed
    145183$query_true = '
     
    147185  FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_ACCESS_TABLE.' ON cat_id = id
    148186  WHERE status = \'private\'
    149     AND user_id = '.$page['user'].'
     187    AND user_id = '.$page['user'];
     188if (count($group_authorized) > 0)
     189{
     190  $query_true.= '
     191    AND cat_id NOT IN ('.implode(',', $group_authorized).')';
     192}
     193$query_true.= '
    150194;';
    151195display_select_cat_wrapper($query_true,array(),'category_option_true');
     
    167211    AND id NOT IN ('.implode(',', $authorized_ids).')';
    168212}
     213if (count($group_authorized) > 0)
     214{
     215  $query_false.= '
     216    AND id NOT IN ('.implode(',', $group_authorized).')';
     217}
    169218$query_false.= '
    170219;';
  • trunk/doc/ChangeLog

    r817 r818  
     12005-08-17 Pierrick LE GALL
     2
     3        * improvement : in admin/user_perm, already authorized categories
     4        thanks to group associations are displayed and not taken into
     5        account for user specific permissions.
     6
    172005-08-17 Pierrick LE GALL
    28
  • trunk/template/default/admin/user_perm.tpl

    r817 r818  
    11<h1>{TITLE}</h1>
    22
    3 <form method="post" action="{F_ACTION}">
    4   {DOUBLE_SELECT}
    5 </form>
     3<!-- BEGIN groups -->
     4<fieldset>
     5  <legend>{lang:Categories authorized thanks to group associations}</legend>
    66
    7 <p>{lang:Only private categories are listed}</p>
     7  <ul>
     8    <!-- BEGIN category -->
     9    <li>{groups.category.NAME}</li>
     10    <!-- END category -->
     11  </ul>
     12</fieldset>
     13<!-- END groups -->
     14
     15<fieldset>
     16  <legend>{lang:Other private categories}</legend>
     17
     18  <form method="post" action="{F_ACTION}">
     19    {DOUBLE_SELECT}
     20  </form>
     21</fieldset>
  • trunk/template/default/default.css

    r817 r818  
    598598  margin: 5px;
    599599}
     600
     601div#adminMain>fieldset {
     602  margin: 10px;
     603}
     604
     605fieldset>legend {
     606  font-style: italic;
     607}
Note: See TracChangeset for help on using the changeset viewer.