You are here

function notifications_tags_node_get_terms in Notifications 7

Same name and namespace in other branches
  1. 5 notifications_tags/notifications_tags.module \notifications_tags_node_get_terms()
  2. 6.4 notifications_tags/notifications_tags.module \notifications_tags_node_get_terms()
  3. 6 notifications_tags/notifications_tags.module \notifications_tags_node_get_terms()
  4. 6.2 notifications_tags/notifications_tags.module \notifications_tags_node_get_terms()
  5. 6.3 notifications_tags/notifications_tags.module \notifications_tags_node_get_terms()

Helper function to get latest node terms that belong to our vocabularies for subscriptions

We cannot use the one from taxonomy module because it has static caching and we'll be sending notifications right after the node has been updated

1 call to notifications_tags_node_get_terms()
notifications_tags_notifications_object_node in notifications_tags/notifications_tags.module
Implementation of hook_notifications_object_node()

File

notifications_tags/notifications_tags.module, line 343
Subscriptions to taxonomy terms

Code

function notifications_tags_node_get_terms($node) {
  static $terms;
  if (!isset($terms[$node->nid])) {
    $terms[$node->nid] = array();
    if ($vocabularies = notifications_tags_vocabulary_list()) {

      // We just get terms for allowed vocabularies
      $vids = array_keys($vocabularies);
      $args = array_merge(array(
        $node->nid,
      ), $vids);
      $result = db_query('SELECT t.tid FROM {term_node} t INNER JOIN {term_data} d ON t.tid = d.tid WHERE t.nid = %d AND d.vid IN(' . db_placeholders($vids) . ')', $args);
      while ($term = db_fetch_object($result)) {
        $terms[$node->nid][] = $term->tid;
      }
    }
  }
  return $terms[$node->nid];
}