aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_search.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2014-04-05 19:24:27 +0000
committerrvelices <rv-github@modusoptimus.com>2014-04-05 19:24:27 +0000
commit1f3f5ff73f505cbc6041ae213398d240f61d5a60 (patch)
tree5d80de6ffec34d3315051994f2187de5fac55883 /include/functions_search.inc.php
parent7a8463579826233d7dc26ec93f3f98c22acaa7ac (diff)
bug 3069: add quick search as filter in batch manager
git-svn-id: http://piwigo.org/svn/trunk@28087 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions_search.inc.php')
-rw-r--r--include/functions_search.inc.php39
1 files changed, 24 insertions, 15 deletions
diff --git a/include/functions_search.inc.php b/include/functions_search.inc.php
index a02e03331..b823bcfaa 100644
--- a/include/functions_search.inc.php
+++ b/include/functions_search.inc.php
@@ -1193,7 +1193,7 @@ function qsearch_eval(QMultiToken $expr, QResults $qsr, &$qualifies, &$ignored_t
* @param string $images_where optional additional restriction on images table
* @return array
*/
-function get_quick_search_results($q, $super_order_by, $images_where='')
+function get_quick_search_results($q, $options)
{
global $conf;
//@TODO: maybe cache for 10 minutes the result set to avoid many expensive sql calls when navigating the pictures
@@ -1254,26 +1254,35 @@ function get_quick_search_results($q, $super_order_by, $images_where='')
return $search_results;
}
+ $permissions = !isset($options['permissions']) ? true : $options['permissions'];
+
$where_clauses = array();
$where_clauses[]='i.id IN ('. implode(',', $ids) . ')';
- if (!empty($images_where))
+ if (!empty($options['images_where'))
{
$where_clauses[]='('.$images_where.')';
}
- $where_clauses[] = get_sql_condition_FandF(
- array
- (
- 'forbidden_categories' => 'category_id',
- 'visible_categories' => 'category_id',
- 'visible_images' => 'i.id'
- ),
- null,true
- );
+ if ($permissions)
+ {
+ $where_clauses[] = get_sql_condition_FandF(
+ array
+ (
+ 'forbidden_categories' => 'category_id',
+ 'visible_categories' => 'category_id',
+ 'visible_images' => 'i.id'
+ ),
+ null,true
+ );
+ }
$query = '
-SELECT DISTINCT(id)
- FROM '.IMAGES_TABLE.' i
- INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
+SELECT DISTINCT(id) FROM '.IMAGES_TABLE.' i';
+ if ($permissions)
+ {
+ $query .= '
+ INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id';
+ }
+ $query .= '
WHERE '.implode("\n AND ", $where_clauses)."\n".
$conf['order_by'];
@@ -1305,7 +1314,7 @@ function get_search_results($search_id, $super_order_by, $images_where='')
}
else
{
- return get_quick_search_results($search['q'], $super_order_by, $images_where);
+ return get_quick_search_results($search['q'], array('super_order_by'=>$super_order_by, 'images_where'=>$images_where) );
}
}