Changeset 13074


Ignore:
Timestamp:
Feb 9, 2012, 10:11:34 PM (9 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
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/maintenance.php

    r13001 r13074  
    143143  case 'derivatives':
    144144  {
    145     clear_derivative_cache();
     145    clear_derivative_cache($_GET['type']);
    146146    break;
    147147  }
     
    159159
    160160$url_format = get_root_url().'admin.php?page=maintenance&action=%s&pwg_token='.get_pwg_token();
     161
     162$purge_urls[l10n('all')] = sprintf($url_format, 'derivatives').'&type=all';
     163foreach(ImageStdParams::get_defined_type_map() as $params)
     164{
     165  $purge_urls[ l10n($params->type) ] = sprintf($url_format, 'derivatives').'&type='.$params->type;
     166}
    161167
    162168$template->assign(
     
    174180    'U_MAINT_COMPILED_TEMPLATES' => sprintf($url_format, 'compiled-templates'),
    175181    'U_MAINT_DERIVATIVES' => sprintf($url_format, 'derivatives'),
     182    'purge_derivatives' => $purge_urls,
    176183    'U_HELP' => get_root_url().'admin/popuphelp.php?page=maintenance',
    177184    )
    178185  );
     186
    179187
    180188if ($conf['gallery_locked'])
  • trunk/admin/themes/default/template/maintenance.tpl

    r13001 r13074  
    3535        <li><a href="{$U_MAINT_SEARCH}"onclick="return confirm('{'Purge search history'|@translate|@escape:'javascript'}');">{'Purge search history'|@translate}</a></li>
    3636        <li><a href="{$U_MAINT_COMPILED_TEMPLATES}">{'Purge compiled templates'|@translate}</a></li>
    37         <li><a href="{$U_MAINT_DERIVATIVES}">{'Purge derivative image cache'|@translate}</a></li>
     37        <li>{'Purge derivative image cache'|@translate}:
     38        {foreach from=$purge_derivatives key=name item=url name=loop}{if !$smarty.foreach.loop.first}, {/if}<a href="{$url}">{$name}</a>{/foreach}
     39        </li>
    3840</ul>
  • trunk/include/functions_category.inc.php

    r12954 r13074  
    486486}
    487487
    488 /**
    489  * create a tree from a flat list of categories, no recursivity for high speed
    490  */
    491 function categories_flatlist_to_tree($categories)
    492 {
    493   $tree = array();
    494   $key_of_cat = array();
    495 
    496   foreach ($categories as $key => &$node)
    497   {
    498     $key_of_cat[$node['id']] = $key;
    499 
    500     if (!isset($node['id_uppercat']))
    501     {
    502       $tree[$key] = &$node;
    503     }
    504     else
    505     {
    506       if (!isset($categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories']))
    507       {
    508         $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'] = array();
    509       }
    510 
    511       $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'][$key] = &$node;
    512     }
    513   }
    514 
    515   return $tree;
    516 }
     488
    517489?>
  • 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  {
  • trunk/include/page_header.php

    r12922 r13074  
    6767
    6868// No referencing is required
    69 if ( !$conf['meta_ref'] ) 
     69if ( !$conf['meta_ref'] )
    7070{
    7171  $page['meta_robots']['noindex'] = 1;
     
    8282}
    8383if ( !isset($page['meta_robots']['noindex']) )
    84 { 
    85   $template->assign('meta_ref',1); 
     84{
     85  $template->assign('meta_ref',1);
    8686}
    8787
     
    9898      ));
    9999}
     100else
     101{// messages only if no redirection
     102  foreach (array('errors','infos') as $mode)
     103  {
     104    if (isset($_SESSION['page_'.$mode]))
     105    {
     106      $page[$mode] = array_merge($page[$mode], $_SESSION['page_'.$mode]);
     107      unset($_SESSION['page_'.$mode]);
     108    }
    100109
    101 
    102 // messages
    103 foreach (array('errors','infos') as $mode)
    104 {
    105   if (isset($_SESSION['page_'.$mode]))
    106   {
    107     $page[$mode] = array_merge($page[$mode], $_SESSION['page_'.$mode]);
    108     unset($_SESSION['page_'.$mode]);
    109   }
    110  
    111   if (count($page[$mode]) != 0)
    112   {
    113     $template->assign($mode, $page[$mode]);
     110    if (count($page[$mode]) != 0)
     111    {
     112      $template->assign($mode, $page[$mode]);
     113    }
    114114  }
    115115}
    116 
    117116trigger_action('loc_end_page_header');
    118117
  • trunk/include/ws_functions.inc.php

    r13003 r13074  
    521521}
    522522
     523
     524/**
     525 * create a tree from a flat list of categories, no recursivity for high speed
     526 */
     527function categories_flatlist_to_tree($categories)
     528{
     529  $tree = array();
     530  $key_of_cat = array();
     531
     532  foreach ($categories as $key => &$node)
     533  {
     534    $key_of_cat[$node['id']] = $key;
     535
     536    if (!isset($node['id_uppercat']))
     537    {
     538      $tree[$key] = &$node;
     539    }
     540    else
     541    {
     542      if (!isset($categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories']))
     543      {
     544        $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'] = array();
     545      }
     546
     547      $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'][$key] = &$node;
     548    }
     549  }
     550
     551  return $tree;
     552}
    523553
    524554/**
     
    16701700  {
    16711701    $do_update = false;
    1672    
     1702
    16731703    $infos = pwg_image_infos($file_path);
    1674    
     1704
    16751705    foreach (array('width', 'height', 'filesize') as $image_info)
    16761706    {
     
    17451775  // else we use "file".
    17461776  remove_chunks($params['original_sum'], 'thumb');
    1747  
     1777
    17481778  if (isset($params['high_sum']))
    17491779  {
  • trunk/picture.php

    r13048 r13074  
    171171  foreach($element_info['derivatives'] as $type => $derivative)
    172172  {
     173    if ($type==IMG_SQUARE || $type==IMG_THUMB)
     174      continue;
    173175    $url = $derivative->get_url();
    174176    if (isset($added[$url]))
     
    806808if (!empty($picture['current']['author']))
    807809{
    808   $infos['INFO_AUTHOR'] =
    809 // FIXME because of search engine partial rewrite, giving the author
    810 // name threw GET is not supported anymore. This feature should come
    811 // back later, with a better design
    812 //     '<a href="'.
    813 //       PHPWG_ROOT_PATH.'category.php?cat=search'.
    814 //       '&amp;search=author:'.$picture['current']['author']
    815 //       .'">'.$picture['current']['author'].'</a>';
    816     $picture['current']['author'];
     810  $infos['INFO_AUTHOR'] = $picture['current']['author'];
    817811}
    818812
  • trunk/themes/default/template/index.tpl

    r13068 r13074  
    132132</div>{* <!-- titrePage --> *}
    133133
     134{if isset($errors) or not empty($infos)}
    134135{include file='infos_errors.tpl'}
    135 
     136{/if}
    136137{if !empty($PLUGIN_INDEX_CONTENT_BEGIN)}{$PLUGIN_INDEX_CONTENT_BEGIN}{/if}
    137138
  • trunk/themes/default/template/password.tpl

    r12764 r13074  
    11{if isset($MENUBAR)}{$MENUBAR}{/if}
    2 <div id="content" class="content">
     2<div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}">
    33  <div class="titrePage">
    44    <ul class="categoryActions">
  • trunk/themes/default/template/picture.tpl

    r13021 r13074  
    22{include file='include/autosize.inc.tpl'}
    33*}
    4 
    54{if isset($MENUBAR)}
    65{$MENUBAR}
    76<div id="content" class="contentWithMenu">
    87{/if}
    9 
     8{if isset($errors) or not empty($infos)}
    109{include file='infos_errors.tpl'}
    11 
     10{/if}
    1211{if !empty($PLUGIN_PICTURE_BEFORE)}{$PLUGIN_PICTURE_BEFORE}{/if}
    1312
     
    275274
    276275{if isset($COMMENT_COUNT)}
    277 <a name="comments"></a>
    278276<div id="comments">
    279277        {if $COMMENT_COUNT > 0}
  • trunk/themes/default/template/register.tpl

    r12886 r13074  
    22<div id="registerPage">
    33
    4 <div id="content" class="content">
     4<div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}">
    55
    66<div class="titrePage">
Note: See TracChangeset for help on using the changeset viewer.