diff options
author | rvelices <rv-github@modusoptimus.com> | 2008-07-22 10:32:25 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2008-07-22 10:32:25 +0000 |
commit | 4322abb39fe8672ba0179e9a460a73ae65fdfffc (patch) | |
tree | a88acf5edd7291cb926c60ecf796b5e7b3f8e0f4 /include/filter.inc.php | |
parent | ecc5ee46fa3caf6622a4cccae3870a950fb0a969 (diff) |
- add #user_cache.cache_update_time - useful for plugins or the filter when it is not possible/desirable to cache/calculate data specific to the user when pwg core does it; note that this opens the possibility to implement a data cache (file/shared mem/ etc...) for every user (for very large databases)
git-svn-id: http://piwigo.org/svn/trunk@2448 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/filter.inc.php')
-rw-r--r-- | include/filter.inc.php | 26 |
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'); |