diff options
author | plegall <plg@piwigo.org> | 2011-11-15 11:48:37 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2011-11-15 11:48:37 +0000 |
commit | bc1650816156f7d778d03c81923474fd66f445b3 (patch) | |
tree | 7765ab72fb17da9e9cffacfbdfb96d8d6f2dbc99 /include/functions_tag.inc.php | |
parent | 836df2292003bc2f42a6a511738f7afd0e90c9c6 (diff) |
bug 2506 fixed: Batch Manager does not take permissions into account when
filtering on tags
feature 2507 added: Batch Manager can filter on "all tags" or "any tag"
git-svn-id: http://piwigo.org/svn/branches/2.3@12629 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions_tag.inc.php')
-rw-r--r-- | include/functions_tag.inc.php | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/include/functions_tag.inc.php b/include/functions_tag.inc.php index 9f93115fd..3bc6d0ff1 100644 --- a/include/functions_tag.inc.php +++ b/include/functions_tag.inc.php @@ -166,7 +166,7 @@ function add_level_to_tags($tags) * @param string order_by - optionally overwrite default photo order * @return array */ -function get_image_ids_for_tags($tag_ids, $mode='AND', $extra_images_where_sql='', $order_by='') +function get_image_ids_for_tags($tag_ids, $mode='AND', $extra_images_where_sql='', $order_by='', $use_permissions=true) { global $conf; if (empty($tag_ids)) @@ -175,22 +175,31 @@ function get_image_ids_for_tags($tag_ids, $mode='AND', $extra_images_where_sql=' } $query = 'SELECT id - FROM '.IMAGES_TABLE.' i - INNER JOIN '.IMAGE_CATEGORY_TABLE.' ic ON id=ic.image_id + FROM '.IMAGES_TABLE.' i '; + + if ($use_permissions) + { + $query.= ' + INNER JOIN '.IMAGE_CATEGORY_TABLE.' ic ON id=ic.image_id'; + } + + $query.= ' INNER JOIN '.IMAGE_TAG_TABLE.' it ON id=it.image_id - WHERE tag_id IN ('.implode(',', $tag_ids).')' - .get_sql_condition_FandF - ( - array - ( - 'forbidden_categories' => 'category_id', - 'visible_categories' => 'category_id', - 'visible_images' => 'id' + WHERE tag_id IN ('.implode(',', $tag_ids).')'; + + if ($use_permissions) + { + $query.= get_sql_condition_FandF( + array( + 'forbidden_categories' => 'category_id', + 'visible_categories' => 'category_id', + 'visible_images' => 'id' ), "\n AND" - ) - .(empty($extra_images_where_sql) ? '' : " \nAND (".$extra_images_where_sql.')') - .' + ); + } + + $query.= (empty($extra_images_where_sql) ? '' : " \nAND (".$extra_images_where_sql.')').' GROUP BY id'; if ($mode=='AND' and count($tag_ids)>1) |