mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-05 08:22:35 +02:00
Added filters according to global mode
This commit is contained in:
@@ -96,6 +96,40 @@ SELECT id, date_creation
|
||||
invalidate_user_cache();
|
||||
}
|
||||
|
||||
//collection
|
||||
$collection = array();
|
||||
if (isset($_POST['nb_photos_deleted']))
|
||||
{
|
||||
check_input_parameter('nb_photos_deleted', $_POST, false, '/^\d+$/');
|
||||
|
||||
// let's fake a collection (we don't know the image_ids so we use "null", we only
|
||||
// care about the number of items here)
|
||||
$collection = array_fill(0, $_POST['nb_photos_deleted'], null);
|
||||
}
|
||||
else if (isset($_POST['setSelected']))
|
||||
{
|
||||
// Here we don't use check_input_parameter because preg_match has a limit in
|
||||
// the repetitive pattern. Found a limit to 3276 but may depend on memory.
|
||||
//
|
||||
// check_input_parameter('whole_set', $_POST, false, '/^\d+(,\d+)*$/');
|
||||
//
|
||||
// Instead, let's break the input parameter into pieces and check pieces one by one.
|
||||
$collection = explode(',', $_POST['whole_set']);
|
||||
|
||||
foreach ($collection as $id)
|
||||
{
|
||||
if (!preg_match('/^\d+$/', $id))
|
||||
{
|
||||
fatal_error('[Hacking attempt] the input parameter "whole_set" is not valid');
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isset($_POST['selection']))
|
||||
{
|
||||
$collection = $_POST['selection'];
|
||||
}
|
||||
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | template init |
|
||||
// +-----------------------------------------------------------------------+
|
||||
@@ -108,12 +142,127 @@ $base_url = PHPWG_ROOT_PATH.'admin.php';
|
||||
$template->assign(
|
||||
array(
|
||||
'U_ELEMENTS_PAGE' => $base_url.get_query_string_diff(array('display','start')),
|
||||
'F_ACTION' => $base_url.get_query_string_diff(array()),
|
||||
'level_options' => get_privacy_level_options(),
|
||||
'ADMIN_PAGE_TITLE' => l10n('Batch Manager'),
|
||||
'PWG_TOKEN' => get_pwg_token(),
|
||||
)
|
||||
);
|
||||
//prefilter
|
||||
$prefilters = array(
|
||||
array('ID' => 'caddie', 'NAME' => l10n('Caddie')),
|
||||
array('ID' => 'favorites', 'NAME' => l10n('Your favorites')),
|
||||
array('ID' => 'last_import', 'NAME' => l10n('Last import')),
|
||||
array('ID' => 'no_album', 'NAME' => l10n('With no album').' ('.l10n('Orphans').')'),
|
||||
array('ID' => 'no_tag', 'NAME' => l10n('With no tag')),
|
||||
array('ID' => 'duplicates', 'NAME' => l10n('Duplicates')),
|
||||
array('ID' => 'all_photos', 'NAME' => l10n('All'))
|
||||
);
|
||||
|
||||
if ($conf['enable_synchronization'])
|
||||
{
|
||||
$prefilters[] = array('ID' => 'no_virtual_album', 'NAME' => l10n('With no virtual album'));
|
||||
$prefilters[] = array('ID' => 'no_sync_md5sum', 'NAME' => l10n('With no checksum'));
|
||||
}
|
||||
|
||||
function UC_name_compare($a, $b)
|
||||
{
|
||||
return strcmp(strtolower($a['NAME']), strtolower($b['NAME']));
|
||||
}
|
||||
|
||||
$prefilters = trigger_change('get_batch_manager_prefilters', $prefilters);
|
||||
|
||||
// Sort prefilters by localized name.
|
||||
usort($prefilters, function ($a, $b) {
|
||||
return strcmp(strtolower($a['NAME']), strtolower($b['NAME']));
|
||||
});
|
||||
|
||||
$template->assign(
|
||||
array(
|
||||
'conf_checksum_compute_blocksize' => $conf['checksum_compute_blocksize'],
|
||||
'prefilters' => $prefilters,
|
||||
'filter' => $_SESSION['bulk_manager_filter'],
|
||||
'selection' => $collection,
|
||||
'all_elements' => $page['cat_elements_id'],
|
||||
'START' => $page['start'],
|
||||
'U_DISPLAY'=>$base_url.get_query_string_diff(array('display')),
|
||||
'F_ACTION'=>$base_url.get_query_string_diff(array('cat','start','tag','filter')),
|
||||
)
|
||||
);
|
||||
|
||||
if (isset($page['no_md5sum_number']))
|
||||
{
|
||||
$template->assign(
|
||||
array(
|
||||
'NB_NO_MD5SUM' => $page['no_md5sum_number'],
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$template->assign('NB_NO_MD5SUM', '');
|
||||
}
|
||||
|
||||
|
||||
// privacy level
|
||||
foreach ($conf['available_permission_levels'] as $level)
|
||||
{
|
||||
$level_options[$level] = l10n(sprintf('Level %d', $level));
|
||||
|
||||
if (0 == $level)
|
||||
{
|
||||
$level_options[$level] = l10n('Everybody');
|
||||
}
|
||||
}
|
||||
$template->assign(
|
||||
array(
|
||||
'filter_level_options'=> $level_options,
|
||||
'filter_level_options_selected' => isset($_SESSION['bulk_manager_filter']['level'])
|
||||
? $_SESSION['bulk_manager_filter']['level']
|
||||
: 0,
|
||||
)
|
||||
);
|
||||
|
||||
// tags
|
||||
$filter_tags = array();
|
||||
|
||||
if (!empty($_SESSION['bulk_manager_filter']['tags']))
|
||||
{
|
||||
$query = '
|
||||
SELECT
|
||||
id,
|
||||
name
|
||||
FROM '.TAGS_TABLE.'
|
||||
WHERE id IN ('.implode(',', $_SESSION['bulk_manager_filter']['tags']).')
|
||||
;';
|
||||
|
||||
$filter_tags = get_taglist($query);
|
||||
}
|
||||
|
||||
$template->assign('filter_tags', $filter_tags);
|
||||
|
||||
// in the filter box, which category to select by default
|
||||
$selected_category = array();
|
||||
|
||||
if (isset($_SESSION['bulk_manager_filter']['category']))
|
||||
{
|
||||
$selected_category = array($_SESSION['bulk_manager_filter']['category']);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we need to know the category in which the last photo was added
|
||||
$query = '
|
||||
SELECT category_id
|
||||
FROM '.IMAGE_CATEGORY_TABLE.'
|
||||
ORDER BY image_id DESC
|
||||
LIMIT 1
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
if (pwg_db_num_rows($result) > 0)
|
||||
{
|
||||
$row = pwg_db_fetch_assoc($result);
|
||||
$selected_category[] = $row['category_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('filter_category_selected', $selected_category);
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | global mode thumbnails |
|
||||
|
||||
Reference in New Issue
Block a user