Changeset 1677


Ignore:
Timestamp:
Dec 21, 2006, 10:38:20 PM (17 years ago)
Author:
rub
Message:

Feature Issue ID 0000601: Filter all public pages with only recent elements

It's a finalized version.
Obsolete code of draft are removed.

You can filter categories and images with recent date period on your screen selection.
In the future, filter could be easy done on other type data (plugin?)

You can flat categories and sub-categories with a recent date period of your choice.

Next, perhaps, a panel to choice recent date for the 2 features.

On draft, there have problem with MySql 5, be careful!

Css problem not resolved:

  • Menu "Categories" is bad centered
  • Icon on dark too on the top
Location:
trunk
Files:
4 added
34 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/action.php

    r1643 r1677  
    8282}
    8383
     84// $filter['visible_categories'] and $filter['visible_images']
     85// are not used because it's not necessary (filter <> restriction)
    8486$query='
    8587SELECT id FROM '.CATEGORIES_TABLE.'
     
    8789  ON category_id=id
    8890  WHERE image_id='.$id.'
    89   AND category_id NOT IN ('.$user['forbidden_categories'].')
     91.'get_sql_condition_FandF(array('forbidden_categories' => 'category_id'), 'AND').'
    9092  LIMIT 1
    9193;';
  • trunk/comments.php

    r1647 r1677  
    217217$query = '
    218218SELECT id,name,uppercats,global_rank
    219   FROM '.CATEGORIES_TABLE;
    220 if ($user['forbidden_categories'] != '')
    221 {
    222   $query.= '
    223     WHERE id NOT IN ('.$user['forbidden_categories'].')';
    224 }
    225 $query.= '
     219  FROM '.CATEGORIES_TABLE.'
     220'.get_sql_condition_FandF
     221  (
     222    array
     223      (
     224        'forbidden_categories' => 'id',
     225        'visible_categories' => 'id'
     226      ),
     227    'WHERE'
     228  ).'
    226229;';
    227230display_select_cat_wrapper($query, array(@$_GET['cat']), $blockname, true);
     
    309312    AND '.$page['author_clause'].'
    310313    AND '.$page['keyword_clause'].'
    311     AND '.$page['status_clause'];
    312 if ($user['forbidden_categories'] != '')
    313 {
    314   $query.= '
    315     AND category_id NOT IN ('.$user['forbidden_categories'].')';
    316 }
    317 $query.= '
     314    AND '.$page['status_clause'].'
     315'.get_sql_condition_FandF
     316  (
     317    array
     318      (
     319        'forbidden_categories' => 'category_id',
     320        'visible_categories' => 'category_id',
     321        'visible_images' => 'ic.image_id'
     322      ),
     323    'AND'
     324  ).'
    318325;';
    319326list($counter) = mysql_fetch_row(pwg_query($query));
     
    355362    AND '.$page['author_clause'].'
    356363    AND '.$page['keyword_clause'].'
    357     AND '.$page['status_clause'];
    358 if ($user['forbidden_categories'] != '')
    359 {
    360   $query.= '
    361     AND category_id NOT IN ('.$user['forbidden_categories'].')';
    362 }
    363 $query.= '
     364    AND '.$page['status_clause'].'
     365'.get_sql_condition_FandF
     366  (
     367    array
     368      (
     369        'forbidden_categories' => 'category_id',
     370        'visible_categories' => 'category_id',
     371        'visible_images' => 'ic.image_id'
     372      ),
     373    'AND'
     374  ).'
    364375  GROUP BY comment_id
    365376  ORDER BY '.$page['sort_by'].' '.$page['sort_order'];
  • trunk/include/category_cats.inc.php

    r1651 r1677  
    4343  WHERE date_last > SUBDATE(
    4444    CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY
    45   );';
     45  )
     46'.get_sql_condition_FandF
     47  (
     48    array
     49      (
     50        'visible_categories' => 'id',
     51      ),
     52    'AND'
     53  ).'
     54;';
    4655}
    4756else
     
    5564  ON id = cat_id and user_id = '.$user['id'].'
    5665  WHERE id_uppercat '.
    57   (!isset($page['category']) ? 'is NULL' : '= '.$page['category']);
    58   if ($page['filter_local_mode'])
    59   {
    60     $query.= '
    61     AND max_date_last > SUBDATE(
    62       CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
    63   }
    64   $query.= '
     66  (!isset($page['category']) ? 'is NULL' : '= '.$page['category']).'
     67'.get_sql_condition_FandF
     68  (
     69    array
     70      (
     71        'visible_categories' => 'id',
     72      ),
     73    'AND'
     74  ).'
    6575  ORDER BY rank
    6676;';
     
    8696  FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic
    8797    ON ic.category_id = c.id';
    88     if ($page['filter_local_mode'] or $user['filter_global_mode'])
    89     {
    90       $query.= '
    91     INNER JOIN '.IMAGES_TABLE.' AS i on ic.image_id = i.id ';
    92     }
    9398    $query.= '
    9499  WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'
    95     AND c.id NOT IN ('.$user['forbidden_categories'].')';
    96     if ($page['filter_local_mode'] or $user['filter_global_mode'])
    97     {
    98       $query.= '
    99     AND i.date_available  > SUBDATE(
    100       CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
    101     }
    102     $query.= '
     100'.get_sql_condition_FandF
     101  (
     102    array
     103      (
     104        'forbidden_categories' => 'c.id',
     105        'visible_categories' => 'c.id',
     106        'visible_images' => 'image_id'
     107      ),
     108    'AND'
     109  ).'
    103110  ORDER BY RAND()
    104111  LIMIT 0,1
     
    117124  ON id = cat_id and user_id = '.$user['id'].'
    118125  WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'
    119     AND representative_picture_id IS NOT NULL';
    120     if ($page['filter_local_mode'] or $user['filter_global_mode'])
    121     {
    122       $query.= '
    123       AND max_date_last > SUBDATE(
    124         CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
    125     }
    126     $query.= '
     126    AND representative_picture_id IS NOT NULL
     127'.get_sql_condition_FandF
     128  (
     129    array
     130      (
     131        'visible_categories' => 'id',
     132      ),
     133    'AND'
     134  ).'
    127135  ORDER BY RAND()
    128136  LIMIT 0,1
     
    162170if (count($categories) > 0)
    163171{
     172  // Update filtered data
     173  update_cats_with_filtered_data($categories);
     174
    164175  if ($conf['subcatify'])
    165176  {
  • trunk/include/category_default.inc.php

    r1651 r1677  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    77// | branch        : BSF (Best So Far)
     
    4747SELECT *
    4848  FROM '.IMAGES_TABLE.'
    49   WHERE id IN ('.implode(',', $selection).')';
    50   if ($page['filter_local_mode'] or $user['filter_global_mode'])
    51   {
    52     $query.= '
    53     AND date_available  > SUBDATE(
    54       CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
    55   }
    56   $query.= ';';
     49  WHERE id IN ('.implode(',', $selection).')
     50;';
    5751  $result = pwg_query($query);
    5852  while ($row = mysql_fetch_assoc($result))
  • trunk/include/common.inc.php

    r1655 r1677  
    113113$lang = array();
    114114$header_msgs = array();
     115$header_notes = array();
    115116
    116117@include(PHPWG_ROOT_PATH .'include/mysql.inc.php');
     
    229230}
    230231
     232if (!defined('IN_ADMIN') or !IN_ADMIN)
     233{
     234  include(PHPWG_ROOT_PATH.'include/functions_filter.inc.php');
     235  include(PHPWG_ROOT_PATH.'include/filter.inc.php');
     236}
     237
     238if (isset($conf['header_notes']))
     239{
     240  $header_notes = array_merge($header_notes, $conf['header_notes']);
     241}
     242
    231243// default event handlers
    232244add_event_handler('render_comment_content', 'parse_comment_content');
  • trunk/include/config_default.inc.php

    r1660 r1677  
    175175$conf['links'] = array();
    176176
     177// List of notes to display on all header page
     178// example $conf['header_notes']  = array('Test', 'Hello');
     179$conf['header_notes']  = array();
     180
    177181// show_thumbnail_caption : on thumbnails page, show thumbnail captions ?
    178182$conf['show_thumbnail_caption'] = true;
     
    544548
    545549// +-----------------------------------------------------------------------+
    546 // | Set default for Web Service                                              |
     550// | Set default for Web Service                                           |
    547551// +-----------------------------------------------------------------------+
    548552
     
    562566  $conf['ws_durations'] = array(3650,1825,730,365,182,91,30,15,10,7,5,1,0);
    563567
     568// +-----------------------------------------------------------------------+
     569// | Filter                                                                |
     570// +-----------------------------------------------------------------------+
     571// Pages where filter is enabled
     572// Other pages cancel current filter
     573$conf['filter_pages'] = array
     574  (
     575    'about.php', 'action.php', 'admin.php', 'comments.php',
     576    'index.php', 'picture.php', 'popuphelp.php', 'profile.php',
     577    'qsearch.php', 'random.php', 'register.php', 'search.php',
     578    'search_rules.php', 'tags.php', 'upload.php'
     579  );
     580
    564581?>
  • trunk/include/functions_calendar.inc.php

    r1163 r1677  
    3030function initialize_calendar()
    3131{
    32   global $page, $conf, $user, $template;
     32  global $page, $conf, $user, $template, $filter;
    3333
    3434//------------------ initialize the condition on items to take into account ---
     
    5959    {
    6060      $inner_sql .= '
    61 WHERE category_id NOT IN ('.$user['forbidden_categories'].')';
     61    '.get_sql_condition_FandF
     62      (
     63        array
     64          (
     65            'forbidden_categories' => 'category_id',
     66            'visible_categories' => 'category_id',
     67            'visible_images' => 'image_id'
     68          ),
     69        'WHERE', true
     70      );
    6271    }
    6372  }
  • trunk/include/functions_category.inc.php

    r1651 r1677  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    77// | branch        : BSF (Best So Far)
     
    4545  global $user;
    4646
     47  // $filter['visible_categories'] and $filter['visible_images']
     48  // are not used because it's not necessary (filter <> restriction)
    4749  if (in_array($category_id, explode(',', $user['forbidden_categories'])))
    4850  {
     
    5355function get_categories_menu()
    5456{
    55   global $page, $user;
     57  global $page, $user, $filter;
    5658
    5759  $query = '
     
    6668  // $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
    6769  $query.= '
    68   FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
     70FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
    6971  ON id = cat_id and user_id = '.$user['id'];
    70   if ($page['filter_local_mode'])
     72
     73  // Always expand when filter is activated
     74  if (!$user['expand'] and !$filter['enabled'])
    7175  {
    7276    $query.= '
    73 where max_date_last > SUBDATE(
    74   CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
     77WHERE
     78(id_uppercat is NULL';
     79    if (isset($page['category']))
     80    {
     81      $query.= ' OR id_uppercat IN ('.$page['uppercats'].')';
     82    }
     83    $query.= ')';
    7584  }
    7685  else
    7786  {
    78     // Always expand when filter_local_mode is activated
    79     if (!$user['expand'] and !$user['filter_global_mode'])
    80     {
    81       $query.= '
    82       WHERE (id_uppercat is NULL';
    83       if (isset($page['category']))
    84       {
    85         $query.= ' OR id_uppercat IN ('.$page['uppercats'].')';
    86       }
    87       $query.= ')';
    88     }
    89   }
     87    $query.= '
     88  '.get_sql_condition_FandF
     89    (
     90      array
     91        (
     92          'visible_categories' => 'id',
     93        ),
     94      'WHERE'
     95    );
     96  }
     97
    9098  $query.= '
    9199;';
     
    98106  }
    99107  usort($cats, 'global_rank_compare');
     108
     109  // Update filtered data
     110  update_cats_with_filtered_data($cats);
    100111
    101112  return get_html_menu_category($cats);
  • trunk/include/functions_html.inc.php

    r1652 r1677  
    289289      $output.= '<a class=""';
    290290      $output.= ' href="'
    291             .make_index_url(
     291            .duplicate_index_url(
    292292                array(
    293293                  'category'=>$id,
    294294                  'cat_name'=>$name
    295                   )
     295                  ),
     296                array('start')
    296297              )
    297298            .'">';
  • trunk/include/functions_notification.inc.php

    r1639 r1677  
    3131
    3232/*
     33 * get standard sql where in order to
     34 * restict an filter caregories and images
     35 *
     36 * IMAGE_CATEGORY_TABLE muste named ic in the query
     37 *
     38 * @param none
     39 *
     40 * @return string sql where
     41 */
     42function get_std_sql_where_restrict_filter($prefix_condition, $force_one_condition = false)
     43{
     44  return get_sql_condition_FandF
     45          (
     46            array
     47              (
     48                'forbidden_categories' => 'ic.category_id',
     49                'visible_categories' => 'ic.category_id',
     50                'visible_images' => 'ic.image_id'
     51              ),
     52            $prefix_condition,
     53            $force_one_condition
     54          );
     55}
     56
     57/*
    3358 * Execute custom notification query
    3459 *
     
    5479    AND c.validation_date > \''.$start.'\'
    5580    AND c.validation_date <= \''.$end.'\'
    56     AND category_id NOT IN ('.$user['forbidden_categories'].')
     81      '.get_std_sql_where_restrict_filter('AND').'
    5782;';
    5883      break;
     
    6792    case 'new_elements':
    6893      $query = '
    69   FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id
     94  FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = id
    7095  WHERE date_available > \''.$start.'\'
    7196    AND date_available <= \''.$end.'\'
    72     AND category_id NOT IN ('.$user['forbidden_categories'].')
     97      '.get_std_sql_where_restrict_filter('AND').'
    7398;';
    7499      break;
    75100    case 'updated_categories':
    76101      $query = '
    77   FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id
     102  FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = id
    78103  WHERE date_available > \''.$start.'\'
    79104    AND date_available <= \''.$end.'\'
    80     AND category_id NOT IN ('.$user['forbidden_categories'].')
     105      '.get_std_sql_where_restrict_filter('AND').'
    81106;';
    82107      break;
     
    424449  global $conf, $user;
    425450
    426   $where_sql = 'WHERE category_id NOT IN ('.$user['forbidden_categories'].')';
     451  $where_sql = get_std_sql_where_restrict_filter('WHERE', true);
    427452
    428453  $query = '
     
    430455      COUNT(DISTINCT id) nb_elements,
    431456      COUNT(DISTINCT category_id) nb_cats
    432   FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id
     457  FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id
    433458  '.$where_sql.'
    434459  GROUP BY date_available
     
    449474      $query = '
    450475SELECT DISTINCT id, path, name, tn_ext
    451   FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id
     476  FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id
    452477  '.$where_sql.'
    453478    AND date_available="'.$dates[$i]['date_available'].'"
     
    467492      $query = '
    468493SELECT DISTINCT c.uppercats, COUNT(DISTINCT i.id) img_count
    469   FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON i.id=image_id
     494  FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id=image_id
    470495    INNER JOIN '.CATEGORIES_TABLE.' c ON c.id=category_id
    471496  '.$where_sql.'
  • trunk/include/functions_search.inc.php

    r1619 r1677  
    336336function get_quick_search_results($q)
    337337{
    338   global $user, $page;
     338  global $user, $page, $filter;
    339339  $search_results = array();
    340340
     
    385385    INNER JOIN
    386386  '.CATEGORIES_TABLE.' c on c.id=ic.category_id
    387 WHERE category_id NOT IN ('.$user['forbidden_categories'].')
     387'.get_sql_condition_FandF
     388  (
     389    array
     390      (
     391        'forbidden_categories' => 'category_id',
     392        'visible_categories' => 'category_id',
     393        'visible_images' => 'ic.image_id'
     394      ),
     395    'WHERE'
     396  ).'
    388397GROUP BY i.id';
    389398
     
    428437    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
    429438  WHERE id IN ('.implode(',', array_keys($by_tag_weights) ).')
    430     AND category_id NOT IN ('.$user['forbidden_categories'].')';
    431 
     439'.get_sql_condition_FandF
     440  (
     441    array
     442      (
     443        'forbidden_categories' => 'category_id',
     444        'visible_categories' => 'category_id',
     445        'visible_images' => 'ic.image_id'
     446      ),
     447    'AND'
     448  );
    432449    $allowed_image_ids = array_from_query( $query, 'id');
    433450    $by_tag_weights = array_intersect_key($by_tag_weights, array_flip($allowed_image_ids));
  • trunk/include/functions_tag.inc.php

    r1537 r1677  
    3838 * @return array
    3939 */
    40 function get_available_tags($forbidden_categories = null)
     40function get_available_tags()
    4141{
    4242  // we can find top fatter tags among reachable images
     
    4646    INNER JOIN '.TAGS_TABLE.' ON tag_id = id';
    4747
    48   if (!is_null($forbidden_categories))
     48  $where_tag_img =
     49    get_sql_condition_FandF
     50    (
     51      array
     52        (
     53          'forbidden_categories' => 'category_id',
     54          'visible_categories' => 'category_id',
     55          'visible_images' => 'image_id'
     56        ),
     57      'WHERE'
     58    );
     59
     60  if (!is_null($where_tag_img))
    4961  {
    5062    // first we need all reachable image ids
     
    5264SELECT DISTINCT image_id
    5365  FROM '.IMAGE_CATEGORY_TABLE.'
    54   WHERE category_id NOT IN ('.implode(',', $forbidden_categories).')
     66  '.$where_tag_img.'
    5567;';
    5668    $image_ids = array_from_query($images_query, 'image_id');
  • trunk/include/functions_url.inc.php

    r1676 r1677  
    265265  }
    266266
     267  if (isset($params['flat_recent_cat']) and $params['flat_recent_cat'] > 0)
     268  {
     269    $url.= '/flat_recent_cat-'.$params['flat_recent_cat'];
     270  }
     271
    267272  if (isset($params['start']) and $params['start'] > 0)
    268273  {
  • trunk/include/functions_user.inc.php

    r1651 r1677  
    144144}
    145145
    146 function build_user( $user_id, $use_cache, $filter_global_mode = false )
     146function build_user( $user_id, $use_cache )
    147147{
    148148  global $conf;
    149 
    150149  $user['id'] = $user_id;
    151   $user = array_merge( $user, getuserdata($user_id, $use_cache, $filter_global_mode) );
     150  $user = array_merge( $user, getuserdata($user_id, $use_cache) );
    152151  if ( $user['id'] == $conf['guest_id'])
    153152  {
     
    168167    $user['is_the_guest']=false;
    169168  }
    170 
    171169  // calculation of the number of picture to display per page
    172170  $user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page'];
     
    199197 * @param array
    200198 */
    201 function getuserdata($user_id, $use_cache, $filter_global_mode = false )
     199function getuserdata($user_id, $use_cache)
    202200{
    203201  global $conf;
     
    268266  if ($use_cache)
    269267  {
    270     $userdata['filter_global_mode'] = $filter_global_mode;
    271 
    272268    if (!isset($userdata['need_update'])
    273269        or !is_bool($userdata['need_update'])
    274         or $userdata['need_update'] == true
    275         or $filter_global_mode  // not optimize condition RubTag
    276        )
     270        or $userdata['need_update'] == true)
    277271    {
    278272      $userdata['forbidden_categories'] =
    279273        calculate_permissions($userdata['id'], $userdata['status']);
    280274
    281       update_user_cache_categories($userdata);
     275      update_user_cache_categories($userdata['id'], $userdata['forbidden_categories']);
    282276
    283277      // Set need update are done
    284       $userdata['need_update'] = $userdata['filter_global_mode']; // for draft always update RubTag
     278      $userdata['need_update'] = false;
     279
     280      // Indicate update done
     281      $userdata['need_update_done'] = true;
    285282
    286283      $query = '
     
    307304      pwg_query($query);
    308305    }
    309 
    310     {
     306    else
     307    {
     308      // Indicate update not done
     309      $userdata['need_update_done'] = false;
    311310    }
    312311  }
     
    329328  }
    330329
     330  // $filter['visible_categories'] and $filter['visible_images']
     331  // must be not used because filter <> restriction
    331332  // retrieving images allowed : belonging to at least one authorized
    332333  // category
     
    336337    ON f.image_id = ic.image_id
    337338  WHERE f.user_id = '.$user['id'].'
    338     AND ic.category_id NOT IN ('.$user['forbidden_categories'].')
     339'.get_sql_condition_FandF
     340  (
     341    array
     342      (
     343        'forbidden_categories' => 'ic.category_id',
     344      ),
     345    'AND'
     346  ).'
    339347;';
    340348  $result = pwg_query($query);
     
    455463
    456464/**
    457  * compute data of categories branches
     465 * compute data of categories branches (one branch only)
    458466 */
    459467function compute_branch_cat_data(&$cats, &$list_cat_id, &$level, &$ref_level)
     
    497505
    498506/**
     507 * compute data of categories branches
     508 */
     509function compute_categories_data(&$cats)
     510{
     511  $ref_level = 0;
     512  $level = 0;
     513  $list_cat_id = array();
     514
     515  foreach ($cats as $id => $category)
     516  {
     517    // Compute
     518    $level = substr_count($category['global_rank'], '.') + 1;
     519    if ($level > $ref_level)
     520    {
     521      array_push($list_cat_id, $id);
     522    }
     523    else
     524    {
     525      compute_branch_cat_data($cats, $list_cat_id, $level, $ref_level);
     526      array_push($list_cat_id, $id);
     527    }
     528    $ref_level = $level;
     529  }
     530
     531  $level = 1;
     532  compute_branch_cat_data($cats, $list_cat_id, $level, $ref_level);
     533}
     534
     535/**
     536 * get computed array of categories
     537 *
     538 * @param int user_id
     539 * @param list user_forbidden_categories
     540 * @param bool filter_enabled
     541 * @param int recent_period
     542 * @return array
     543 */
     544function get_computed_categories($user_id, $user_forbidden_categories, $filter_enabled, $recent_period = 0)
     545{
     546  $query = '
     547SELECT
     548  c.id cat_id,
     549  date_last max_date_last,
     550  nb_images count_images,
     551  global_rank';
     552
     553  if (!$filter_enabled)
     554  {
     555    $query.= '
     556FROM '.CATEGORIES_TABLE.' as c';
     557  }
     558  else
     559  {
     560    // Count by date_available to avoid count null
     561    $query.= ',
     562  count(date_available) filtered_count_images,
     563  max(date_available) max_date_available
     564FROM '.CATEGORIES_TABLE.' as c
     565    LEFT JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON ic.category_id = c.id
     566    LEFT JOIN '.IMAGES_TABLE.' AS i
     567      ON ic.image_id = i.id AND
     568          i.date_available > SUBDATE(CURRENT_DATE,INTERVAL '.$recent_period.' DAY)';
     569  }
     570
     571  if ($user_forbidden_categories != '')
     572  {
     573    $query.= '
     574WHERE
     575  c.id NOT IN ('.$user_forbidden_categories.')';
     576  }
     577
     578  if ($filter_enabled)
     579  {
     580    $query.= '
     581GROUP BY
     582  c.id';
     583  }
     584  $query.= ';';
     585
     586  $result = pwg_query($query);
     587
     588  $cats = array();
     589  while ($row = mysql_fetch_assoc($result))
     590  {
     591    $row['user_id'] = $user_id;
     592    $row['count_categories'] = 0;
     593    if ($filter_enabled)
     594    {
     595      $row['nb_images'] = $row['filtered_count_images'];
     596      $row['count_images'] = $row['filtered_count_images'];
     597      $row['max_date_last'] = $row['max_date_available'];
     598    }
     599    $cats += array($row['cat_id'] => $row);
     600  }
     601  usort($cats, 'global_rank_compare');
     602
     603  compute_categories_data($cats);
     604
     605  if ($filter_enabled)
     606  {
     607    $cat_tmp = $cats;
     608    $cats = array();
     609 
     610    foreach ($cat_tmp as $category)
     611    {
     612      if (!empty($category['max_date_last']))
     613      {
     614        // Re-init counters
     615        $category['count_categories'] = 0;
     616        $category['nb_images'] = $category['filtered_count_images'];
     617        $category['count_images'] = $category['filtered_count_images'];
     618        // Keep category
     619        $cats[$category['cat_id']] = $category;
     620       
     621      }
     622    }
     623    // Compute a second time
     624    compute_categories_data($cats);
     625  }
     626
     627  return $cats;
     628}
     629
     630/**
    499631 * update data of user_cache_categories
    500632 *
    501  * @param array userdata
     633 * @param int user_id
     634 * @param list user_forbidden_categories
     635 * @param bool filter_enabled
    502636 * @return null
    503637 */
    504 function update_user_cache_categories(&$userdata)
     638function update_user_cache_categories($user_id, $user_forbidden_categories)
    505639{
    506640  // delete user cache
    507641  $query = '
    508642DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.'
    509   WHERE user_id = '.$userdata['id'].'
     643  WHERE user_id = '.$user_id.'
    510644;';
    511645  pwg_query($query);
    512646
    513   /*$query = '
    514 SELECT id cat_id, date_last max_date_last, nb_images count_images, global_rank
    515   FROM '.CATEGORIES_TABLE;
    516   if ($userdata['forbidden_categories'] != '')
    517   {
    518     $query.= '
    519     WHERE id NOT IN ('.$userdata['forbidden_categories'].')';
    520   }
    521   $query.= ';';*/
    522 
    523 
    524   $query = '
    525 SELECT c.id cat_id, date_last max_date_last, nb_images count_images, global_rank';
    526 
    527   if (!$userdata['filter_global_mode'])
    528   {
    529     $query.= '
    530   FROM '.CATEGORIES_TABLE.' as C';
    531   }
    532   else
    533   {
    534     // Count by date_available to avoid count null
    535     $query.= ', count(date_available) filtered_count_images, max(date_available) max_date_available
    536   FROM '.CATEGORIES_TABLE.' as C
    537     LEFT JOIN '.IMAGE_CATEGORY_TABLE.' AS ic
    538     ON ic.category_id = c.id LEFT JOIN '.IMAGES_TABLE.' AS i
    539     ON ic.image_id = i.id AND i.date_available  > SUBDATE(
    540       CURRENT_DATE,INTERVAL '.$userdata['recent_period'].' DAY)';
    541   }
    542 
    543   if ($userdata['forbidden_categories'] != '')
    544   {
    545     $query.= '
    546     WHERE C.id NOT IN ('.$userdata['forbidden_categories'].')';
    547   }
    548 
    549   if ($userdata['filter_global_mode'])
    550   {
    551     $query.= '
    552   GROUP BY c.id';
    553   }
    554   $query.= ';';
    555 
    556   $result = pwg_query($query);
    557 
    558   $cats = array();
    559   while ($row = mysql_fetch_assoc($result))
    560   {
    561     $row['user_id'] = $userdata['id'];
    562     $row['count_categories'] = 0;
    563     if ($userdata['filter_global_mode'])
    564     {
    565       $row['count_images'] = $row['filtered_count_images'];
    566       $row['max_date_last'] = $row['max_date_available'];
    567     }
    568     $cats += array($row['cat_id'] => $row);
    569   }
    570   usort($cats, 'global_rank_compare');
    571 
    572   $ref_level = 0;
    573   $level = 0;
    574   $list_cat_id = array();
    575 
    576   foreach ($cats as $id => $category)
    577   {
    578     // Compute
    579     $level = substr_count($category['global_rank'], '.') + 1;
    580     if ($level > $ref_level)
    581     {
    582       array_push($list_cat_id, $id);
    583     }
    584     else
    585     {
    586       compute_branch_cat_data($cats, $list_cat_id, $level, $ref_level);
    587       array_push($list_cat_id, $id);
    588     }
    589     $ref_level = $level;
    590   }
    591 
    592   $level = 1;
    593   compute_branch_cat_data($cats, $list_cat_id, $level, $ref_level);
    594 
    595   if ($userdata['filter_global_mode'])
    596   {
    597     $forbidden_cats = array();
    598     $forbidden_cats = explode(',', $userdata['forbidden_categories']);
    599     $cat_tmp = $cats;
    600     $cats = array();
    601  
    602     foreach ($cat_tmp as $cat_id => $category)
    603     {
    604       if (empty($category['max_date_last']))
    605       {
    606         array_push($forbidden_cats, $category['cat_id']);
    607       }
    608       else
    609       {
    610         array_push($cats, $category);
    611       }
    612     }
    613     $userdata['forbidden_categories'] = implode(',', array_unique($forbidden_cats));
    614   }
     647  $cats = get_computed_categories($user_id, $user_forbidden_categories, false);
    615648
    616649  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     
    10151048}
    10161049
     1050/*
     1051 * Compute sql where condition with restrict and filter data
     1052 *
     1053 * FandF: Forbidden and Filters
     1054 *
     1055 * @param $condition_fields array:
     1056 *            keys are condition to aply and
     1057 *            values are sql field to use
     1058 *            array('forbidden_categories' => 'ic.category_id')
     1059 *        $prefix_condition string:
     1060 *            this value are concatenated if sql is not empty
     1061 *        $force_one_condition:
     1062 *            if there are not condition , use this condition "1 = 1"
     1063 *
     1064 * @return string sql where/conditions
     1065 */
     1066function get_sql_condition_FandF($condition_fields, $prefix_condition = null, $force_one_condition = false)
     1067{
     1068  global $user, $filter;
     1069
     1070  $sql_list = array();
     1071
     1072  foreach ($condition_fields as $condition => $field_name)
     1073  {
     1074    switch($condition)
     1075    {
     1076      case 'forbidden_categories':
     1077        if (!empty($user['forbidden_categories']))
     1078        {
     1079          $sql_list[] = $field_name.' NOT IN ('.$user['forbidden_categories'].')';
     1080        }
     1081        break;
     1082
     1083      case 'visible_categories':
     1084        if (!empty($filter['visible_categories']))
     1085        {
     1086          $sql_list[] = $field_name.' IN ('.$filter['visible_categories'].')';
     1087        }
     1088        break;
     1089
     1090      case 'visible_images':
     1091        if (!empty($filter['visible_images']))
     1092        {
     1093          $sql_list[] = $field_name.' IN ('.$filter['visible_images'].')';
     1094        }
     1095        break;
     1096
     1097      default:
     1098        die('Unknow condition');
     1099        break;
     1100
     1101    }
     1102  }
     1103
     1104  if (count($sql_list) > 0)
     1105  {
     1106    $sql = '('.implode(' AND ', $sql_list).')';
     1107  }
     1108  else
     1109  {
     1110    if ($force_one_condition)
     1111    {
     1112      $sql = '1 = 1';
     1113    }
     1114    else
     1115    {
     1116      $sql = '';
     1117    }
     1118  }
     1119
     1120  if (isset($prefix_condition) and !empty($sql))
     1121  {
     1122    $sql = $prefix_condition.' '.$sql;
     1123  }
     1124
     1125  return $sql;
     1126}
     1127
    10171128?>
  • trunk/include/menubar.inc.php

    r1652 r1677  
    6464    );
    6565}
     66
     67//------------------------------------------------------------------------ filter
     68if ($filter['enabled'])
     69{
     70  $template->assign_block_vars(
     71    'stop_filter',
     72    array(
     73      'URL' => add_url_params(make_index_url(array()), array('filter' => 'stop'))
     74      )
     75    );
     76}
     77else
     78{
     79  $template->assign_block_vars(
     80    'start_filter',
     81    array(
     82      'URL' => add_url_params(make_index_url(array()), array('filter' => 'start'))
     83      )
     84    );
     85}
     86
     87
    6688//------------------------------------------------------------------------ tags
    6789if ('tags' == $page['section'])
  • trunk/include/page_header.php

    r1627 r1677  
    6161  $template->assign_block_vars( 'header_meta', $header_infos);
    6262}
     63
     64// Header notes
     65if (count($header_notes) > 0)
     66{
     67  $template->assign_block_vars('header_notes', array());
     68  foreach ($header_notes as $header_note)
     69  {
     70    $template->assign_block_vars('header_notes.header_note',
     71                                 array('HEADER_NOTE' => $header_note));
     72  }
     73}
     74
    6375// refresh
    6476if ( isset( $refresh ) and intval($refresh) >= 0
  • trunk/include/section_init.inc.php

    r1623 r1677  
    268268  }
    269269
     270  if (preg_match('/^flat_recent_cat-(\d+)/', $tokens[$i], $matches))
     271  {
     272    // indicate a special list of images
     273    $page['flat_recent_cat'] = $matches[1];
     274  }
     275
    270276  if (preg_match('/^(posted|created)/', $tokens[$i] ))
    271277  {
     
    326332      $page,
    327333      array(
    328         'comment'          => $result['comment'],
    329         'cat_dir'          => $result['dir'],
    330         'cat_name'         => $result['name'],
    331         'cat_site_id'      => $result['site_id'],
    332         'cat_uploadable'   => $result['uploadable'],
    333         'cat_commentable'  => $result['commentable'],
    334         'cat_id_uppercat'  => $result['id_uppercat'],
    335         'uppercats'        => $result['uppercats'],
    336 
    337         'title' => get_cat_display_name($result['name'], '', false),
    338         )
    339       );
    340 
    341     if (!isset($page['chronology_field']))
    342     {
    343       if ( !empty($result['image_order']) and !isset($page['super_order_by']) )
     334        'comment'            => $result['comment'],
     335        'cat_dir'            => $result['dir'],
     336        'cat_name'           => $result['name'],
     337        'cat_site_id'        => $result['site_id'],
     338        'cat_uploadable'     => $result['uploadable'],
     339        'cat_commentable'    => $result['commentable'],
     340        'cat_id_uppercat'    => $result['id_uppercat'],
     341        'uppercats'          => $result['uppercats'],
     342        'title'             =>
     343          get_cat_display_name($result['name'], '', false),
     344        'thumbnails_include' =>
     345          (($result['nb_images'] > 0) or (isset($page['flat_recent_cat'])))
     346          ? 'include/category_default.inc.php'
     347          : 'include/category_cats.inc.php'
     348        )
     349      );
     350  }
     351  else
     352  {
     353    $page['title'] = $lang['no_category'];
     354    $page['thumbnails_include'] =
     355      (isset($page['flat_recent_cat']))
     356          ? 'include/category_default.inc.php'
     357          : 'include/category_cats.inc.php';
     358  }
     359
     360  if (isset($page['flat_recent_cat']))
     361  {
     362    $page['title'] = $lang['recent_pics_cat'].' : '.$page['title'] ;
     363  }
     364
     365  if
     366    (
     367      (!isset($page['chronology_field'])) and
     368      (
     369        (isset($page['category'])) or
     370        (isset($page['flat_recent_cat']))
     371      )
     372    )
     373  {
     374    if ( !empty($result['image_order']) and !isset($page['super_order_by']) )
     375    {
     376      $conf[ 'order_by' ] = ' ORDER BY '.$result['image_order'];
     377    }
     378
     379    if (isset($page['flat_recent_cat']))
     380    {
     381      // flat recent categories mode
     382        $query = '
     383SELECT
     384  DISTINCT(ic.image_id)
     385FROM '.IMAGES_TABLE.' AS i
     386       INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id = ic.image_id
     387       INNER JOIN '.CATEGORIES_TABLE.' AS c ON ic.category_id = c.id
     388WHERE
     389  date_available  > SUBDATE(
     390      CURRENT_DATE,INTERVAL '.$page['flat_recent_cat'].' DAY)'.
     391  (isset($page['category']) ? '
     392  AND uppercats REGEXP \'(^|,)'.$page['category'].'(,|$)\'' : '' ).'
     393'.get_sql_condition_FandF
     394  (
     395    array
     396      (
     397        'forbidden_categories' => 'category_id',
     398        'visible_categories' => 'category_id',
     399        'visible_images' => 'image_id'
     400      ),
     401    'AND'
     402  ).'
     403;';
     404
     405      $where_sql = array_from_query($query, 'image_id');
     406      if (!empty($where_sql))
    344407      {
    345         $conf[ 'order_by' ] = ' ORDER BY '.$result['image_order'];
     408        $where_sql = 'image_id in ('.implode(',', $where_sql).')';
    346409      }
    347 
     410    }
     411    else
     412    {
     413      // Normal mode
     414      $where_sql = 'category_id = '.$page['category'];
     415    }
     416
     417    if (!empty($where_sql))
     418    {
     419      // Main query
    348420      $query = '
    349421SELECT image_id
    350422  FROM '.IMAGE_CATEGORY_TABLE.'
    351423    INNER JOIN '.IMAGES_TABLE.' ON id = image_id
    352   WHERE category_id = '.$page['category'].'
     424  WHERE
     425    '.$where_sql.'
     426'.get_sql_condition_FandF
     427  (
     428    array
     429      (
     430        'forbidden_categories' => 'category_id',
     431        'visible_categories' => 'category_id',
     432        'visible_images' => 'image_id'
     433      ),
     434    'AND'
     435  ).'
    353436  '.$conf['order_by'].'
    354437;';
     438
    355439      $page['items'] = array_from_query($query, 'image_id');
    356 
    357       $page['thumbnails_include'] =
    358         $result['nb_images'] > 0
    359         ? 'include/category_default.inc.php'
    360         : 'include/category_cats.inc.php';
    361     } //otherwise the calendar will requery all subitems
    362   }
    363   else
    364   {
    365     $page['title'] = $lang['no_category'];
    366     $page['thumbnails_include'] = 'include/category_cats.inc.php';
    367   }
     440    }
     441    else
     442    {
     443      $page['items'] = array();
     444    }
     445  } //otherwise the calendar will requery all subitems
    368446}
    369447// special sections
    370448else
    371449{
    372   if (!empty($user['forbidden_categories']))
    373   {
    374     $forbidden =
    375       ' category_id NOT IN ('.$user['forbidden_categories'].')';
    376   }
    377   else
    378   {
    379     $forbidden = ' 1 = 1';
    380   }
     450  $forbidden =
     451    get_sql_condition_FandF
     452    (
     453      array
     454        (
     455          'forbidden_categories' => 'category_id',
     456          'visible_categories' => 'category_id',
     457          'visible_images' => 'image_id'
     458        ),
     459      'AND'
     460    );
     461
    381462// +-----------------------------------------------------------------------+
    382463// |                            tags section                               |
     
    401482  FROM '.IMAGE_CATEGORY_TABLE.' INNER JOIN '.IMAGES_TABLE.' ON image_id=id
    402483  WHERE image_id IN ('.implode(',', $items).')
    403     AND '.$forbidden.
     484    '.$forbidden.
    404485    $conf['order_by'].'
    405486;';
     
    435516    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
    436517  WHERE id IN ('.implode(',', $search_result['items']).')
    437     AND '.$forbidden.'
     518    '.$forbidden.'
    438519  '.$conf['order_by'].'
    439520;';
     
    465546    INNER JOIN '.IMAGES_TABLE.' ON image_id = id
    466547  WHERE user_id = '.$user['id'].'
     548'.get_sql_condition_FandF
     549  (
     550    array
     551      (
     552        'visible_images' => 'image_id'
     553      ),
     554    'AND'
     555  ).'
    467556  '.$conf['order_by'].'
    468557;';
     
    488577  WHERE date_available > \''.
    489578      date('Y-m-d', time() - 60*60*24*$user['recent_period']).'\'
    490     AND '.$forbidden.'
     579    '.$forbidden.'
    491580  '.$conf['order_by'].'
    492581;';
     
    527616    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
    528617  WHERE hit > 0
    529     AND '.$forbidden.'
     618    '.$forbidden.'
    530619    '.$conf['order_by'].'
    531620  LIMIT 0, '.$conf['top_number'].'
     
    555644    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
    556645  WHERE average_rate IS NOT NULL
    557     AND '.$forbidden.'
     646    '.$forbidden.'
    558647    '.$conf['order_by'].'
    559648  LIMIT 0, '.$conf['top_number'].'
     
    579668    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
    580669  WHERE image_id IN ('.implode(',', $page['list']).')
    581     AND '.$forbidden.'
     670    '.$forbidden.'
    582671  '.$conf['order_by'].'
    583672;';
  • trunk/include/user.inc.php

    r1651 r1677  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    77// | branch        : BSF (Best So Far)
     
    7171}
    7272
    73 if (isset($_GET['filter_global_mode']))
    74 {
    75   $user['filter_global_mode'] = ($_GET['filter_global_mode'] == 'start');
    76   pwg_set_session_var('filter_global_mode', $user['filter_global_mode']);
    77 }
    78 else
    79 {
    80   $user['filter_global_mode'] = pwg_get_session_var('filter_global_mode', false);
    81 }
    82 
    8373$user = build_user( $user['id'],
    84           ( defined('IN_ADMIN') and IN_ADMIN ) ? false : true, // use cache ?
    85           $user['filter_global_mode'] // filter_global_mode ?
     74          ( defined('IN_ADMIN') and IN_ADMIN ) ? false : true // use cache ?
    8675         );
    8776
  • trunk/index.php

    r1655 r1677  
    107107}
    108108
    109 if (isset($_GET['filter_local_mode']))
    110 {
    111   $page['filter_local_mode'] = ($_GET['filter_local_mode'] == 'start');
    112 }
    113 else
    114 {
    115   $page['filter_local_mode'] = pwg_get_session_var('filter_local_mode', false);
    116 }
    117 
    118 $page['filter_local_mode'] = (($page['filter_local_mode']) and
    119                               ($page['section'] == 'categories') and
    120                               (!isset($page['chronology_field'])));
    121 pwg_set_session_var('filter_local_mode', $page['filter_local_mode']);
    122 
    123 if ($page['filter_local_mode'])
    124 {
    125   $template->assign_block_vars(
    126     'stop_filter_local_mode',
    127     array(
    128       'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_local_mode' => 'stop'))
    129       )
    130     );
    131 }
    132 else
    133 {
    134   $template->assign_block_vars(
    135     'start_filter_local_mode',
    136     array(
    137       'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_local_mode' => 'start'))
    138       )
    139     );
    140 }
    141 
    142 if (isset($_GET['filter_global_mode']))
    143 {
    144   $user['filter_global_mode'] = ($_GET['filter_global_mode'] == 'start');
    145   pwg_set_session_var('filter_global_mode', $user['filter_global_mode']);
    146 }
    147 else
    148 {
    149   $user['filter_global_mode'] = pwg_get_session_var('filter_global_mode', false);
    150 }
    151 
    152 if ($user['filter_global_mode'])
    153 {
    154   $template->assign_block_vars(
    155     'stop_filter_global_mode',
    156     array(
    157       'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_global_mode' => 'stop'))
    158       )
    159     );
    160 }
    161 else
    162 {
    163   $template->assign_block_vars(
    164     'start_filter_global_mode',
    165     array(
    166       'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_global_mode' => 'start'))
     109if (isset($page['flat_recent_cat']) or isset($page['chronology_field']))
     110{
     111  $template->assign_block_vars(
     112    'mode_normal',
     113    array(
     114      'URL' => duplicate_index_url( array(), array('chronology_field', 'start', 'flat_recent_cat') )
     115      )
     116    );
     117}
     118
     119if (!isset($page['flat_recent_cat']))
     120{
     121  $template->assign_block_vars(
     122    'flat_recent_cat',
     123    array(
     124      'URL' => duplicate_index_url(array('flat_recent_cat' => $user['recent_period']), array('start', 'chronology_field'))
    167125      )
    168126    );
     
    180138    'mode_created',
    181139    array(
    182       'URL' => duplicate_index_url( $chronology_params, array('start') )
     140      'URL' => duplicate_index_url( $chronology_params, array('start', 'flat_recent_cat') )
    183141      )
    184142    );
     
    188146    'mode_posted',
    189147    array(
    190       'URL' => duplicate_index_url( $chronology_params, array('start') )
     148      'URL' => duplicate_index_url( $chronology_params, array('start', 'flat_recent_cat') )
    191149      )
    192150    );
     
    194152else
    195153{
    196   $template->assign_block_vars(
    197     'mode_normal',
    198     array(
    199       'URL' => duplicate_index_url( array(), array('chronology_field','start') )
    200       )
    201     );
    202 
    203154  if ($page['chronology_field'] == 'created')
    204155  {
     
    211162  $url = duplicate_index_url(
    212163            array('chronology_field'=>$chronology_field ),
    213             array('chronology_date', 'start')
     164            array('chronology_date', 'start', 'flat_recent_cat')
    214165          );
    215166  $template->assign_block_vars(
  • trunk/language/en_UK.iso-8859-1/common.lang.php

    r1651 r1677  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    77// | branch        : BSF (Best So Far)
     
    491491$lang['maxwidth'] = 'Maximum width of the pictures';
    492492$lang['maxwidth_error'] = 'Maximum width must be a number superior to 50';
    493 $lang['start_filter_local_mode_hint'] = '[local] displays only recent elements';
    494 $lang['stop_filter_local_mode_hint'] = '[local] return to display all elements';
    495 $lang['start_filter_global_mode_hint'] = '[global] displays only recent elements';
    496 $lang['stop_filter_global_mode_hint'] = '[global] return to display all elements';
     493$lang['flat_recent_cat_hint'] = 'display recent elements of categories and sub-categories';
     494$lang['start_filter_hint'] = 'displays only recent elements';
     495$lang['stop_filter_hint'] = 'return to display all elements';
    497496$lang['mode_created_hint'] = 'displays a calendar by creation date';
    498497$lang['mode_normal_hint'] = 'return to normal view mode';
     
    614613$lang['w_month'] = 'Month';
    615614$lang['yes'] = 'Yes';
     615$lang['note_filter_day'] = 'The whole of the elements are filtered in order to diplay the recent elements of less %s day.';
     616$lang['note_filter_days'] = 'The whole of the elements are filtered in order to diplay the recent elements of less %s days.';
    616617?>
  • trunk/language/fr_FR.iso-8859-1/common.lang.php

    r1651 r1677  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    77// | branch        : BSF (Best So Far)
     
    491491$lang['maxwidth'] = 'Largeur maximum des images';
    492492$lang['maxwidth_error'] = 'La largeur des images doit être supérieure à 50';
    493 $lang['start_filter_local_mode_hint'] = '[local] afficher que les éléments récents';
    494 $lang['stop_filter_local_mode_hint'] = '[local] retourner à l\'affichage de tous les éléments';
    495 $lang['start_filter_global_mode_hint'] = '[global] afficher que les éléments récents';
    496 $lang['stop_filter_global_mode_hint'] = '[global] retourner à l\'affichage de tous les éléments';
     493$lang['flat_recent_cat_hint'] = 'affiche les éléments récents des catégories et des sous-catégories';
     494$lang['start_filter_hint'] = 'afficher que les éléments récents';
     495$lang['stop_filter_hint'] = 'retourner à l\'affichage de tous les éléments';
    497496$lang['mode_created_hint'] = 'afficher un calendrier par date de création';
    498497$lang['mode_normal_hint'] = 'retourner à la vue normale';
     
    615614$lang['w_month'] = 'Mois';
    616615$lang['yes'] = 'Oui';
     616$lang['note_filter_day'] = 'L\'ensemble des éléments est filtré pour n\'afficher que les éléments récents de moins de %d jour.';
     617$lang['note_filter_days'] = 'L\'ensemble des éléments est filtré pour n\'afficher que les éléments récents de moins de %d jours.';
    617618?>
  • trunk/picture.php

    r1627 r1677  
    249249    INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id
    250250  WHERE image_id = '.$page['image_id'].'
    251     AND category_id NOT IN ('.$user['forbidden_categories'].')
     251'.get_sql_condition_FandF
     252  (
     253    array
     254      (
     255        'forbidden_categories' => 'category_id',
     256        'visible_categories' => 'category_id'
     257      ),
     258    'AND'
     259  ).'
    252260;';
    253261$result = pwg_query($query);
  • trunk/random.php

    r1503 r1677  
    4646  FROM '.IMAGES_TABLE.'
    4747    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
    48   '.(
    49     $user['forbidden_categories'] != ''
    50       ? 'WHERE category_id NOT IN ('.$user['forbidden_categories'].')'
    51       : ''
    52     ).'
     48'.get_sql_condition_FandF
     49  (
     50    array
     51      (
     52        'forbidden_categories' => 'category_id',
     53        'visible_categories' => 'category_id',
     54        'visible_images' => 'id'
     55      ),
     56    'WHERE'
     57  ).'
    5358  ORDER BY RAND(NOW())
    5459  LIMIT 0, '.$conf['top_number'].'
  • trunk/search.php

    r1627 r1677  
    188188  );
    189189
    190 $available_tags = get_available_tags(
    191       isset($user['forbidden_categories'])
    192       ? explode(',', $user['forbidden_categories'])
    193       : null
    194       );
     190$available_tags = get_available_tags();
    195191
    196192if (count($available_tags) > 0)
     
    214210$query = '
    215211SELECT name,id,date_last,nb_images,global_rank,uppercats
    216   FROM '.CATEGORIES_TABLE;
    217 if ($user['forbidden_categories'] != '')
    218 {
    219   $query.= '
    220   WHERE id NOT IN ('.$user['forbidden_categories'].')';
    221 }
    222 $query.= '
     212  FROM '.CATEGORIES_TABLE.'
     213'.get_sql_condition_FandF
     214  (
     215    array
     216      (
     217        'forbidden_categories' => 'id',
     218        'visible_categories' => 'id'
     219      ),
     220    'WHERE'
     221  ).'
    223222;';
    224223
  • trunk/services/recent.php

    r1675 r1677  
    11<?php
    22
    3 $where = ( $user['forbidden_categories'] == '') ? '' :
    4   'ic.`category_id` NOT IN ('.$user['forbidden_categories'].')';
     3$where =
     4  get_sql_condition_FandF
     5    (
     6      array
     7        (
     8          'forbidden_categories' => 'ic.category_id',
     9          'visible_categories' => 'ic.category_id',
     10          'visible_images' => 'i.id'
     11        ),
     12      ''
     13    );
    514$list = implode(',', $final);
    615if ( $where !== '' and $list !== '' )
  • trunk/tags.php

    r1120 r1677  
    7474
    7575// find all tags available for the current user
    76 $tags = get_available_tags(explode(',', $user['forbidden_categories']));
     76$tags = get_available_tags();
    7777
    7878// we want only the first most represented tags, so we sort them by counter
  • trunk/template/yoga/default-colors.css

    r1657 r1677  
    101101}
    102102
     103/**
     104 * Header notes box in public/administration
     105 */
     106.header_notes {
     107  border: 1px solid #aaaaaa; /* border color and style */
     108  text-align: center;
     109  background-image: url(icon/note.png);
     110  background-repeat: no-repeat;
     111  background-position: top left;
     112  font-weight: bold;
     113  margin: 14px;
     114  padding: 5px 00px 0px 0px;
     115}
     116
    103117LEGEND {
    104118  font-style: italic;
  • trunk/template/yoga/header.tpl

    r1636 r1677  
    7373<!-- END header_msgs -->
    7474<div id="theHeader">{PAGE_BANNER}</div>
     75<!-- BEGIN header_notes -->
     76<div class="header_notes">
     77  <!-- BEGIN header_note -->
     78  <P>{header_notes.header_note.HEADER_NOTE}</p>
     79  <!-- END header_note -->
     80</div>
     81<!-- END header_notes -->
  • trunk/template/yoga/index.tpl

    r1651 r1677  
    2828      <!-- END search_rules -->
    2929
    30       <!-- BEGIN start_filter_local_mode -->
    31       <li><a href="{start_filter_local_mode.URL}" title="{lang:start_filter_local_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/start_filter_mode.png" class="button" alt="{lang:start_filter_local_mode_hint}"></a></li>
    32       <!-- END start_filter_local_mode -->
    33       <!-- BEGIN stop_filter_local_mode -->
    34       <li><a href="{stop_filter_local_mode.URL}" title="{lang:stop_filter_local_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/stop_filter_mode.png" class="button" alt="{lang:stop_filter_local_mode_hint}"></a></li>
    35       <!-- END stop_filter_local_mode -->
    36 
    3730      <!-- BEGIN mode_normal -->
    3831      <li><a href="{mode_normal.URL}" title="{lang:mode_normal_hint}"><img src="{pwg_root}{themeconf:icon_dir}/normal_mode.png" class="button" alt="{lang:mode_normal_hint}"></a></li>
    3932      <!-- END mode_normal -->
     33
     34      <!-- BEGIN flat_recent_cat -->
     35      <li><a href="{flat_recent_cat.URL}" title="{lang:flat_recent_cat_hint}"><img src="{pwg_root}{themeconf:icon_dir}/flat_recent_cat.png" class="button" alt="{lang:flat_recent_cat_hint}"></a></li>
     36      <!-- END flat_recent_cat -->
     37
    4038      <!-- BEGIN mode_posted -->
    4139      <li><a href="{mode_posted.URL}" title="{lang:mode_posted_hint}" rel="nofollow"><img src="{pwg_root}{themeconf:icon_dir}/calendar.png" class="button" alt="{lang:mode_posted_hint}"></a></li>
  • trunk/template/yoga/menubar.tpl

    r1652 r1677  
    1414<!-- END links -->
    1515<dl id="mbCategories">
    16   <!-- BEGIN start_filter_global_mode -->
    17   <a href="{start_filter_global_mode.URL}" title="{lang:start_filter_global_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/start_filter_mode.png" class="buttonmenu" alt="{lang:start_filter_global_mode_hint}"></a>
    18   <!-- END start_filter_global_mode -->
    19   <!-- BEGIN stop_filter_global_mode -->
    20   <a href="{stop_filter_global_mode.URL}" title="{lang:stop_filter_global_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/stop_filter_mode.png" class="buttonmenu" alt="{lang:stop_filter_global_mode_hint}"></a>
    21   <!-- END stop_filter_global_mode -->
     16  <!-- BEGIN start_filter -->
     17  <a href="{start_filter.URL}" title="{lang:start_filter_hint}"><img src="{pwg_root}{themeconf:icon_dir}/start_filter.png" class="buttonmenu" alt="{lang:start_filter_hint}"></a>
     18  <!-- END start_filter -->
     19  <!-- BEGIN stop_filter -->
     20  <a href="{stop_filter.URL}" title="{lang:stop_filter_hint}"><img src="{pwg_root}{themeconf:icon_dir}/stop_filter.png" class="buttonmenu" alt="{lang:stop_filter_hint}"></a>
     21  <!-- END stop_filter -->
    2222  <dt><a href="{U_HOME}">{lang:Categories}</a></dt>
    2323  <dd>
  • trunk/template/yoga/theme/clear/theme.css

    r1515 r1677  
    1616}
    1717
    18 #menubar DL, #content, #imageToolBar {
     18#menubar DL, #content, #imageToolBar, .header_notes {
    1919  background-color: #eeeeee;
    2020}
  • trunk/template/yoga/theme/dark/theme.css

    r1515 r1677  
    2727}
    2828
    29 #menubar DL, #content, #imageToolBar {
     29#menubar DL, #content, #imageToolBar, .header_notes {
    3030  background-color: #5f5f5f;
    3131}
  • trunk/web_service.php

    r1675 r1677  
    171171SELECT DISTINCT image_id
    172172  FROM '.IMAGE_CATEGORY_TABLE.'
    173 WHERE  category_id NOT IN ('.$user['forbidden_categories'].')
     173WHERE
     174'.get_sql_condition_FandF
     175  (
     176    array
     177      (
     178        'forbidden_categories' => 'category_id',
     179        'visible_categories' => 'category_id',
     180        'visible_images' => 'image_id'
     181      ),
     182    '', true
     183  ).'
    174184  AND  image_id IN ('.$list.')
    175185;';
     
    390400       AND i.`representative_ext` IS NULL
    391401       '.$cat_criterion.'
    392        AND c.`id` NOT IN ('.$user['forbidden_categories'].') ';
     402       '.get_sql_condition_FandF
     403         (
     404            array
     405             (
     406               'forbidden_categories' => 'c.id',
     407               'visible_categories' => 'c.id',
     408               'visible_images' => 'i.id'
     409              ),
     410           'AND'
     411         );
    393412
    394413//     AND c.`agreed_ws` = \'true\' (Obsolete specification replaced by force)
Note: See TracChangeset for help on using the changeset viewer.