aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authornikrou <nikrou@piwigo.org>2010-06-24 18:42:39 +0000
committernikrou <nikrou@piwigo.org>2010-06-24 18:42:39 +0000
commit3aaa5b2dfd3434e62d4116cba48853c8293a7f78 (patch)
treee18b4c8c4f521f9c650f06421c67c528e0c1bbce /include
parente1ecc62b8388a6739acc37077d503e7e570cdbbb (diff)
Bug 1736 fixed : Complete RSS Feed returns error
start or end dates can be null git-svn-id: http://piwigo.org/svn/trunk@6597 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r--include/functions_notification.inc.php76
1 files changed, 57 insertions, 19 deletions
diff --git a/include/functions_notification.inc.php b/include/functions_notification.inc.php
index 9a5afe762..edffe9f99 100644
--- a/include/functions_notification.inc.php
+++ b/include/functions_notification.inc.php
@@ -71,40 +71,78 @@ function custom_notification_query($action, $type, $start, $end)
$query = '
FROM '.COMMENTS_TABLE.' AS c
, '.IMAGE_CATEGORY_TABLE.' AS ic
- WHERE c.image_id = ic.image_id
- AND c.validation_date > \''.$start.'\'
- AND c.validation_date <= \''.$end.'\'
- '.get_std_sql_where_restrict_filter('AND').'
+ WHERE c.image_id = ic.image_id';
+ if (!empty($start))
+ {
+ $query .= '
+ AND c.validation_date > \''.$start.'\'';
+ }
+ if (!empty($end))
+ {
+ $query .= '
+ AND c.validation_date <= \''.$end.'\'';
+ }
+ $query .= get_std_sql_where_restrict_filter('AND').'
;';
break;
case 'unvalidated_comments':
$query = '
FROM '.COMMENTS_TABLE.'
- WHERE date> \''.$start.'\' AND date <= \''.$end.'\'
- AND validated = \'false\'
+ WHERE 1=1';
+ if (!empty($start))
+ {
+ $query .= ' AND date> \''.$start.'\'';
+ }
+ if (!empty($end))
+ {
+ $query .= ' AND date <= \''.$end.'\'';
+ }
+ $query .= ' AND validated = \'false\'
;';
break;
case 'new_elements':
$query = '
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = id
- WHERE date_available > \''.$start.'\'
- AND date_available <= \''.$end.'\'
- '.get_std_sql_where_restrict_filter('AND', 'id').'
+ WHERE 1=1';
+ if (!empty($start))
+ {
+ $query .= ' AND date_available > \''.$start.'\'';
+ }
+ if (!empty($end))
+ {
+ $query .= ' AND date_available <= \''.$end.'\'';
+ }
+ $query .= get_std_sql_where_restrict_filter('AND', 'id').'
;';
break;
case 'updated_categories':
$query = '
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = id
- WHERE date_available > \''.$start.'\'
- AND date_available <= \''.$end.'\'
- '.get_std_sql_where_restrict_filter('AND', 'id').'
+ WHERE 1=1';
+ if (!empty($start))
+ {
+ $query .= ' AND date_available > \''.$start.'\'';
+ }
+ if (!empty($end))
+ {
+ $query .= ' AND date_available <= \''.$end.'\'';
+ }
+ $query .= get_std_sql_where_restrict_filter('AND', 'id').'
;';
break;
case 'new_users':
$query = '
FROM '.USER_INFOS_TABLE.'
- WHERE registration_date > \''.$start.'\'
- AND registration_date <= \''.$end.'\'
+ WHERE 1=1';
+ if (!empty($start))
+ {
+ $query .= ' AND registration_date > \''.$start.'\'';
+ }
+ if (!empty($end))
+ {
+ $query .= ' AND registration_date <= \''.$end.'\'';
+ }
+ $query .= '
;';
break;
case 'waiting_elements':
@@ -458,10 +496,10 @@ SELECT date_available,
if ($max_elements>0)
{ // get some thumbnails ...
$query = '
-SELECT DISTINCT id, path, name, tn_ext, file
+SELECT id, path, name, tn_ext, file
FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=image_id
'.$where_sql.'
- AND date_available="'.$dates[$i]['date_available'].'"
+ AND date_available=\''.$dates[$i]['date_available'].'\'
AND tn_ext IS NOT NULL
ORDER BY '.DB_RANDOM_FUNCTION.'()
LIMIT '.$max_elements.'
@@ -477,12 +515,12 @@ SELECT DISTINCT id, path, name, tn_ext, file
if ($max_cats>0)
{// get some categories ...
$query = '
-SELECT DISTINCT c.uppercats, COUNT(DISTINCT i.id) img_count
+SELECT c.uppercats, COUNT(DISTINCT i.id) img_count
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'].'"
- GROUP BY category_id
+ AND date_available=\''.$dates[$i]['date_available'].'\'
+ GROUP BY category_id, c.uppercats
ORDER BY img_count DESC
LIMIT '.$max_cats.'
;';