aboutsummaryrefslogtreecommitdiffstats
path: root/include/filter.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/filter.inc.php')
-rw-r--r--include/filter.inc.php26
1 files changed, 14 insertions, 12 deletions
diff --git a/include/filter.inc.php b/include/filter.inc.php
index b77ddca98..d63515265 100644
--- a/include/filter.inc.php
+++ b/include/filter.inc.php
@@ -22,7 +22,6 @@
// +-----------------------------------------------------------------------+
// $filter['enabled']: Filter is enabled
-// $filter['check_key']: Check key to valitade computed filter data
// $filter['recent_period']: Recent period used to computed filter data
// $filter['categories']: Computed data of filtered categories
// $filter['visible_categories']:
@@ -34,7 +33,7 @@ if (!get_filter_page_value('cancel'))
if (isset($_GET['filter']))
{
$filter['matches'] = array();
- $filter['enabled'] =
+ $filter['enabled'] =
preg_match('/^start-recent-(\d+)$/', $_GET['filter'], $filter['matches']) === 1;
}
else
@@ -49,26 +48,33 @@ else
if ($filter['enabled'])
{
+ $filter_key = pwg_get_session_var('filter_check_key', array('user'=>0,'recent_period'=>-1, 'time'=>0, 'date'=> '') );
+
if (isset($filter['matches']))
{
$filter['recent_period'] = $filter['matches'][1];
}
else
{
- $filter['recent_period'] = pwg_get_session_var('filter_recent_period', $user['recent_period']);
+ $filter['recent_period'] = $filter_key['recent_period']>0 ? $filter_key['recent_period'] : $user['recent_period'];
}
if (
// New filter
!pwg_get_session_var('filter_enabled', false) or
// Cache data updated
- $user['need_update_done'] or
+ $filter_key['time'] <= $user['cache_update_time'] or
// Date, period, user are changed
- (pwg_get_session_var('filter_check_key', '') != get_filter_check_key())
+ $filter_key['user'] != $user['id'] or
+ $filter_key['recent_period'] != $filter['recent_period'] or
+ $filter_key['date'] != date('Ymd')
)
{
// Need to compute dats
- $filter['check_key'] = get_filter_check_key();
+ $filter_key = array(
+ 'user'=>(int)$user['id'],'recent_period'=>(int)$filter['recent_period'], 'time'=>time(), 'date'=> date('Ymd')
+ );
+
$filter['categories'] = get_computed_categories($user, (int)$filter['recent_period']);
$filter['visible_categories'] = implode(',', array_keys($filter['categories']));
@@ -103,22 +109,19 @@ WHERE ';
// Save filter data on session
pwg_set_session_var('filter_enabled', $filter['enabled']);
- pwg_set_session_var('filter_check_key', $filter['check_key']);
- pwg_set_session_var('filter_recent_period', $filter['recent_period']);
+ pwg_set_session_var('filter_check_key', $filter_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']);
-
}
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', '');
}
-
+ unset($filter_key);
if (get_filter_page_value('add_notes'))
{
$header_notes[] = l10n_dec('note_filter_day', 'note_filter_days', $filter['recent_period']);
@@ -130,7 +133,6 @@ else
{
pwg_unset_session_var('filter_enabled');
pwg_unset_session_var('filter_check_key');
- pwg_unset_session_var('filter_recent_period');
pwg_unset_session_var('filter_categories');
pwg_unset_session_var('filter_visible_categories');
pwg_unset_session_var('filter_visible_images');