Changeset 680


Ignore:
Timestamp:
Jan 8, 2005, 12:23:52 PM (19 years ago)
Author:
plg
Message:
  • deletion of calculated permissions when deleting a user
  • taking into account locked categories during permissions calculation
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r675 r680  
    322322//     - all the favorites linked to this user
    323323//     - all sessions linked to this user
    324 //     - all categories informations linked to this user
     324//     - calculated permissions linked to the user
    325325function delete_user($user_id)
    326326{
     
    349349  $query = '
    350350DELETE FROM '.SESSIONS_TABLE.'
     351  WHERE user_id = '.$user_id.'
     352;';
     353  pwg_query($query);
     354
     355  // deletion of calculated permissions linked to the user
     356  $query = '
     357DELETE FROM '.USER_FORBIDDEN_TABLE.'
    351358  WHERE user_id = '.$user_id.'
    352359;';
  • trunk/include/functions_user.inc.php

    r675 r680  
    268268 *
    269269 * @param int user_id
     270 * @param string user_status
    270271 * @return string forbidden_categories
    271272 */
    272 function calculate_permissions($user_id)
     273function calculate_permissions($user_id, $user_status)
    273274{
    274275  $private_array = array();
     
    284285  {
    285286    array_push($private_array, $row['id']);
     287  }
     288
     289  // if user is not an admin, locked categories can be considered as private$
     290  if ($user_status != 'admin')
     291  {
     292    $query = '
     293SELECT id
     294  FROM '.CATEGORIES_TABLE.'
     295  WHERE visible = \'false\'
     296;';
     297    $result = pwg_query($query);
     298    while ($row = mysql_fetch_array($result))
     299    {
     300      array_push($private_array, $row['id']);
     301    }
     302
     303    $private_array = array_unique($private_array);
    286304  }
    287305 
  • trunk/include/user.inc.php

    r675 r680  
    129129      or $user['need_update'] == true)
    130130  {
    131     $user['forbidden_categories'] = calculate_permissions($user['id']);
     131    $user['forbidden_categories'] = calculate_permissions($user['id'],
     132                                                          $user['status']);
    132133  }
    133134}
Note: See TracChangeset for help on using the changeset viewer.