function privatemsg_filter_add_tags in Privatemsg 7.2
Same name and namespace in other branches
- 6.2 privatemsg_filter/privatemsg_filter.module \privatemsg_filter_add_tags()
- 6 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 - Form builder function, display a form to modify tags on a thread.
- 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 - Form callback for removing a tag to threads.
- 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 = 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.
db_merge('pm_tags_index')
->key(array(
'tag_id' => $tag_id,
'uid' => $account->uid,
'thread_id' => $thread,
))
->execute();
}
}
}