Ignore:
Timestamp:
Feb 28, 2008, 3:41:48 AM (17 years ago)
Author:
rvelices
Message:
  • migrate many templates to smarty
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_perm.php

    r1961 r2223  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    77// | file          : $Id$
     
    7373// +-----------------------------------------------------------------------+
    7474
    75 if (isset($_POST) and false)
    76 {
    77   echo '<pre>';
    78   print_r($_POST);
    79   echo '</pre>';
    80 }
    8175
    8276if (isset($_POST['deny_groups_submit'])
     
    203197// +-----------------------------------------------------------------------+
    204198
    205 $template->set_filenames(array('cat_perm'=>'admin/cat_perm.tpl'));
     199$template->set_filename('cat_perm', 'admin/cat_perm.tpl');
    206200
    207201$template->assign_vars(
     
    231225  ORDER BY name ASC
    232226;';
    233 $result = pwg_query($query);
    234 
    235 while ($row = mysql_fetch_array($result))
    236 {
    237   $groups[$row['id']] = $row['name'];
    238 }
    239 
     227$groups = simple_hash_from_query($query, 'id', 'name');
     228$template->assign('all_groups', $groups);
     229
     230// groups granted to access the category
    240231$query = '
    241232SELECT group_id
     
    244235;';
    245236$group_granted_ids = array_from_query($query, 'group_id');
    246 
    247 // groups granted to access the category
    248 foreach ($group_granted_ids as $group_id)
    249 {
    250   $template->assign_block_vars(
    251     'group_granted',
    252     array(
    253       'NAME'=>$groups[$group_id],
    254       'ID'=>$group_id
    255       )
    256     );
    257 }
     237$template->assign('group_granted_ids', $group_granted_ids);
     238
    258239
    259240// groups denied
    260 foreach (array_diff(array_keys($groups), $group_granted_ids) as $group_id)
    261 {
    262   $template->assign_block_vars(
    263     'group_denied',
    264     array(
    265       'NAME'=>$groups[$group_id],
    266       'ID'=>$group_id
    267       )
    268     );
    269 }
     241$template->assign('group_denied_ids',
     242      array_diff(array_keys($groups), $group_granted_ids)
     243  );
    270244
    271245// users...
     
    277251  FROM '.USERS_TABLE.'
    278252;';
    279 $result = pwg_query($query);
    280 while($row = mysql_fetch_array($result))
    281 {
    282   $users[$row['id']] = $row['username'];
    283 }
     253$users = simple_hash_from_query($query, 'id', 'username');
     254$template->assign('all_users', $users);
     255
    284256
    285257$query = '
     
    290262$user_granted_direct_ids = array_from_query($query, 'user_id');
    291263
    292 foreach ($user_granted_direct_ids as $user_id)
    293 {
    294   $template->assign_block_vars(
    295     'user_granted',
    296     array(
    297       'NAME'=>$users[$user_id],
    298       'ID'=>$user_id
    299       )
    300     );
    301 }
     264$template->assign('user_granted_direct_ids', $user_granted_direct_ids);
     265
     266
    302267
    303268$user_granted_indirect_ids = array();
     
    336301  foreach ($user_granted_indirect_ids as $user_id)
    337302  {
    338     $group = '';
    339    
    340303    foreach ($granted_groups as $group_id => $group_users)
    341304    {
    342305      if (in_array($user_id, $group_users))
    343306      {
    344         $group = $groups[$group_id];
     307        $template->append(
     308          'user_granted_indirects',
     309          array(
     310            'USER'=>$users[$user_id],
     311            'GROUP'=>$groups[$group_id]
     312            )
     313          );
    345314        break;
    346315      }
    347316    }
    348    
    349     $template->assign_block_vars(
    350       'user_granted_indirect',
    351       array(
    352         'NAME'=>$users[$user_id],
    353         'GROUP'=>$group
    354         )
    355       );
    356317  }
    357318}
     
    360321                              $user_granted_indirect_ids,
    361322                              $user_granted_direct_ids);
    362 
    363 foreach ($user_denied_ids as $user_id)
    364 {
    365   $template->assign_block_vars(
    366     'user_denied',
    367     array(
    368       'NAME'=>$users[$user_id],
    369       'ID'=>$user_id
    370       )
    371     );
    372 }
     323$template->assign('user_denied_ids', $user_denied_ids);
    373324
    374325
Note: See TracChangeset for help on using the changeset viewer.