diff options
author | rvelices <rv-github@modusoptimus.com> | 2014-04-05 19:24:27 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2014-04-05 19:24:27 +0000 |
commit | 1f3f5ff73f505cbc6041ae213398d240f61d5a60 (patch) | |
tree | 5d80de6ffec34d3315051994f2187de5fac55883 /include | |
parent | 7a8463579826233d7dc26ec93f3f98c22acaa7ac (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')
-rw-r--r-- | include/functions_search.inc.php | 39 | ||||
-rw-r--r-- | include/ws_functions/pwg.images.php | 36 |
2 files changed, 43 insertions, 32 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) ); } } diff --git a/include/ws_functions/pwg.images.php b/include/ws_functions/pwg.images.php index 6eebd4482..78d1d51d7 100644 --- a/include/ws_functions/pwg.images.php +++ b/include/ws_functions/pwg.images.php @@ -294,7 +294,7 @@ function remove_chunks($original_sum, $type) * @option string content * @option string key */ -function ws_images_addComment($params, &$service) +function ws_images_addComment($params, $service) { $query = ' SELECT DISTINCT image_id @@ -354,7 +354,7 @@ SELECT DISTINCT image_id * @option int comments_page * @option int comments_per_page */ -function ws_images_getInfo($params, &$service) +function ws_images_getInfo($params, $service) { global $user, $conf; @@ -579,7 +579,7 @@ SELECT id, date, author, content * @option int image_id * @option float rate */ -function ws_images_rate($params, &$service) +function ws_images_rate($params, $service) { $query = ' SELECT DISTINCT id @@ -620,7 +620,7 @@ SELECT DISTINCT id * @option int page * @option string order (optional) */ -function ws_images_search($params, &$service) +function ws_images_search($params, $service) { include_once(PHPWG_ROOT_PATH .'include/functions_search.inc.php'); @@ -638,8 +638,10 @@ function ws_images_search($params, &$service) $search_result = get_quick_search_results( $params['query'], - $super_order_by, - implode(' AND ', $where_clauses) + array( + 'super_order_by' => $super_order_by, + 'images_where' => implode(' AND ', $where_clauses) + ) ); $image_ids = array_slice( @@ -704,7 +706,7 @@ SELECT * * @option int image_id * @option int level */ -function ws_images_setPrivacyLevel($params, &$service) +function ws_images_setPrivacyLevel($params, $service) { global $conf; @@ -737,7 +739,7 @@ UPDATE '. IMAGES_TABLE .' * @option int category_id * @option int rank */ -function ws_images_setRank($params, &$service) +function ws_images_setRank($params, $service) { // does the image really exist? $query = ' @@ -820,7 +822,7 @@ UPDATE '. IMAGE_CATEGORY_TABLE .' * @option string type = 'file' * @option int position */ -function ws_images_add_chunk($params, &$service) +function ws_images_add_chunk($params, $service) { global $conf; @@ -877,7 +879,7 @@ function ws_images_add_chunk($params, &$service) * @option string type = 'file' * @option string sum */ -function ws_images_addFile($params, &$service) +function ws_images_addFile($params, $service) { ws_logfile(__FUNCTION__.', input : '.var_export($params, true)); @@ -970,7 +972,7 @@ SELECT * @option bool check_uniqueness * @option int image_id (optional) */ -function ws_images_add($params, &$service) +function ws_images_add($params, $service) { global $conf, $user; @@ -1133,7 +1135,7 @@ SELECT id, name, permalink * @option string|string[] tags * @option int image_id (optional) */ -function ws_images_addSimple($params, &$service) +function ws_images_addSimple($params, $service) { global $conf; @@ -1247,7 +1249,7 @@ SELECT id, name, permalink * @option string md5sum_list (optional) * @option string filename_list (optional) */ -function ws_images_exist($params, &$service) +function ws_images_exist($params, $service) { ws_logfile(__FUNCTION__.' '.var_export($params, true)); @@ -1320,7 +1322,7 @@ SELECT id, file * @option int image_id * @option string file_sum */ -function ws_images_checkFiles($params, &$service) +function ws_images_checkFiles($params, $service) { ws_logfile(__FUNCTION__.', input : '.var_export($params, true)); @@ -1392,7 +1394,7 @@ SELECT path * @option string single_value_mode * @option string multiple_value_mode */ -function ws_images_setInfo($params, &$service) +function ws_images_setInfo($params, $service) { include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); @@ -1528,7 +1530,7 @@ SELECT * * @option int|int[] image_id * @option string pwg_token */ -function ws_images_delete($params, &$service) +function ws_images_delete($params, $service) { if (get_pwg_token() != $params['pwg_token']) { @@ -1565,7 +1567,7 @@ function ws_images_delete($params, &$service) * Checks if Piwigo is ready for upload * @param mixed[] $params */ -function ws_images_checkUpload($params, &$service) +function ws_images_checkUpload($params, $service) { include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); |