aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to 'admin')
-rw-r--r--admin/batch_manager.php122
-rw-r--r--admin/batch_manager_global.php22
-rw-r--r--admin/cat_list.php2
-rw-r--r--admin/cat_modify.php2
-rw-r--r--admin/photos_add_direct.php2
-rw-r--r--admin/tags.php2
6 files changed, 86 insertions, 66 deletions
diff --git a/admin/batch_manager.php b/admin/batch_manager.php
index 31fb46c00..89fac392d 100644
--- a/admin/batch_manager.php
+++ b/admin/batch_manager.php
@@ -43,10 +43,12 @@ check_status(ACCESS_ADMINISTRATOR);
check_input_parameter('selection', $_POST, true, PATTERN_ID);
+
// +-----------------------------------------------------------------------+
// | initialize current set |
// +-----------------------------------------------------------------------+
+// filters from form
if (isset($_POST['submitFilter']))
{
// echo '<pre>'; print_r($_POST); echo '</pre>';
@@ -109,39 +111,52 @@ if (isset($_POST['submitFilter']))
}
}
}
-else if (isset($_GET['cat']))
+// filters from url
+else if (isset($_GET['filter']))
{
- if ('caddie' == $_GET['cat'])
- {
- $_SESSION['bulk_manager_filter'] = array(
- 'prefilter' => 'caddie'
- );
- }
- else if ('recent' == $_GET['cat'])
+ if (!is_array($_GET['filter']))
{
- $_SESSION['bulk_manager_filter'] = array(
- 'prefilter' => 'last import'
- );
+ $_GET['filter'] = explode(',', $_GET['filter']);
}
- else if (is_numeric($_GET['cat']))
- {
- $_SESSION['bulk_manager_filter'] = array(
- 'category' => $_GET['cat']
- );
- }
-}
-else if (isset($_GET['tag']))
-{
- if (is_numeric($_GET['tag']))
+
+ $_SESSION['bulk_manager_filter'] = array();
+
+ foreach ($_GET['filter'] as $filter)
{
- $_SESSION['bulk_manager_filter'] = array(
- 'tags' => array($_GET['tag']),
- 'tag_mode' => 'AND',
- );
+ list($type, $value) = explode('-', $filter);
+
+ switch ($type)
+ {
+ case 'prefilter':
+ $_SESSION['bulk_manager_filter']['prefilter'] = $value;
+ break;
+
+ case 'album':
+ if (is_numeric($value))
+ {
+ $_SESSION['bulk_manager_filter']['category'] = $value;
+ }
+ break;
+
+ case 'tag':
+ if (is_numeric($value))
+ {
+ $_SESSION['bulk_manager_filter']['tags'] = array($value);
+ $_SESSION['bulk_manager_filter']['tag_mode'] = 'AND';
+ }
+ break;
+
+ case 'level':
+ if (is_numeric($value) && in_array($value, $conf['available_permission_levels']))
+ {
+ $_SESSION['bulk_manager_filter']['level'] = $value;
+ }
+ break;
+ }
}
}
-if (!isset($_SESSION['bulk_manager_filter']))
+if (empty($_SESSION['bulk_manager_filter']))
{
$_SESSION['bulk_manager_filter'] = array(
'prefilter' => 'caddie'
@@ -150,13 +165,13 @@ if (!isset($_SESSION['bulk_manager_filter']))
// echo '<pre>'; print_r($_SESSION['bulk_manager_filter']); echo '</pre>';
-// depending on the current filter (in session), we find the appropriate
-// photos
+// depending on the current filter (in session), we find the appropriate photos
$filter_sets = array();
if (isset($_SESSION['bulk_manager_filter']['prefilter']))
{
- if ('caddie' == $_SESSION['bulk_manager_filter']['prefilter'])
+ switch ($_SESSION['bulk_manager_filter']['prefilter'])
{
+ case 'caddie':
$query = '
SELECT element_id
FROM '.CADDIE_TABLE.'
@@ -166,10 +181,10 @@ SELECT element_id
$filter_sets,
array_from_query($query, 'element_id')
);
- }
+
+ break;
- if ('favorites' == $_SESSION['bulk_manager_filter']['prefilter'])
- {
+ case 'favorites':
$query = '
SELECT image_id
FROM '.FAVORITES_TABLE.'
@@ -179,10 +194,10 @@ SELECT image_id
$filter_sets,
array_from_query($query, 'image_id')
);
- }
+
+ break;
- if ('last import'== $_SESSION['bulk_manager_filter']['prefilter'])
- {
+ case 'last_import':
$query = '
SELECT MAX(date_available) AS date
FROM '.IMAGES_TABLE.'
@@ -200,10 +215,10 @@ SELECT id
array_from_query($query, 'id')
);
}
- }
+
+ break;
- if ('with no virtual album' == $_SESSION['bulk_manager_filter']['prefilter'])
- {
+ case 'no_virtual_album':
// we are searching elements not linked to any virtual category
$query = '
SELECT id
@@ -231,10 +246,10 @@ SELECT id
$filter_sets,
array_diff($all_elements, $linked_to_virtual)
);
- }
+
+ break;
- if ('with no album' == $_SESSION['bulk_manager_filter']['prefilter'])
- {
+ case 'no_album':
$query = '
SELECT
id
@@ -246,10 +261,10 @@ SELECT
$filter_sets,
array_from_query($query, 'id')
);
- }
+
+ break;
- if ('with no tag' == $_SESSION['bulk_manager_filter']['prefilter'])
- {
+ case 'no_tag':
$query = '
SELECT
id
@@ -261,15 +276,14 @@ SELECT
$filter_sets,
array_from_query($query, 'id')
);
- }
+
+ break;
- if ('duplicates' == $_SESSION['bulk_manager_filter']['prefilter'])
- {
+ case 'duplicates':
// we could use the group_concat MySQL function to retrieve the list of
// image_ids but it would not be compatible with PostgreSQL, so let's
// perform 2 queries instead. We hope there are not too many duplicates.
-
$query = '
SELECT file
FROM '.IMAGES_TABLE.'
@@ -288,16 +302,18 @@ SELECT id
$filter_sets,
array_from_query($query, 'id')
);
- }
+
+ break;
- if ('all photos' == $_SESSION['bulk_manager_filter']['prefilter'])
- {
+ case 'all_photos':
$query = '
SELECT id
FROM '.IMAGES_TABLE.'
'.$conf['order_by'];
$filter_sets[] = array_from_query($query, 'id');
+
+ break;
}
$filter_sets = trigger_event('perform_batch_manager_prefilters', $filter_sets, $_SESSION['bulk_manager_filter']['prefilter']);
@@ -403,6 +419,7 @@ foreach ($filter_sets as $set)
}
$page['cat_elements_id'] = $current_set;
+
// +-----------------------------------------------------------------------+
// | first element to display |
// +-----------------------------------------------------------------------+
@@ -423,6 +440,7 @@ else
$page['start'] = $_REQUEST['start'];
}
+
// +-----------------------------------------------------------------------+
// | Tabs |
// +-----------------------------------------------------------------------+
@@ -442,6 +460,7 @@ $tabsheet->set_id('batch_manager');
$tabsheet->select($page['tab']);
$tabsheet->assign();
+
// +-----------------------------------------------------------------------+
// | tags |
// +-----------------------------------------------------------------------+
@@ -452,6 +471,7 @@ SELECT id, name
;';
$template->assign('tags', get_taglist($query, false));
+
// +-----------------------------------------------------------------------+
// | dimensions |
// +-----------------------------------------------------------------------+
diff --git a/admin/batch_manager_global.php b/admin/batch_manager_global.php
index f4ff53ed7..b64324b2d 100644
--- a/admin/batch_manager_global.php
+++ b/admin/batch_manager_global.php
@@ -112,7 +112,7 @@ DELETE
$tag_ids = get_tag_ids($_POST['add_tags']);
add_tags($tag_ids, $collection);
- if ('with no tag' == $page['prefilter'])
+ if ('no_tag' == $page['prefilter'])
{
redirect($redirect_url);
}
@@ -149,12 +149,12 @@ DELETE
);
// let's refresh the page because we the current set might be modified
- if ('with no album' == $page['prefilter'])
+ if ('no_album' == $page['prefilter'])
{
redirect($redirect_url);
}
- if ('with no virtual album' == $page['prefilter'])
+ if ('no_virtual_album' == $page['prefilter'])
{
$category_info = get_cat_info($_POST['associate']);
if (empty($category_info['dir']))
@@ -173,12 +173,12 @@ DELETE
);
// let's refresh the page because we the current set might be modified
- if ('with no album' == $page['prefilter'])
+ if ('no_album' == $page['prefilter'])
{
redirect($redirect_url);
}
- if ('with no virtual album' == $page['prefilter'])
+ if ('no_virtual_album' == $page['prefilter'])
{
$category_info = get_cat_info($_POST['move']);
if (empty($category_info['dir']))
@@ -435,17 +435,17 @@ $base_url = get_root_url().'admin.php';
$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' => 'with no album', 'NAME' => l10n('With no album')),
- array('ID' => 'with no tag', 'NAME' => l10n('With no tag')),
+ array('ID' => 'last_import', 'NAME' => l10n('Last import')),
+ array('ID' => 'no_album', 'NAME' => l10n('With no album')),
+ array('ID' => 'no_tag', 'NAME' => l10n('With no tag')),
array('ID' => 'duplicates', 'NAME' => l10n('Duplicates')),
- array('ID' => 'all photos', 'NAME' => l10n('All'))
+ array('ID' => 'all_photos', 'NAME' => l10n('All'))
);
if ($conf['enable_synchronization'])
{
array_push($prefilters,
- array('ID' => 'with no virtual album', 'NAME' => l10n('With no virtual album'))
+ array('ID' => 'no_virtual_album', 'NAME' => l10n('With no virtual album'))
);
}
@@ -460,7 +460,7 @@ $template->assign(
'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')),
+ 'F_ACTION'=>$base_url.get_query_string_diff(array('cat','start','tag','filter')),
)
);
diff --git a/admin/cat_list.php b/admin/cat_list.php
index be359e5be..383e4d7f4 100644
--- a/admin/cat_list.php
+++ b/admin/cat_list.php
@@ -322,7 +322,7 @@ foreach ($categories as $category)
if ( array_key_exists($category['id'], $categories_with_images) )
{
$tpl_cat['U_MANAGE_ELEMENTS']=
- $base_url.'batch_manager&amp;cat='.$category['id'];
+ $base_url.'batch_manager&amp;filter=album-'.$category['id'];
}
$template->append('categories', $tpl_cat);
diff --git a/admin/cat_modify.php b/admin/cat_modify.php
index ff05946d9..1f83f1f3e 100644
--- a/admin/cat_modify.php
+++ b/admin/cat_modify.php
@@ -252,7 +252,7 @@ if ($category['has_images'])
{
$template->assign(
'U_MANAGE_ELEMENTS',
- $base_url.'batch_manager&amp;cat='.$category['id']
+ $base_url.'batch_manager&amp;filter=album-'.$category['id']
);
$query = '
diff --git a/admin/photos_add_direct.php b/admin/photos_add_direct.php
index 352c27aa2..c9374d5b9 100644
--- a/admin/photos_add_direct.php
+++ b/admin/photos_add_direct.php
@@ -57,7 +57,7 @@ DELETE FROM '.CADDIE_TABLE.'
$inserts
);
- redirect(get_root_url().'admin.php?page=batch_manager&cat=caddie');
+ redirect(get_root_url().'admin.php?page=batch_manager&filter=prefilter-caddie');
}
// +-----------------------------------------------------------------------+
diff --git a/admin/tags.php b/admin/tags.php
index 008bba667..5da902840 100644
--- a/admin/tags.php
+++ b/admin/tags.php
@@ -461,7 +461,7 @@ while ($tag = pwg_db_fetch_assoc($result))
$tag['name'] = trigger_event('render_tag_name', $raw_name);
$tag['counter'] = intval(@$tag_counters[ $tag['id'] ]);
$tag['U_VIEW'] = make_index_url(array('tags'=>array($tag)));
- $tag['U_EDIT'] = 'admin.php?page=batch_manager&amp;tag='.$tag['id'];
+ $tag['U_EDIT'] = 'admin.php?page=batch_manager&amp;filter=tag-'.$tag['id'];
$alt_names = trigger_event('get_tag_alt_names', array(), $raw_name);
$alt_names = array_diff( array_unique($alt_names), array($tag['name']) );