Ignore:
Timestamp:
Nov 15, 2011, 12:58:10 PM (12 years ago)
Author:
plg
Message:

merge r12629 from branch 2.3 to trunk

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"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_tag.inc.php

    r12118 r12630  
    167167 * @return array
    168168 */
    169 function get_image_ids_for_tags($tag_ids, $mode='AND', $extra_images_where_sql='', $order_by='')
     169function get_image_ids_for_tags($tag_ids, $mode='AND', $extra_images_where_sql='', $order_by='', $use_permissions=true)
    170170{
    171171  global $conf;
     
    176176
    177177  $query = 'SELECT id
    178   FROM '.IMAGES_TABLE.' i
    179     INNER JOIN '.IMAGE_CATEGORY_TABLE.' ic ON id=ic.image_id
     178  FROM '.IMAGES_TABLE.' i ';
     179
     180  if ($use_permissions)
     181  {
     182    $query.= '
     183    INNER JOIN '.IMAGE_CATEGORY_TABLE.' ic ON id=ic.image_id';
     184  }
     185
     186  $query.= '
    180187    INNER JOIN '.IMAGE_TAG_TABLE.' it ON id=it.image_id
    181     WHERE tag_id IN ('.implode(',', $tag_ids).')'
    182     .get_sql_condition_FandF
    183     (
    184       array
    185         (
    186           'forbidden_categories' => 'category_id',
    187           'visible_categories' => 'category_id',
    188           'visible_images' => 'id'
     188    WHERE tag_id IN ('.implode(',', $tag_ids).')';
     189
     190  if ($use_permissions)
     191  {
     192    $query.= get_sql_condition_FandF(
     193      array(
     194        'forbidden_categories' => 'category_id',
     195        'visible_categories' => 'category_id',
     196        'visible_images' => 'id'
    189197        ),
    190198      "\n  AND"
    191     )
    192   .(empty($extra_images_where_sql) ? '' : " \nAND (".$extra_images_where_sql.')')
    193   .'
     199      );
     200  }
     201
     202  $query.= (empty($extra_images_where_sql) ? '' : " \nAND (".$extra_images_where_sql.')').'
    194203  GROUP BY id';
    195204 
Note: See TracChangeset for help on using the changeset viewer.