aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/category_cats.inc.php71
-rw-r--r--include/category_default.inc.php12
-rw-r--r--include/common.inc.php12
-rw-r--r--include/config_default.inc.php19
-rw-r--r--include/filter.inc.php117
-rw-r--r--include/functions_calendar.inc.php13
-rw-r--r--include/functions_category.inc.php45
-rw-r--r--include/functions_filter.inc.php66
-rw-r--r--include/functions_html.inc.php5
-rw-r--r--include/functions_notification.inc.php47
-rw-r--r--include/functions_search.inc.php25
-rw-r--r--include/functions_tag.inc.php18
-rw-r--r--include/functions_url.inc.php5
-rw-r--r--include/functions_user.inc.php273
-rwxr-xr-xinclude/menubar.inc.php22
-rw-r--r--include/page_header.php12
-rw-r--r--include/section_init.inc.php171
-rw-r--r--include/user.inc.php15
18 files changed, 734 insertions, 214 deletions
diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php
index c84bdf6e9..67e666fb8 100644
--- a/include/category_cats.inc.php
+++ b/include/category_cats.inc.php
@@ -42,7 +42,16 @@ SELECT
ON id = cat_id and user_id = '.$user['id'].'
WHERE date_last > SUBDATE(
CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY
- );';
+ )
+'.get_sql_condition_FandF
+ (
+ array
+ (
+ 'visible_categories' => 'id',
+ ),
+ 'AND'
+ ).'
+;';
}
else
{
@@ -54,14 +63,15 @@ SELECT
FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
ON id = cat_id and user_id = '.$user['id'].'
WHERE id_uppercat '.
- (!isset($page['category']) ? 'is NULL' : '= '.$page['category']);
- if ($page['filter_local_mode'])
- {
- $query.= '
- AND max_date_last > SUBDATE(
- CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
- }
- $query.= '
+ (!isset($page['category']) ? 'is NULL' : '= '.$page['category']).'
+'.get_sql_condition_FandF
+ (
+ array
+ (
+ 'visible_categories' => 'id',
+ ),
+ 'AND'
+ ).'
ORDER BY rank
;';
}
@@ -85,21 +95,18 @@ while ($row = mysql_fetch_assoc($result))
SELECT image_id
FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic
ON ic.category_id = c.id';
- if ($page['filter_local_mode'] or $user['filter_global_mode'])
- {
- $query.= '
- INNER JOIN '.IMAGES_TABLE.' AS i on ic.image_id = i.id ';
- }
$query.= '
WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'
- AND c.id NOT IN ('.$user['forbidden_categories'].')';
- if ($page['filter_local_mode'] or $user['filter_global_mode'])
- {
- $query.= '
- AND i.date_available > SUBDATE(
- CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
- }
- $query.= '
+'.get_sql_condition_FandF
+ (
+ array
+ (
+ 'forbidden_categories' => 'c.id',
+ 'visible_categories' => 'c.id',
+ 'visible_images' => 'image_id'
+ ),
+ 'AND'
+ ).'
ORDER BY RAND()
LIMIT 0,1
;';
@@ -116,14 +123,15 @@ SELECT representative_picture_id
FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
ON id = cat_id and user_id = '.$user['id'].'
WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'
- AND representative_picture_id IS NOT NULL';
- if ($page['filter_local_mode'] or $user['filter_global_mode'])
- {
- $query.= '
- AND max_date_last > SUBDATE(
- CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
- }
- $query.= '
+ AND representative_picture_id IS NOT NULL
+'.get_sql_condition_FandF
+ (
+ array
+ (
+ 'visible_categories' => 'id',
+ ),
+ 'AND'
+ ).'
ORDER BY RAND()
LIMIT 0,1
;';
@@ -161,6 +169,9 @@ SELECT id, path, tn_ext
if (count($categories) > 0)
{
+ // Update filtered data
+ update_cats_with_filtered_data($categories);
+
if ($conf['subcatify'])
{
$template->set_filenames(
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index 1fff71956..8422fcf13 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
// | file : $RCSfile$
@@ -46,14 +46,8 @@ if (count($selection) > 0)
$query = '
SELECT *
FROM '.IMAGES_TABLE.'
- WHERE id IN ('.implode(',', $selection).')';
- if ($page['filter_local_mode'] or $user['filter_global_mode'])
- {
- $query.= '
- AND date_available > SUBDATE(
- CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
- }
- $query.= ';';
+ WHERE id IN ('.implode(',', $selection).')
+;';
$result = pwg_query($query);
while ($row = mysql_fetch_assoc($result))
{
diff --git a/include/common.inc.php b/include/common.inc.php
index c1ebc7f74..3fca4783d 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -112,6 +112,7 @@ $page = array();
$user = array();
$lang = array();
$header_msgs = array();
+$header_notes = array();
@include(PHPWG_ROOT_PATH .'include/mysql.inc.php');
if (!defined('PHPWG_INSTALLED'))
@@ -228,6 +229,17 @@ if (count($header_msgs) > 0)
}
}
+if (!defined('IN_ADMIN') or !IN_ADMIN)
+{
+ include(PHPWG_ROOT_PATH.'include/functions_filter.inc.php');
+ include(PHPWG_ROOT_PATH.'include/filter.inc.php');
+}
+
+if (isset($conf['header_notes']))
+{
+ $header_notes = array_merge($header_notes, $conf['header_notes']);
+}
+
// default event handlers
add_event_handler('render_comment_content', 'parse_comment_content');
trigger_action('init');
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index 6e6b39cb5..453a9a02b 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -174,6 +174,10 @@ $conf['show_version'] = true;
// page.
$conf['links'] = array();
+// List of notes to display on all header page
+// example $conf['header_notes'] = array('Test', 'Hello');
+$conf['header_notes'] = array();
+
// show_thumbnail_caption : on thumbnails page, show thumbnail captions ?
$conf['show_thumbnail_caption'] = true;
@@ -543,7 +547,7 @@ $conf['nbm_treatment_timeout_default'] = 20;
$conf['enable_plugins']=true;
// +-----------------------------------------------------------------------+
-// | Set default for Web Service |
+// | Set default for Web Service |
// +-----------------------------------------------------------------------+
// Web services are accepted
@@ -561,4 +565,17 @@ $conf['enable_plugins']=true;
// 0 it's temporary closed (Useful for one access)
$conf['ws_durations'] = array(3650,1825,730,365,182,91,30,15,10,7,5,1,0);
+// +-----------------------------------------------------------------------+
+// | Filter |
+// +-----------------------------------------------------------------------+
+// Pages where filter is enabled
+// Other pages cancel current filter
+$conf['filter_pages'] = array
+ (
+ 'about.php', 'action.php', 'admin.php', 'comments.php',
+ 'index.php', 'picture.php', 'popuphelp.php', 'profile.php',
+ 'qsearch.php', 'random.php', 'register.php', 'search.php',
+ 'search_rules.php', 'tags.php', 'upload.php'
+ );
+
?>
diff --git a/include/filter.inc.php b/include/filter.inc.php
new file mode 100644
index 000000000..3a1279f94
--- /dev/null
+++ b/include/filter.inc.php
@@ -0,0 +1,117 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery |
+// | Copyright (C) 2006-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | branch : BSF (Best So Far)
+// | file : $Id: filter.inc.php 1651 2006-12-13 00:05:16Z rub $
+// | last update : $Date: 2006-12-13 01:05:16 +0100 (mer., 13 déc. 2006) $
+// | last modifier : $Author: rub $
+// | revision : $Revision: 1651 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+// global variable for filter
+$filter = array();
+
+// $filter['enabled']: Filter is enabled
+// $filter['categories']: Computed data of filtered categories
+// $filter['visible_categories']: List of visible categories (count(visible) < count(forbidden) more often)
+// $filter['visible_images']: List of visible images
+
+
+$filter['enabled'] =
+ (in_array(basename($_SERVER['SCRIPT_FILENAME']), $conf['filter_pages'])) and
+ (
+ (isset($_GET['filter']) and ($_GET['filter'] == 'start')) or
+ pwg_get_session_var('filter_enabled', false)
+ );
+
+if (in_array(basename($_SERVER['SCRIPT_FILENAME']), $conf['filter_pages']))
+{
+ if (isset($_GET['filter']))
+ {
+ $filter['enabled'] = ($_GET['filter'] == 'start');
+ }
+ else
+ {
+ $filter['enabled'] = pwg_get_session_var('filter_enabled', false);
+ }
+}
+else
+{
+ $filter['enabled'] = false;
+}
+
+if ($filter['enabled'])
+{
+ if (
+ // New filter
+ !pwg_get_session_var('filter_enabled', false) or
+ // Cache data updated
+ $user['need_update_done'] or
+ // Date, period, user are changed
+ (pwg_get_session_var('filter_check_key', '') != get_filter_check_key())
+ )
+ {
+ // Need to compute dats
+ $filter['check_key'] = get_filter_check_key();
+ $filter['categories'] = get_computed_categories($user['id'], $user['forbidden_categories'], true, $user['recent_period']);
+ $filter['visible_categories'] = implode(',', array_keys($filter['categories']));
+
+ $query ='
+SELECT
+ distinct image_id
+FROM '.
+ IMAGE_CATEGORY_TABLE.' INNER JOIN '.IMAGES_TABLE.' ON image_id = id
+WHERE ';
+ if (!empty($filter['visible_categories']))
+ {
+ $query.= '
+ category_id IN ('.$filter['visible_categories'].') and';
+ }
+ $query.= '
+ date_available > SUBDATE(
+ CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
+
+ $filter['visible_images'] = implode(',', array_from_query($query, 'image_id'));
+ }
+ else
+ {
+ // Read only data
+ $filter['check_key'] = pwg_get_session_var('filter_check_key', '');
+ $filter['categories'] = unserialize(pwg_get_session_var('filter_categories', serialize(array())));
+ $filter['visible_categories'] = pwg_get_session_var('filter_visible_categories', '');
+ $filter['visible_images'] = pwg_get_session_var('filter_visible_images', '');
+ }
+
+ $header_notes[] = l10n_dec($lang['note_filter_day'], $lang['note_filter_days'], $user['recent_period']);
+}
+else
+{
+ $filter['check_key'] = '';
+ $filter['categories'] = array();
+ $filter['visible_categories'] = '';
+ $filter['visible_images'] = '';
+}
+
+pwg_set_session_var('filter_enabled', $filter['enabled']);
+pwg_set_session_var('filter_check_key', $filter['check_key']);
+pwg_set_session_var('filter_categories', serialize($filter['categories']));
+pwg_set_session_var('filter_visible_categories', $filter['visible_categories']);
+pwg_set_session_var('filter_visible_images', $filter['visible_images']);
+
+?>
diff --git a/include/functions_calendar.inc.php b/include/functions_calendar.inc.php
index 3bc79cddc..3bb70ed35 100644
--- a/include/functions_calendar.inc.php
+++ b/include/functions_calendar.inc.php
@@ -29,7 +29,7 @@ define('CAL_VIEW_CALENDAR', 'calendar');
function initialize_calendar()
{
- global $page, $conf, $user, $template;
+ global $page, $conf, $user, $template, $filter;
//------------------ initialize the condition on items to take into account ---
$inner_sql = ' FROM ' . IMAGES_TABLE;
@@ -58,7 +58,16 @@ WHERE category_id IN ('.implode(',',$sub_ids).')';
else
{
$inner_sql .= '
-WHERE category_id NOT IN ('.$user['forbidden_categories'].')';
+ '.get_sql_condition_FandF
+ (
+ array
+ (
+ 'forbidden_categories' => 'category_id',
+ 'visible_categories' => 'category_id',
+ 'visible_images' => 'image_id'
+ ),
+ 'WHERE', true
+ );
}
}
else
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 4ae2b126c..bde0944e7 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
// | file : $Id$
@@ -44,6 +44,8 @@ function check_restrictions($category_id)
{
global $user;
+ // $filter['visible_categories'] and $filter['visible_images']
+ // are not used because it's not necessary (filter <> restriction)
if (in_array($category_id, explode(',', $user['forbidden_categories'])))
{
access_denied();
@@ -52,7 +54,7 @@ function check_restrictions($category_id)
function get_categories_menu()
{
- global $page, $user;
+ global $page, $user, $filter;
$query = '
SELECT ';
@@ -65,28 +67,34 @@ SELECT ';
// $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
$query.= '
- FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
+FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
ON id = cat_id and user_id = '.$user['id'];
- if ($page['filter_local_mode'])
+
+ // Always expand when filter is activated
+ if (!$user['expand'] and !$filter['enabled'])
{
$query.= '
-where max_date_last > SUBDATE(
- CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
+WHERE
+(id_uppercat is NULL';
+ if (isset($page['category']))
+ {
+ $query.= ' OR id_uppercat IN ('.$page['uppercats'].')';
+ }
+ $query.= ')';
}
else
{
- // Always expand when filter_local_mode is activated
- if (!$user['expand'] and !$user['filter_global_mode'])
- {
- $query.= '
- WHERE (id_uppercat is NULL';
- if (isset($page['category']))
- {
- $query.= ' OR id_uppercat IN ('.$page['uppercats'].')';
- }
- $query.= ')';
- }
+ $query.= '
+ '.get_sql_condition_FandF
+ (
+ array
+ (
+ 'visible_categories' => 'id',
+ ),
+ 'WHERE'
+ );
}
+
$query.= '
;';
@@ -98,6 +106,9 @@ where max_date_last > SUBDATE(
}
usort($cats, 'global_rank_compare');
+ // Update filtered data
+ update_cats_with_filtered_data($cats);
+
return get_html_menu_category($cats);
}
diff --git a/include/functions_filter.inc.php b/include/functions_filter.inc.php
new file mode 100644
index 000000000..4bd5a6769
--- /dev/null
+++ b/include/functions_filter.inc.php
@@ -0,0 +1,66 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery |
+// | Copyright (C) 2006-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | branch : BSF (Best So Far)
+// | file : $Id: functions_filter.inc.php 1651 2006-12-13 00:05:16Z rub $
+// | last update : $Date: 2006-12-13 01:05:16 +0100 (mer., 13 déc. 2006) $
+// | last modifier : $Author: rub $
+// | revision : $Revision: 1651 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+
+/**
+ * Get a check key for filtered data
+ * Check key are composed of elements witch force to compute data
+ *
+ * @param null
+ * @return strinf check_key
+ */
+function get_filter_check_key()
+{
+ global $user;
+
+ return $user['id'].$user['recent_period'].date('Ymd');
+}
+
+/**
+ * update data of categories with filtered values
+ *
+ * @param array list of categories
+ * @return null
+ */
+function update_cats_with_filtered_data(&$cats)
+{
+ global $filter;
+
+ if ($filter['enabled'])
+ {
+ $upd_fields = array('max_date_last', 'count_images', 'count_categories', 'nb_images');
+
+ foreach ($cats as $cat_id => $category)
+ {
+ foreach ($upd_fields as $upd_field)
+ {
+ $cats[$cat_id][$upd_field] = $filter['categories'][$category['id']][$upd_field];
+ }
+ }
+ }
+}
+
+?>
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php
index 39f738f3f..8b544defa 100644
--- a/include/functions_html.inc.php
+++ b/include/functions_html.inc.php
@@ -288,11 +288,12 @@ function get_cat_display_name($cat_informations,
{
$output.= '<a class=""';
$output.= ' href="'
- .make_index_url(
+ .duplicate_index_url(
array(
'category'=>$id,
'cat_name'=>$name
- )
+ ),
+ array('start')
)
.'">';
$output.= $name.'</a>';
diff --git a/include/functions_notification.inc.php b/include/functions_notification.inc.php
index 8c88fd342..631922303 100644
--- a/include/functions_notification.inc.php
+++ b/include/functions_notification.inc.php
@@ -28,6 +28,31 @@
// +-----------------------------------------------------------------------+
// | functions |
// +-----------------------------------------------------------------------+
+
+/*
+ * get standard sql where in order to
+ * restict an filter caregories and images
+ *
+ * IMAGE_CATEGORY_TABLE muste named ic in the query
+ *
+ * @param none
+ *
+ * @return string sql where
+ */
+function get_std_sql_where_restrict_filter($prefix_condition, $force_one_condition = false)
+{
+ return get_sql_condition_FandF
+ (
+ array
+ (
+ 'forbidden_categories' => 'ic.category_id',
+ 'visible_categories' => 'ic.category_id',
+ 'visible_images' => 'ic.image_id'
+ ),
+ $prefix_condition,
+ $force_one_condition
+ );
+}
/*
* Execute custom notification query
@@ -43,7 +68,7 @@
function custom_notification_query($action, $type, $start, $end)
{
global $user;
-
+
switch($type)
{
case 'new_comments':
@@ -53,7 +78,7 @@ function custom_notification_query($action, $type, $start, $end)
WHERE c.image_id = ic.image_id
AND c.validation_date > \''.$start.'\'
AND c.validation_date <= \''.$end.'\'
- AND category_id NOT IN ('.$user['forbidden_categories'].')
+ '.get_std_sql_where_restrict_filter('AND').'
;';
break;
case 'unvalidated_comments':
@@ -66,18 +91,18 @@ function custom_notification_query($action, $type, $start, $end)
break;
case 'new_elements':
$query = '
- FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id
+ FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = id
WHERE date_available > \''.$start.'\'
AND date_available <= \''.$end.'\'
- AND category_id NOT IN ('.$user['forbidden_categories'].')
+ '.get_std_sql_where_restrict_filter('AND').'
;';
break;
case 'updated_categories':
$query = '
- FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id
+ FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = id
WHERE date_available > \''.$start.'\'
AND date_available <= \''.$end.'\'
- AND category_id NOT IN ('.$user['forbidden_categories'].')
+ '.get_std_sql_where_restrict_filter('AND').'
;';
break;
case 'new_users':
@@ -421,15 +446,15 @@ function news($start, $end, $exclude_img_cats=false, $add_url=false)
*/
function get_recent_post_dates($max_dates, $max_elements, $max_cats)
{
- global $conf, $user;
+ global $conf, $user;
- $where_sql = 'WHERE category_id NOT IN ('.$user['forbidden_categories'].')';
+ $where_sql = get_std_sql_where_restrict_filter('WHERE', true);
$query = '
SELECT date_available,
COUNT(DISTINCT id) nb_elements,
COUNT(DISTINCT category_id) nb_cats
- FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id
+ FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id
'.$where_sql.'
GROUP BY date_available
ORDER BY date_available DESC
@@ -448,7 +473,7 @@ SELECT date_available,
{ // get some thumbnails ...
$query = '
SELECT DISTINCT id, path, name, tn_ext
- FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id
+ FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id
'.$where_sql.'
AND date_available="'.$dates[$i]['date_available'].'"
AND tn_ext IS NOT NULL
@@ -466,7 +491,7 @@ SELECT DISTINCT id, path, name, tn_ext
{// get some categories ...
$query = '
SELECT DISTINCT c.uppercats, COUNT(DISTINCT i.id) img_count
- FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON i.id=image_id
+ FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id=image_id
INNER JOIN '.CATEGORIES_TABLE.' c ON c.id=category_id
'.$where_sql.'
AND date_available="'.$dates[$i]['date_available'].'"
diff --git a/include/functions_search.inc.php b/include/functions_search.inc.php
index 36dbb6210..14076ffb0 100644
--- a/include/functions_search.inc.php
+++ b/include/functions_search.inc.php
@@ -335,7 +335,7 @@ function get_qsearch_like_clause($q, $field)
*/
function get_quick_search_results($q)
{
- global $user, $page;
+ global $user, $page, $filter;
$search_results = array();
// first search tag names corresponding to the query $q. we could also search
@@ -384,7 +384,16 @@ FROM (
)
INNER JOIN
'.CATEGORIES_TABLE.' c on c.id=ic.category_id
-WHERE category_id NOT IN ('.$user['forbidden_categories'].')
+'.get_sql_condition_FandF
+ (
+ array
+ (
+ 'forbidden_categories' => 'category_id',
+ 'visible_categories' => 'category_id',
+ 'visible_images' => 'ic.image_id'
+ ),
+ 'WHERE'
+ ).'
GROUP BY i.id';
$query = 'SELECT id, MATCH(ft) AGAINST( "'.$q.'" IN BOOLEAN MODE) AS q FROM ('.$query.') AS Y
@@ -427,8 +436,16 @@ SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE id IN ('.implode(',', array_keys($by_tag_weights) ).')
- AND category_id NOT IN ('.$user['forbidden_categories'].')';
-
+'.get_sql_condition_FandF
+ (
+ array
+ (
+ 'forbidden_categories' => 'category_id',
+ 'visible_categories' => 'category_id',
+ 'visible_images' => 'ic.image_id'
+ ),
+ 'AND'
+ );
$allowed_image_ids = array_from_query( $query, 'id');
$by_tag_weights = array_intersect_key($by_tag_weights, array_flip($allowed_image_ids));
arsort($by_tag_weights, SORT_NUMERIC);
diff --git a/include/functions_tag.inc.php b/include/functions_tag.inc.php
index b330041ca..c01bb2fc7 100644
--- a/include/functions_tag.inc.php
+++ b/include/functions_tag.inc.php
@@ -37,7 +37,7 @@
* @param array forbidden categories
* @return array
*/
-function get_available_tags($forbidden_categories = null)
+function get_available_tags()
{
// we can find top fatter tags among reachable images
$tags_query = '
@@ -45,13 +45,25 @@ SELECT tag_id, name, url_name, count(*) counter
FROM '.IMAGE_TAG_TABLE.'
INNER JOIN '.TAGS_TABLE.' ON tag_id = id';
- if (!is_null($forbidden_categories))
+ $where_tag_img =
+ get_sql_condition_FandF
+ (
+ array
+ (
+ 'forbidden_categories' => 'category_id',
+ 'visible_categories' => 'category_id',
+ 'visible_images' => 'image_id'
+ ),
+ 'WHERE'
+ );
+
+ if (!is_null($where_tag_img))
{
// first we need all reachable image ids
$images_query = '
SELECT DISTINCT image_id
FROM '.IMAGE_CATEGORY_TABLE.'
- WHERE category_id NOT IN ('.implode(',', $forbidden_categories).')
+ '.$where_tag_img.'
;';
$image_ids = array_from_query($images_query, 'image_id');
if ( empty($image_ids) )
diff --git a/include/functions_url.inc.php b/include/functions_url.inc.php
index 2b561f3d4..e50f3e2e8 100644
--- a/include/functions_url.inc.php
+++ b/include/functions_url.inc.php
@@ -264,6 +264,11 @@ function add_well_known_params_in_url($url, $params)
}
}
+ if (isset($params['flat_recent_cat']) and $params['flat_recent_cat'] > 0)
+ {
+ $url.= '/flat_recent_cat-'.$params['flat_recent_cat'];
+ }
+
if (isset($params['start']) and $params['start'] > 0)
{
$url.= '/start-'.$params['start'];
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index d59a97e4d..dba5072fb 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -143,12 +143,11 @@ function setup_style($style)
return new Template(PHPWG_ROOT_PATH.'template/'.$style);
}
-function build_user( $user_id, $use_cache, $filter_global_mode = false )
+function build_user( $user_id, $use_cache )
{
global $conf;
-
$user['id'] = $user_id;
- $user = array_merge( $user, getuserdata($user_id, $use_cache, $filter_global_mode) );
+ $user = array_merge( $user, getuserdata($user_id, $use_cache) );
if ( $user['id'] == $conf['guest_id'])
{
$user['is_the_guest']=true;
@@ -167,7 +166,6 @@ function build_user( $user_id, $use_cache, $filter_global_mode = false )
{
$user['is_the_guest']=false;
}
-
// calculation of the number of picture to display per page
$user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page'];
@@ -198,7 +196,7 @@ function build_user( $user_id, $use_cache, $filter_global_mode = false )
* @param boolean use_cache
* @param array
*/
-function getuserdata($user_id, $use_cache, $filter_global_mode = false )
+function getuserdata($user_id, $use_cache)
{
global $conf;
@@ -267,21 +265,20 @@ SELECT ui.*, uc.*
if ($use_cache)
{
- $userdata['filter_global_mode'] = $filter_global_mode;
-
if (!isset($userdata['need_update'])
or !is_bool($userdata['need_update'])
- or $userdata['need_update'] == true
- or $filter_global_mode // not optimize condition RubTag
- )
+ or $userdata['need_update'] == true)
{
$userdata['forbidden_categories'] =
calculate_permissions($userdata['id'], $userdata['status']);
- update_user_cache_categories($userdata);
+ update_user_cache_categories($userdata['id'], $userdata['forbidden_categories']);
// Set need update are done
- $userdata['need_update'] = $userdata['filter_global_mode']; // for draft always update RubTag
+ $userdata['need_update'] = false;
+
+ // Indicate update done
+ $userdata['need_update_done'] = true;
$query = '
SELECT COUNT(DISTINCT(image_id)) as total
@@ -306,8 +303,10 @@ INSERT INTO '.USER_CACHE_TABLE.'
;';
pwg_query($query);
}
-
+ else
{
+ // Indicate update not done
+ $userdata['need_update_done'] = false;
}
}
@@ -328,6 +327,8 @@ function check_user_favorites()
return;
}
+ // $filter['visible_categories'] and $filter['visible_images']
+ // must be not used because filter <> restriction
// retrieving images allowed : belonging to at least one authorized
// category
$query = '
@@ -335,7 +336,14 @@ SELECT DISTINCT f.image_id
FROM '.FAVORITES_TABLE.' AS f INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic
ON f.image_id = ic.image_id
WHERE f.user_id = '.$user['id'].'
- AND ic.category_id NOT IN ('.$user['forbidden_categories'].')
+'.get_sql_condition_FandF
+ (
+ array
+ (
+ 'forbidden_categories' => 'ic.category_id',
+ ),
+ 'AND'
+ ).'
;';
$result = pwg_query($query);
$authorizeds = array();
@@ -454,7 +462,7 @@ SELECT id
}
/**
- * compute data of categories branches
+ * compute data of categories branches (one branch only)
*/
function compute_branch_cat_data(&$cats, &$list_cat_id, &$level, &$ref_level)
{
@@ -496,60 +504,82 @@ function compute_branch_cat_data(&$cats, &$list_cat_id, &$level, &$ref_level)
}
/**
- * update data of user_cache_categories
- *
- * @param array userdata
- * @return null
+ * compute data of categories branches
*/
-function update_user_cache_categories(&$userdata)
+function compute_categories_data(&$cats)
{
- // delete user cache
- $query = '
-DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.'
- WHERE user_id = '.$userdata['id'].'
-;';
- pwg_query($query);
+ $ref_level = 0;
+ $level = 0;
+ $list_cat_id = array();
- /*$query = '
-SELECT id cat_id, date_last max_date_last, nb_images count_images, global_rank
- FROM '.CATEGORIES_TABLE;
- if ($userdata['forbidden_categories'] != '')
+ foreach ($cats as $id => $category)
{
- $query.= '
- WHERE id NOT IN ('.$userdata['forbidden_categories'].')';
+ // Compute
+ $level = substr_count($category['global_rank'], '.') + 1;
+ if ($level > $ref_level)
+ {
+ array_push($list_cat_id, $id);
+ }
+ else
+ {
+ compute_branch_cat_data($cats, $list_cat_id, $level, $ref_level);
+ array_push($list_cat_id, $id);
+ }
+ $ref_level = $level;
}
- $query.= ';';*/
+ $level = 1;
+ compute_branch_cat_data($cats, $list_cat_id, $level, $ref_level);
+}
+/**
+ * get computed array of categories
+ *
+ * @param int user_id
+ * @param list user_forbidden_categories
+ * @param bool filter_enabled
+ * @param int recent_period
+ * @return array
+ */
+function get_computed_categories($user_id, $user_forbidden_categories, $filter_enabled, $recent_period = 0)
+{
$query = '
-SELECT c.id cat_id, date_last max_date_last, nb_images count_images, global_rank';
+SELECT
+ c.id cat_id,
+ date_last max_date_last,
+ nb_images count_images,
+ global_rank';
- if (!$userdata['filter_global_mode'])
+ if (!$filter_enabled)
{
$query.= '
- FROM '.CATEGORIES_TABLE.' as C';
+FROM '.CATEGORIES_TABLE.' as c';
}
else
{
// Count by date_available to avoid count null
- $query.= ', count(date_available) filtered_count_images, max(date_available) max_date_available
- FROM '.CATEGORIES_TABLE.' as C
- LEFT JOIN '.IMAGE_CATEGORY_TABLE.' AS ic
- ON ic.category_id = c.id LEFT JOIN '.IMAGES_TABLE.' AS i
- ON ic.image_id = i.id AND i.date_available > SUBDATE(
- CURRENT_DATE,INTERVAL '.$userdata['recent_period'].' DAY)';
+ $query.= ',
+ count(date_available) filtered_count_images,
+ max(date_available) max_date_available
+FROM '.CATEGORIES_TABLE.' as c
+ LEFT JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON ic.category_id = c.id
+ LEFT JOIN '.IMAGES_TABLE.' AS i
+ ON ic.image_id = i.id AND
+ i.date_available > SUBDATE(CURRENT_DATE,INTERVAL '.$recent_period.' DAY)';
}
- if ($userdata['forbidden_categories'] != '')
+ if ($user_forbidden_categories != '')
{
$query.= '
- WHERE C.id NOT IN ('.$userdata['forbidden_categories'].')';
+WHERE
+ c.id NOT IN ('.$user_forbidden_categories.')';
}
- if ($userdata['filter_global_mode'])
+ if ($filter_enabled)
{
$query.= '
- GROUP BY c.id';
+GROUP BY
+ c.id';
}
$query.= ';';
@@ -558,10 +588,11 @@ SELECT c.id cat_id, date_last max_date_last, nb_images count_images, global_rank
$cats = array();
while ($row = mysql_fetch_assoc($result))
{
- $row['user_id'] = $userdata['id'];
+ $row['user_id'] = $user_id;
$row['count_categories'] = 0;
- if ($userdata['filter_global_mode'])
+ if ($filter_enabled)
{
+ $row['nb_images'] = $row['filtered_count_images'];
$row['count_images'] = $row['filtered_count_images'];
$row['max_date_last'] = $row['max_date_available'];
}
@@ -569,50 +600,52 @@ SELECT c.id cat_id, date_last max_date_last, nb_images count_images, global_rank
}
usort($cats, 'global_rank_compare');
- $ref_level = 0;
- $level = 0;
- $list_cat_id = array();
-
- foreach ($cats as $id => $category)
- {
- // Compute
- $level = substr_count($category['global_rank'], '.') + 1;
- if ($level > $ref_level)
- {
- array_push($list_cat_id, $id);
- }
- else
- {
- compute_branch_cat_data($cats, $list_cat_id, $level, $ref_level);
- array_push($list_cat_id, $id);
- }
- $ref_level = $level;
- }
-
- $level = 1;
- compute_branch_cat_data($cats, $list_cat_id, $level, $ref_level);
+ compute_categories_data($cats);
- if ($userdata['filter_global_mode'])
+ if ($filter_enabled)
{
- $forbidden_cats = array();
- $forbidden_cats = explode(',', $userdata['forbidden_categories']);
$cat_tmp = $cats;
$cats = array();
- foreach ($cat_tmp as $cat_id => $category)
+ foreach ($cat_tmp as $category)
{
- if (empty($category['max_date_last']))
- {
- array_push($forbidden_cats, $category['cat_id']);
- }
- else
+ if (!empty($category['max_date_last']))
{
- array_push($cats, $category);
+ // Re-init counters
+ $category['count_categories'] = 0;
+ $category['nb_images'] = $category['filtered_count_images'];
+ $category['count_images'] = $category['filtered_count_images'];
+ // Keep category
+ $cats[$category['cat_id']] = $category;
+
}
}
- $userdata['forbidden_categories'] = implode(',', array_unique($forbidden_cats));
+ // Compute a second time
+ compute_categories_data($cats);
}
+ return $cats;
+}
+
+/**
+ * update data of user_cache_categories
+ *
+ * @param int user_id
+ * @param list user_forbidden_categories
+ * @param bool filter_enabled
+ * @return null
+ */
+function update_user_cache_categories($user_id, $user_forbidden_categories)
+{
+ // delete user cache
+ $query = '
+DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.'
+ WHERE user_id = '.$user_id.'
+;';
+ pwg_query($query);
+
+ $cats = get_computed_categories($user_id, $user_forbidden_categories, false);
+
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
mass_inserts
(
@@ -1014,4 +1047,82 @@ function get_email_address_as_display_text($email_address)
}
}
+/*
+ * Compute sql where condition with restrict and filter data
+ *
+ * FandF: Forbidden and Filters
+ *
+ * @param $condition_fields array:
+ * keys are condition to aply and
+ * values are sql field to use
+ * array('forbidden_categories' => 'ic.category_id')
+ * $prefix_condition string:
+ * this value are concatenated if sql is not empty
+ * $force_one_condition:
+ * if there are not condition , use this condition "1 = 1"
+ *
+ * @return string sql where/conditions
+ */
+function get_sql_condition_FandF($condition_fields, $prefix_condition = null, $force_one_condition = false)
+{
+ global $user, $filter;
+
+ $sql_list = array();
+
+ foreach ($condition_fields as $condition => $field_name)
+ {
+ switch($condition)
+ {
+ case 'forbidden_categories':
+ if (!empty($user['forbidden_categories']))
+ {
+ $sql_list[] = $field_name.' NOT IN ('.$user['forbidden_categories'].')';
+ }
+ break;
+
+ case 'visible_categories':
+ if (!empty($filter['visible_categories']))
+ {
+ $sql_list[] = $field_name.' IN ('.$filter['visible_categories'].')';
+ }
+ break;
+
+ case 'visible_images':
+ if (!empty($filter['visible_images']))
+ {
+ $sql_list[] = $field_name.' IN ('.$filter['visible_images'].')';
+ }
+ break;
+
+ default:
+ die('Unknow condition');
+ break;
+
+ }
+ }
+
+ if (count($sql_list) > 0)
+ {
+ $sql = '('.implode(' AND ', $sql_list).')';
+ }
+ else
+ {
+ if ($force_one_condition)
+ {
+ $sql = '1 = 1';
+ }
+ else
+ {
+ $sql = '';
+ }
+ }
+
+ if (isset($prefix_condition) and !empty($sql))
+ {
+ $sql = $prefix_condition.' '.$sql;
+ }
+
+ return $sql;
+}
+
?>
diff --git a/include/menubar.inc.php b/include/menubar.inc.php
index c149b3553..d5535ca12 100755
--- a/include/menubar.inc.php
+++ b/include/menubar.inc.php
@@ -63,6 +63,28 @@ foreach ($conf['links'] as $url => $label)
)
);
}
+
+//------------------------------------------------------------------------ filter
+if ($filter['enabled'])
+{
+ $template->assign_block_vars(
+ 'stop_filter',
+ array(
+ 'URL' => add_url_params(make_index_url(array()), array('filter' => 'stop'))
+ )
+ );
+}
+else
+{
+ $template->assign_block_vars(
+ 'start_filter',
+ array(
+ 'URL' => add_url_params(make_index_url(array()), array('filter' => 'start'))
+ )
+ );
+}
+
+
//------------------------------------------------------------------------ tags
if ('tags' == $page['section'])
{
diff --git a/include/page_header.php b/include/page_header.php
index a6d4619a3..db7fa3b9a 100644
--- a/include/page_header.php
+++ b/include/page_header.php
@@ -60,6 +60,18 @@ if (isset($header_infos))
{
$template->assign_block_vars( 'header_meta', $header_infos);
}
+
+// Header notes
+if (count($header_notes) > 0)
+{
+ $template->assign_block_vars('header_notes', array());
+ foreach ($header_notes as $header_note)
+ {
+ $template->assign_block_vars('header_notes.header_note',
+ array('HEADER_NOTE' => $header_note));
+ }
+}
+
// refresh
if ( isset( $refresh ) and intval($refresh) >= 0
and isset( $url_link ) and isset( $redirect_msg ) )
diff --git a/include/section_init.inc.php b/include/section_init.inc.php
index 416d98849..d5bbce645 100644
--- a/include/section_init.inc.php
+++ b/include/section_init.inc.php
@@ -267,6 +267,12 @@ while (isset($tokens[$i]))
$page['start'] = $matches[1];
}
+ if (preg_match('/^flat_recent_cat-(\d+)/', $tokens[$i], $matches))
+ {
+ // indicate a special list of images
+ $page['flat_recent_cat'] = $matches[1];
+ }
+
if (preg_match('/^(posted|created)/', $tokens[$i] ))
{
$chronology_tokens = explode('-', $tokens[$i] );
@@ -325,59 +331,134 @@ if ('categories' == $page['section'])
$page = array_merge(
$page,
array(
- 'comment' => $result['comment'],
- 'cat_dir' => $result['dir'],
- 'cat_name' => $result['name'],
- 'cat_site_id' => $result['site_id'],
- 'cat_uploadable' => $result['uploadable'],
- 'cat_commentable' => $result['commentable'],
- 'cat_id_uppercat' => $result['id_uppercat'],
- 'uppercats' => $result['uppercats'],
-
- 'title' => get_cat_display_name($result['name'], '', false),
+ 'comment' => $result['comment'],
+ 'cat_dir' => $result['dir'],
+ 'cat_name' => $result['name'],
+ 'cat_site_id' => $result['site_id'],
+ 'cat_uploadable' => $result['uploadable'],
+ 'cat_commentable' => $result['commentable'],
+ 'cat_id_uppercat' => $result['id_uppercat'],
+ 'uppercats' => $result['uppercats'],
+ 'title' =>
+ get_cat_display_name($result['name'], '', false),
+ 'thumbnails_include' =>
+ (($result['nb_images'] > 0) or (isset($page['flat_recent_cat'])))
+ ? 'include/category_default.inc.php'
+ : 'include/category_cats.inc.php'
)
);
+ }
+ else
+ {
+ $page['title'] = $lang['no_category'];
+ $page['thumbnails_include'] =
+ (isset($page['flat_recent_cat']))
+ ? 'include/category_default.inc.php'
+ : 'include/category_cats.inc.php';
+ }
+
+ if (isset($page['flat_recent_cat']))
+ {
+ $page['title'] = $lang['recent_pics_cat'].' : '.$page['title'] ;
+ }
+
+ if
+ (
+ (!isset($page['chronology_field'])) and
+ (
+ (isset($page['category'])) or
+ (isset($page['flat_recent_cat']))
+ )
+ )
+ {
+ if ( !empty($result['image_order']) and !isset($page['super_order_by']) )
+ {
+ $conf[ 'order_by' ] = ' ORDER BY '.$result['image_order'];
+ }
- if (!isset($page['chronology_field']))
+ if (isset($page['flat_recent_cat']))
{
- if ( !empty($result['image_order']) and !isset($page['super_order_by']) )
+ // flat recent categories mode
+ $query = '
+SELECT
+ DISTINCT(ic.image_id)
+FROM '.IMAGES_TABLE.' AS i
+ INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id = ic.image_id
+ INNER JOIN '.CATEGORIES_TABLE.' AS c ON ic.category_id = c.id
+WHERE
+ date_available > SUBDATE(
+ CURRENT_DATE,INTERVAL '.$page['flat_recent_cat'].' DAY)'.
+ (isset($page['category']) ? '
+ AND uppercats REGEXP \'(^|,)'.$page['category'].'(,|$)\'' : '' ).'
+'.get_sql_condition_FandF
+ (
+ array
+ (
+ 'forbidden_categories' => 'category_id',
+ 'visible_categories' => 'category_id',
+ 'visible_images' => 'image_id'
+ ),
+ 'AND'
+ ).'
+;';
+
+ $where_sql = array_from_query($query, 'image_id');
+ if (!empty($where_sql))
{
- $conf[ 'order_by' ] = ' ORDER BY '.$result['image_order'];
+ $where_sql = 'image_id in ('.implode(',', $where_sql).')';
}
+ }
+ else
+ {
+ // Normal mode
+ $where_sql = 'category_id = '.$page['category'];
+ }
+ if (!empty($where_sql))
+ {
+ // Main query
$query = '
SELECT image_id
FROM '.IMAGE_CATEGORY_TABLE.'
INNER JOIN '.IMAGES_TABLE.' ON id = image_id
- WHERE category_id = '.$page['category'].'
+ WHERE
+ '.$where_sql.'
+'.get_sql_condition_FandF
+ (
+ array
+ (
+ 'forbidden_categories' => 'category_id',
+ 'visible_categories' => 'category_id',
+ 'visible_images' => 'image_id'
+ ),
+ 'AND'
+ ).'
'.$conf['order_by'].'
;';
- $page['items'] = array_from_query($query, 'image_id');
- $page['thumbnails_include'] =
- $result['nb_images'] > 0
- ? 'include/category_default.inc.php'
- : 'include/category_cats.inc.php';
- } //otherwise the calendar will requery all subitems
- }
- else
- {
- $page['title'] = $lang['no_category'];
- $page['thumbnails_include'] = 'include/category_cats.inc.php';
- }
+ $page['items'] = array_from_query($query, 'image_id');
+ }
+ else
+ {
+ $page['items'] = array();
+ }
+ } //otherwise the calendar will requery all subitems
}
// special sections
else
{
- if (!empty($user['forbidden_categories']))
- {
- $forbidden =
- ' category_id NOT IN ('.$user['forbidden_categories'].')';
- }
- else
- {
- $forbidden = ' 1 = 1';
- }
+ $forbidden =
+ get_sql_condition_FandF
+ (
+ array
+ (
+ 'forbidden_categories' => 'category_id',
+ 'visible_categories' => 'category_id',
+ 'visible_images' => 'image_id'
+ ),
+ 'AND'
+ );
+
// +-----------------------------------------------------------------------+
// | tags section |
// +-----------------------------------------------------------------------+
@@ -400,7 +481,7 @@ else
SELECT image_id
FROM '.IMAGE_CATEGORY_TABLE.' INNER JOIN '.IMAGES_TABLE.' ON image_id=id
WHERE image_id IN ('.implode(',', $items).')
- AND '.$forbidden.
+ '.$forbidden.
$conf['order_by'].'
;';
$items = array_unique(
@@ -434,7 +515,7 @@ SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE id IN ('.implode(',', $search_result['items']).')
- AND '.$forbidden.'
+ '.$forbidden.'
'.$conf['order_by'].'
;';
$page['items'] = array_from_query($query, 'id');
@@ -464,6 +545,14 @@ SELECT image_id
FROM '.FAVORITES_TABLE.'
INNER JOIN '.IMAGES_TABLE.' ON image_id = id
WHERE user_id = '.$user['id'].'
+'.get_sql_condition_FandF
+ (
+ array
+ (
+ 'visible_images' => 'image_id'
+ ),
+ 'AND'
+ ).'
'.$conf['order_by'].'
;';
@@ -487,7 +576,7 @@ SELECT DISTINCT(id)
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE date_available > \''.
date('Y-m-d', time() - 60*60*24*$user['recent_period']).'\'
- AND '.$forbidden.'
+ '.$forbidden.'
'.$conf['order_by'].'
;';
@@ -526,7 +615,7 @@ SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE hit > 0
- AND '.$forbidden.'
+ '.$forbidden.'
'.$conf['order_by'].'
LIMIT 0, '.$conf['top_number'].'
;';
@@ -554,7 +643,7 @@ SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE average_rate IS NOT NULL
- AND '.$forbidden.'
+ '.$forbidden.'
'.$conf['order_by'].'
LIMIT 0, '.$conf['top_number'].'
;';
@@ -578,7 +667,7 @@ SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE image_id IN ('.implode(',', $page['list']).')
- AND '.$forbidden.'
+ '.$forbidden.'
'.$conf['order_by'].'
;';
diff --git a/include/user.inc.php b/include/user.inc.php
index 6f75ac962..b67d6e3e4 100644
--- a/include/user.inc.php
+++ b/include/user.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
// | file : $RCSfile$
@@ -70,19 +70,8 @@ if ($conf['apache_authentication'] and isset($_SERVER['REMOTE_USER']))
}
}
-if (isset($_GET['filter_global_mode']))
-{
- $user['filter_global_mode'] = ($_GET['filter_global_mode'] == 'start');
- pwg_set_session_var('filter_global_mode', $user['filter_global_mode']);
-}
-else
-{
- $user['filter_global_mode'] = pwg_get_session_var('filter_global_mode', false);
-}
-
$user = build_user( $user['id'],
- ( defined('IN_ADMIN') and IN_ADMIN ) ? false : true, // use cache ?
- $user['filter_global_mode'] // filter_global_mode ?
+ ( defined('IN_ADMIN') and IN_ADMIN ) ? false : true // use cache ?
);
?> \ No newline at end of file