aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_notification.inc.php
diff options
context:
space:
mode:
authorrub <rub@piwigo.org>2006-12-21 21:38:20 +0000
committerrub <rub@piwigo.org>2006-12-21 21:38:20 +0000
commitcab8f98c4ab88a0ad05f2359099c883675319084 (patch)
treea8224615d63c1330fd8744e3abd5195eb5763476 /include/functions_notification.inc.php
parenta7ce26153185c274a08fb52b07402c8afba6f128 (diff)
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 git-svn-id: http://piwigo.org/svn/trunk@1677 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions_notification.inc.php')
-rw-r--r--include/functions_notification.inc.php47
1 files changed, 36 insertions, 11 deletions
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'].'"