Index: privatemsg_filter.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg_filter/privatemsg_filter.module,v
retrieving revision 1.1.2.15
diff -u -r1.1.2.15 privatemsg_filter.module
--- privatemsg_filter.module	22 Apr 2009 02:23:45 -0000	1.1.2.15
+++ privatemsg_filter.module	9 May 2009 18:54:59 -0000
@@ -551,4 +551,37 @@
     }
     drupal_set_message(t('Tagging information has been saved.'));
   }
+}
+
+/**
+ * Implementation of hook_privatemsg_thread_operations().
+ */
+function privatemsg_filter_privatemsg_thread_operations() {
+  global $user;
+  $operations = array();
+  $tags = privatemsg_filter_get_tags_data($user);
+
+  if (!empty($tags)) {
+    $operations['-'] = array(
+      'label' => t('Apply Tag...'),
+    );
+    foreach ($tags as $tag_id => $tag) {
+      $operations[$tag_id] = array(
+        'label' => '- '. $tag,
+        'callback' => '_privatemsg_filter_thread_tag',
+        'callback arguments' => array('tag_id' => $tag_id),
+     );
+    }
+  }
+ return $operations;
+}
+
+function _privatemsg_filter_thread_tag($threads, $tag_id) {
+  global $user;
+
+  foreach ($threads as $thread) {
+    if (db_result(db_query('SELECT COUNT(*) FROM {pm_tags_index} WHERE tag_id = %d AND (uid = %d AND thread_id = %d)', $tag_id, $user->uid, $thread)) == 0) {
+      db_query('INSERT INTO {pm_tags_index} (tag_id, uid, thread_id) VALUES (%d, %d, %d)', $tag_id, $user->uid, $thread);
+    }
+  }
 }
\ No newline at end of file

