You are here

class Notifications_Taxonomy_Term_Multiple_Subscription in Notifications 7

Subscription to simple taxonomy term

Hierarchy

Expanded class hierarchy of Notifications_Taxonomy_Term_Multiple_Subscription

1 string reference to 'Notifications_Taxonomy_Term_Multiple_Subscription'
notifications_tags_notifications in notifications_tags/notifications_tags.module
Implementation of hook_notifications().

File

notifications_tags/notifications_tags.inc, line 260
Drupal Notifications Framework - Default class file

View source
class Notifications_Taxonomy_Term_Multiple_Subscription extends Notifications_Subscription_Multiple {

  /**
   * Get proper name
   */
  public function get_name() {
    if (isset($this->name)) {
      return $this->name;
    }
    elseif ($terms = $this
      ->get_fields()) {
      foreach ($terms as $term_field) {
        $names[] = $term_field
          ->get_name();
      }
      return t('Content tagged with @terms', array(
        '@terms' => implode(', ', $names),
      ));
    }
    else {
      parent::get_name();
    }
  }

  /**
   * Add term object
   */
  public function add_term($term) {
    return $this
      ->add_field('term:tid', $term->tid);
  }

  /**
   * Add term by name (and optional vid)
   */
  public function add_term_by_name($name, $vid = NULL) {
    $conditions = array(
      'name' => trim($name),
    );
    if ($vid) {
      $conditions['vid'] = $vid;
    }
    if ($terms = taxonomy_term_load_multiple(array(), $conditions)) {
      $this
        ->add_term(reset($terms));
    }
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Notifications_Subscription_Multiple::check_fields function Check all fields are there and they have a value. In this case we need at least the same fields that the type fields has
Notifications_Subscription_Multiple::map_field function Map field to its right position in this subscription. As fields have no specific position it will be the next one
Notifications_Taxonomy_Term_Multiple_Subscription::add_term public function Add term object
Notifications_Taxonomy_Term_Multiple_Subscription::add_term_by_name public function Add term by name (and optional vid)
Notifications_Taxonomy_Term_Multiple_Subscription::get_name public function Get proper name