You are here

function privatemsg_rules_load_tag in Privatemsg 6.2

Loads a tag.

1 call to privatemsg_rules_load_tag()
privatemsg_rules_thread_has_tag in privatemsg_rules/privatemsg_rules.rules.inc
Check if a thread has a specific tag.

File

privatemsg_rules/privatemsg_rules.rules.inc, line 116
Hooks and callback functions for rules.module integration.

Code

function privatemsg_rules_load_tag($settings) {
  if (!empty($settings['tag'])) {
    $tag = db_fetch_object(db_query("SELECT * from {pm_tags} pmt WHERE pmt.tag = '%s'", $settings['tag']));
    if ($tag) {
      return array(
        'tag_loaded' => $tag,
      );
    }

    // If tag does not exist, create it.
    $tags = privatemsg_filter_create_tags(array(
      $settings['tag'],
    ));
    if ($tagid = reset($tags)) {
      $settings['tagid'] = $tagid;
    }
  }
  elseif (!empty($settings['tagid'])) {
    return array(
      'tag_loaded' => db_fetch_object(db_query('SELECT * from {pm_tags} pmt WHERE pmt.tag_id = %d', $settings['tagid'])),
    );
  }
}