Changeset 27388


Ignore:
Timestamp:
Feb 16, 2014, 8:39:19 AM (10 years ago)
Author:
rvelices
Message:

more query2array and remove unnecessary tests in often called url functions

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/comments.php

    r26761 r27388  
    7070      $is_inserted = true;
    7171    }
    72    
     72
    7373    $items_number_new[] = $number;
    7474  }
     
    8989             'clause' => '1=1') // stupid but generic
    9090  );
    91  
     91
    9292trigger_action('loc_begin_comments');
    9393
     
    266266          $_POST['key']
    267267          );
    268        
     268
    269269        switch ($comment_action)
    270270        {
     
    282282        }
    283283      }
    284      
     284
    285285      $edit_comment = $_GET['edit'];
    286286    }
     
    438438  WHERE id IN ('.implode(',', $element_ids).')
    439439;';
    440   $elements = hash_from_query($query, 'id');
     440  $elements = query2array($query, 'id');
    441441
    442442  // retrieving category informations
    443   $query = 'SELECT id, name, permalink, uppercats 
     443  $query = 'SELECT id, name, permalink, uppercats
    444444  FROM '.CATEGORIES_TABLE.'
    445445  WHERE id IN ('.implode(',', $category_ids).')';
    446   $categories = hash_from_query($query, 'id');
     446  $categories = query2array($query, 'id');
    447447
    448448  foreach ($comments as $comment)
     
    468468        )
    469469      );
    470      
     470
    471471    $email = null;
    472472    if (!empty($comment['user_email']))
     
    489489      'CONTENT'=>trigger_event('render_comment_content',$comment['content']),
    490490      );
    491      
     491
    492492    if (is_admin())
    493493    {
  • trunk/include/functions_url.inc.php

    r26461 r27388  
    133133
    134134  $url_before_params = $url;
    135  
     135
    136136  $url.= make_section_in_url($params);
    137137  $url = add_well_known_params_in_url($url, $params);
     
    141141    $url = get_absolute_root_url( url_is_remote($url) );
    142142  }
    143  
     143
    144144  return $url;
    145145}
     
    216216{
    217217  global $conf;
    218 
    219   isset($params['image_id']) or fatal_error('make_picture_url: image_id is a required parameter');
    220218
    221219  $url = get_root_url().'picture';
     
    338336      else
    339337      {
    340         is_array($params['category']) or trigger_error(
    341             'make_section_in_url wrong type for category', E_USER_WARNING
    342             );
    343         is_numeric($params['category']['id']) or trigger_error(
    344             'make_section_in_url category id not numeric', E_USER_WARNING
    345             );
    346338        isset($params['category']['name']) or trigger_error(
    347339            'make_section_in_url category name not set', E_USER_WARNING
     
    371363    case 'tags' :
    372364    {
    373       if (!isset($params['tags']) or count($params['tags']) == 0)
    374       {
    375         fatal_error('make_section_in_url: require at least one tag');
    376       }
    377 
    378365      $section_string.= '/tags';
    379366
     
    404391    case 'search' :
    405392    {
    406       isset($params['search']) or fatal_error('make_section_in_url: require a search identifier');
    407393      $section_string.= '/search/'.$params['search'];
    408394      break;
     
    410396    case 'list' :
    411397    {
    412       isset($params['list']) or fatal_error('make_section_in_url: require a list of items');
    413398      $section_string.= '/list/'.implode(',', $params['list']);
    414399      break;
     
    471456          else
    472457          {
    473             $maybe_permalinks[] = 
     458            $maybe_permalinks[] =
    474459                $maybe_permalinks[count($maybe_permalinks)-1]
    475460                . '/' . $tokens[$current_token];
     
    679664    $params['download'] = null;
    680665  }
    681  
     666
    682667  return add_url_params(get_root_url().'action.php', $params);
    683668}
     
    813798
    814799  $vars = array_diff_key($vars, array_flip($rejects));
    815  
     800
    816801  return '?' . http_build_query($vars, '', $escape ? '&' : '&');
    817802}
  • trunk/include/functions_user.inc.php

    r27158 r27388  
    427427  WHERE category_id NOT IN ('.$userdata['forbidden_categories'].')
    428428    AND level>'.$userdata['level'];
    429       $forbidden_ids = array_from_query($query, 'id');
     429      $forbidden_ids = query2array($query,null, 'id');
    430430
    431431      if ( empty($forbidden_ids) )
     
    545545    ).'
    546546;';
    547   $authorizeds = array_from_query($query, 'image_id');
     547  $authorizeds = query2array($query,null, 'image_id');
    548548
    549549  $query = '
     
    552552  WHERE user_id = '.$user['id'].'
    553553;';
    554   $favorites = array_from_query($query, 'image_id');
     554  $favorites = query2array($query,null, 'image_id');
    555555
    556556  $to_deletes = array_diff($favorites, $authorizeds);
     
    585585  WHERE status = \'private\'
    586586;';
    587   $private_array = array_from_query($query, 'id');
     587  $private_array = query2array($query,null, 'id');
    588588
    589589  // retrieve category ids directly authorized to the user
     
    593593  WHERE user_id = '.$user_id.'
    594594;';
    595   $authorized_array = array_from_query($query, 'cat_id');
     595  $authorized_array = query2array($query,null, 'cat_id');
    596596
    597597  // retrieve category ids authorized to the groups the user belongs to
     
    605605    array_merge(
    606606      $authorized_array,
    607       array_from_query($query, 'cat_id')
     607      query2array($query,null, 'cat_id')
    608608      );
    609609
     
    623623  WHERE visible = \'false\'
    624624;';
    625     $result = pwg_query($query);
    626     while ($row = pwg_db_fetch_assoc($result))
    627     {
    628       $forbidden_array[] = $row['id'];
    629     }
     625    $forbidden_array = array_merge($forbidden_array, query2array($query, null, 'id') );
    630626    $forbidden_array = array_unique($forbidden_array);
    631627  }
     
    869865        $level = max( $conf['available_permission_levels'] );
    870866      }
    871       else if (($user_id == $conf['guest_id']) or
     867      elseif (($user_id == $conf['guest_id']) or
    872868               ($user_id == $conf['default_user_id']))
    873869      {
Note: See TracChangeset for help on using the changeset viewer.