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
This commit is contained in:
parent
836df22920
commit
bc16508161
3 changed files with 49 additions and 33 deletions
|
@ -71,6 +71,11 @@ if (isset($_POST['submitFilter']))
|
|||
if (isset($_POST['filter_tags_use']))
|
||||
{
|
||||
$_SESSION['bulk_manager_filter']['tags'] = get_tag_ids($_POST['filter_tags'], false);
|
||||
|
||||
if (isset($_POST['tag_mode']) and in_array($_POST['tag_mode'], array('AND', 'OR')))
|
||||
{
|
||||
$_SESSION['bulk_manager_filter']['tag_mode'] = $_POST['tag_mode'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['filter_level_use']))
|
||||
|
@ -297,16 +302,16 @@ SELECT id
|
|||
|
||||
if (!empty($_SESSION['bulk_manager_filter']['tags']))
|
||||
{
|
||||
$query = '
|
||||
SELECT image_id
|
||||
FROM '.IMAGE_TAG_TABLE.
|
||||
'WHERE tag_id IN('.implode(',',$_SESSION['bulk_manager_filter']['tags']).')
|
||||
GROUP BY image_id
|
||||
HAVING COUNT(tag_id)='.count($_SESSION['bulk_manager_filter']['tags']);
|
||||
array_push(
|
||||
array_push(
|
||||
$filter_sets,
|
||||
get_image_ids_for_tags($_SESSION['bulk_manager_filter']['tags'])
|
||||
);
|
||||
get_image_ids_for_tags(
|
||||
$_SESSION['bulk_manager_filter']['tags'],
|
||||
$_SESSION['bulk_manager_filter']['tag_mode'],
|
||||
null,
|
||||
null,
|
||||
false // we don't apply permissions in administration screens
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$current_set = array_shift($filter_sets);
|
||||
|
|
|
@ -480,16 +480,18 @@ jQuery(window).load(function() {
|
|||
</select>
|
||||
<label><input type="checkbox" name="filter_category_recursive" {if isset($filter.category_recursive)}checked="checked"{/if}> {'include child albums'|@translate}</label>
|
||||
</li>
|
||||
<li id="filter_tags" {if !isset($filter.tags)}style="display:none"{/if}>
|
||||
<a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
|
||||
<input type="checkbox" name="filter_tags_use" class="useFilterCheckbox" {if isset($filter.tags)}checked="checked"{/if}>
|
||||
{'Tags'|@translate}
|
||||
<select id="tagsFilter" name="filter_tags">
|
||||
{foreach from=$filter_tags item=tag}
|
||||
<option value="{$tag.id}">{$tag.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</li>
|
||||
<li id="filter_tags" {if !isset($filter.tags)}style="display:none"{/if}>
|
||||
<a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
|
||||
<input type="checkbox" name="filter_tags_use" class="useFilterCheckbox" {if isset($filter.tags)}checked="checked"{/if}>
|
||||
{'Tags'|@translate}
|
||||
<select id="tagsFilter" name="filter_tags">
|
||||
{foreach from=$filter_tags item=tag}
|
||||
<option value="{$tag.id}">{$tag.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<label><span><input type="radio" name="tag_mode" value="AND" {if !isset($filter.tag_mode) or $filter.tag_mode eq 'AND'}checked="checked"{/if}> {'All tags'|@translate}</span></label>
|
||||
<label><span><input type="radio" name="tag_mode" value="OR" {if isset($filter.tag_mode) and $filter.tag_mode eq 'OR'}checked="checked"{/if}> {'Any tag'|@translate}</span></label>
|
||||
</li>
|
||||
<li id="filter_level" {if !isset($filter.level)}style="display:none"{/if}>
|
||||
<a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
|
||||
<input type="checkbox" name="filter_level_use" class="useFilterCheckbox" {if isset($filter.level)}checked="checked"{/if}>
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue