Ignore:
Timestamp:
Feb 9, 2012, 10:11:34 PM (12 years ago)
Author:
rvelices
Message:
  • remove square/thumb from choices on picture
  • fix content margin on password register
  • purge derivative cache by type of derivative
  • session saved infos/messages are not given to the page on html redirections
  • shorter/faster code in functions_xxx
File:
1 edited

Legend:

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

    r12922 r13074  
    7474{
    7575  global $conf;
    76  
     76
    7777  if (defined("PHPWG_INSTALLED"))
    7878  {
     
    106106
    107107  $SCU_users = array();
    108  
     108
    109109  $q = pwg_query("
    110110    SELECT ".$conf['user_fields']['username']." AS username
     
    115115   // $SCU_users is now an associative table where the key is the account as
    116116   // registered in the DB, and the value is this same account, in lower case
    117    
     117
    118118  $users_found = array_keys($SCU_users, $username_lo);
    119119  // $users_found is now a table of which the values are all the accounts
     
    131131  if ($login == '')
    132132  {
    133     array_push($errors, l10n('Please, enter a login'));
     133    $errors[] = l10n('Please, enter a login');
    134134  }
    135135  if (preg_match('/^.* $/', $login))
    136136  {
    137     array_push($errors, l10n('login mustn\'t end with a space character'));
     137    $errors[] = l10n('login mustn\'t end with a space character');
    138138  }
    139139  if (preg_match('/^ .*$/', $login))
    140140  {
    141     array_push($errors, l10n('login mustn\'t start with a space character'));
     141    $errors[] = l10n('login mustn\'t start with a space character');
    142142  }
    143143  if (get_userid($login))
    144144  {
    145     array_push($errors, l10n('this login is already used'));
     145    $errors[] = l10n('this login is already used');
    146146  }
    147147  if ($login != strip_tags($login))
    148148  {
    149     array_push($errors, l10n('html tags are not allowed in login'));
     149    $errors[] = l10n('html tags are not allowed in login');
    150150  }
    151151  $mail_error = validate_mail_address(null, $mail_address);
    152152  if ('' != $mail_error)
    153153  {
    154     array_push($errors, $mail_error);
     154    $errors[] = $mail_error;
    155155  }
    156156
     
    160160    if ($login_error != '')
    161161    {
    162       array_push($errors, $login_error);
     162      $errors[] = $login_error;
    163163    }
    164164  }
     
    206206      while ($row = pwg_db_fetch_assoc($result))
    207207      {
    208         array_push
    209         (
    210           $inserts,
    211           array
    212           (
     208          $inserts[] = array(
    213209            'user_id' => $next_id,
    214210            'group_id' => $row['id']
    215           )
    216         );
     211          );
    217212      }
    218213    }
     
    401396      if ( empty($forbidden_ids) )
    402397      {
    403         array_push( $forbidden_ids, 0 );
     398        $forbidden_ids[] = 0;
    404399      }
    405400      $userdata['image_access_type'] = 'NOT IN'; //TODO maybe later
     
    424419          if ($cat['count_images']==0)
    425420          {
    426             array_push($forbidden_ids, $cat['cat_id']);
     421            $forbidden_ids[] = $cat['cat_id'];
    427422            unset( $user_cache_cats[$cat['cat_id']] );
    428423          }
     
    519514  ).'
    520515;';
    521   $result = pwg_query($query);
    522   $authorizeds = array();
    523   while ($row = pwg_db_fetch_assoc($result))
    524   {
    525     array_push($authorizeds, $row['image_id']);
    526   }
     516  $authorizeds = array_from_query($query, 'image_id');
    527517
    528518  $query = '
     
    531521  WHERE user_id = '.$user['id'].'
    532522;';
    533   $result = pwg_query($query);
    534   $favorites = array();
    535   while ($row = pwg_db_fetch_assoc($result))
    536   {
    537     array_push($favorites, $row['image_id']);
    538   }
     523  $favorites = array_from_query($query, 'image_id');
    539524
    540525  $to_deletes = array_diff($favorites, $authorizeds);
    541 
    542526  if (count($to_deletes) > 0)
    543527  {
     
    565549function calculate_permissions($user_id, $user_status)
    566550{
    567   $private_array = array();
    568   $authorized_array = array();
    569 
    570551  $query = '
    571552SELECT id
     
    573554  WHERE status = \'private\'
    574555;';
    575   $result = pwg_query($query);
    576   while ($row = pwg_db_fetch_assoc($result))
    577   {
    578     array_push($private_array, $row['id']);
    579   }
     556  $private_array = array_from_query($query, 'id');
    580557
    581558  // retrieve category ids directly authorized to the user
     
    618595    while ($row = pwg_db_fetch_assoc($result))
    619596    {
    620       array_push($forbidden_array, $row['id']);
     597      $forbidden_array[] = $row['id'];
    621598    }
    622599    $forbidden_array = array_unique($forbidden_array);
     
    627604   // where clauses such as "WHERE category_id NOT IN(0)" will always be
    628605   // true.
    629     array_push($forbidden_array, 0);
     606    $forbidden_array[] = 0;
    630607  }
    631608
     
    810787
    811788  $email = pwg_db_real_escape_string($email);
    812  
     789
    813790  $query = '
    814791SELECT
     
    932909    return $theme;
    933910  }
    934  
     911
    935912  // let's find the first available theme
    936913  $active_themes = get_pwg_themes();
     
    11591136  // we force the session table to be clean
    11601137  pwg_session_gc();
    1161  
     1138
    11621139  global $conf;
    11631140  // retrieving the encrypted password of the login submitted
     
    13521329{
    13531330  global $user, $conf;
    1354  
     1331
    13551332  if (is_a_guest())
    13561333  {
    13571334    return false;
    13581335  }
    1359  
     1336
    13601337  if (!in_array($action, array('delete','edit', 'validate')))
    13611338  {
Note: See TracChangeset for help on using the changeset viewer.