function privatemsg_filter_add_tags in Privatemsg 6.2
Same name and namespace in other branches
- 6 privatemsg_filter/privatemsg_filter.module \privatemsg_filter_add_tags()
- 7.2 privatemsg_filter/privatemsg_filter.module \privatemsg_filter_add_tags()
- 7 privatemsg_filter/privatemsg_filter.module \privatemsg_filter_add_tags()
Tag one or multiple threads with a tag.
Parameters
$threads: A single thread id or an array of thread ids.
$tag_id: Id of the tag.
6 calls to privatemsg_filter_add_tags()
- hook_privatemsg_message_recipient_changed in ./
privatemsg.api.php - This hook is invoked when a recipient is added to a message.
- privatemsg_filter_form_submit in privatemsg_filter/
privatemsg_filter.module - privatemsg_filter_inbox_rebuild_process in privatemsg_filter/
privatemsg_filter.admin.inc - Batch processing function for rebuilding the index.
- privatemsg_filter_privatemsg_message_insert in privatemsg_filter/
privatemsg_filter.module - Implements hook_privatemsg_message_insert().
- privatemsg_filter_privatemsg_message_recipient_changed in privatemsg_filter/
privatemsg_filter.module - Implements hook_privatemsg_message_recipient_changed().
3 string references to 'privatemsg_filter_add_tags'
- privatemsg_filter_add_tag_submit in privatemsg_filter/
privatemsg_filter.module - Form callback for adding a tag to threads.
- privatemsg_filter_privatemsg_thread_operations in privatemsg_filter/
privatemsg_filter.module - Implements hook_privatemsg_thread_operations().
- privatemsg_filter_remove_tag_submit in privatemsg_filter/
privatemsg_filter.module - Form callback for removing a tag to threads.
File
- privatemsg_filter/
privatemsg_filter.module, line 214 - Allows users to tag private messages and to filter based upon those tags.
Code
function privatemsg_filter_add_tags($threads, $tag_ids, $account = NULL) {
if (!is_array($threads)) {
$threads = array(
$threads,
);
}
if (!is_array($tag_ids)) {
$tag_ids = array(
$tag_ids,
);
}
if (empty($account)) {
global $user;
$account = drupal_clone($user);
}
foreach ($tag_ids as $tag_id) {
foreach ($threads as $thread) {
// Make sure that we don't add a tag to a thread twice,
// only insert if there is no such tag yet.
if (!db_result(db_query('SELECT 1 FROM {pm_tags_index} WHERE tag_id = %d AND (uid = %d AND thread_id = %d)', $tag_id, $account->uid, $thread))) {
db_query('INSERT INTO {pm_tags_index} (tag_id, uid, thread_id) VALUES (%d, %d, %d)', $tag_id, $account->uid, $thread);
}
}
}
}