Index: /branches/2.2/admin/batch_manager.php
===================================================================
--- /branches/2.2/admin/batch_manager.php	(revision 11853)
+++ /branches/2.2/admin/batch_manager.php	(revision 11854)
@@ -67,4 +67,9 @@
       $_SESSION['bulk_manager_filter']['category_recursive'] = true;
     }
+  }
+
+  if (isset($_POST['filter_tags_use']))
+  {
+    $_SESSION['bulk_manager_filter']['tags'] = get_tag_ids($_POST['filter_tags'], false);
   }
 
@@ -291,4 +296,18 @@
 }
 
+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(
+    $filter_sets,
+		get_image_ids_for_tags($_SESSION['bulk_manager_filter']['tags'])
+		);
+}
+
 $current_set = array_shift($filter_sets);
 foreach ($filter_sets as $set)
@@ -366,7 +385,5 @@
 
 $query = '
-SELECT
-    id AS tag_id,
-    name AS tag_name
+SELECT id, name
   FROM '.TAGS_TABLE.'
 ;';
Index: /branches/2.2/admin/batch_manager_global.php
===================================================================
--- /branches/2.2/admin/batch_manager_global.php	(revision 11853)
+++ /branches/2.2/admin/batch_manager_global.php	(revision 11854)
@@ -486,4 +486,13 @@
     )
   );
+
+if (!empty($_SESSION['bulk_manager_filter']['tags']))
+{
+	$query = '
+SELECT id, name
+	FROM '.TAGS_TABLE.'
+	WHERE id IN ('.implode(',', $_SESSION['bulk_manager_filter']['tags']).')';
+	$template->assign('filter_tags', get_taglist($query));
+}
 
 // Virtualy associate a picture to a category
Index: /branches/2.2/admin/batch_manager_unit.php
===================================================================
--- /branches/2.2/admin/batch_manager_unit.php	(revision 11853)
+++ /branches/2.2/admin/batch_manager_unit.php	(revision 11854)
@@ -252,6 +252,6 @@
     $query = '
 SELECT
-    tag_id,
-    name AS tag_name
+    id,
+    name
   FROM '.IMAGE_TAG_TABLE.' AS it
     JOIN '.TAGS_TABLE.' AS t ON t.id = it.tag_id
Index: /branches/2.2/admin/include/functions.php
===================================================================
--- /branches/2.2/admin/include/functions.php	(revision 11853)
+++ /branches/2.2/admin/include/functions.php	(revision 11854)
@@ -2116,6 +2116,6 @@
       $taglist,
       array(
-        'name' => $row['tag_name'],
-        'id' => '~~'.$row['tag_id'].'~~',
+        'name' => $row['name'],
+        'id' => '~~'.$row['id'].'~~',
         )
       );
@@ -2128,5 +2128,5 @@
 }
 
-function get_tag_ids($raw_tags)
+function get_tag_ids($raw_tags, $allow_create=true)
 {
   // In $raw_tags we receive something like array('~~6~~', '~~59~~', 'New
@@ -2144,11 +2144,8 @@
       array_push($tag_ids, $matches[1]);
     }
-    else
+    elseif ($allow_create)
     {
       // we have to create a new tag
-      array_push(
-        $tag_ids,
-        tag_id_from_tag_name($raw_tag)
-        );
+      $tag_ids[] = tag_id_from_tag_name($raw_tag);
     }
   }
Index: /branches/2.2/admin/picture_modify.php
===================================================================
--- /branches/2.2/admin/picture_modify.php	(revision 11853)
+++ /branches/2.2/admin/picture_modify.php	(revision 11854)
@@ -228,6 +228,6 @@
 $query = '
 SELECT
-    tag_id,
-    name AS tag_name
+    id,
+    name
   FROM '.IMAGE_TAG_TABLE.' AS it
     JOIN '.TAGS_TABLE.' AS t ON t.id = it.tag_id
@@ -238,6 +238,6 @@
 $query = '
 SELECT
-    id AS tag_id,
-    name AS tag_name
+    id,
+    name
   FROM '.TAGS_TABLE.'
 ;';
Index: /branches/2.2/admin/themes/default/template/batch_manager_global.tpl
===================================================================
--- /branches/2.2/admin/themes/default/template/batch_manager_global.tpl	(revision 11853)
+++ /branches/2.2/admin/themes/default/template/batch_manager_global.tpl	(revision 11854)
@@ -10,6 +10,7 @@
 {footer_script require='jquery.tokeninput'}
 jQuery(document).ready(function() {ldelim}
+	var tag_src = [{foreach from=$tags item=tag name=tags}{ldelim}name:"{$tag.name|@escape:'javascript'}",id:"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}];
   jQuery("#tags").tokenInput(
-    [{foreach from=$tags item=tag name=tags}{ldelim}"name":"{$tag.name|@escape:'javascript'}","id":"{$tag.id}"{rdelim}{if !$smarty.foreach.tags.last},{/if}{/foreach}],
+    tag_src,
     {ldelim}
       hintText: '{'Type in a search term'|@translate}',
@@ -22,4 +23,17 @@
     }
   );
+	
+  jQuery("#tagsFilter").tokenInput(
+    tag_src,
+    {ldelim}
+      hintText: '{'Type in a search term'|@translate}',
+      noResultsText: '{'No results'|@translate}',
+      searchingText: '{'Searching...'|@translate}',
+      animateDropdown: false,
+      preventDuplicates: true,
+      allowCreation: false
+    }
+  );
+
 });
 {/footer_script}
@@ -347,4 +361,14 @@
         <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_level" {if !isset($filter.level)}style="display:none"{/if}>
         <a href="#" class="removeFilter" title="remove this filter"><span>[x]</span></a>
@@ -363,4 +387,5 @@
         <option value="filter_prefilter">{'predefined filter'|@translate}</option>
         <option value="filter_category">{'album'|@translate}</option>
+				<option value="filter_tags">{'Tags'|@translate}</option>
         <option value="filter_level">{'Who can see these photos?'|@translate}</option>
       </select>
