You are here

public function Notifications_Subscription_List::get_links in Notifications 7

Get all subscription links

Parameters

$type:

  • If 'subscribe', 'unsubscribe' will return just that type of links
  • If 'subscription' will return all subscriptions with either 'subscribe' or 'unsubscribe'
  • Type 'grouped' will return two nested lists: subscribe /unsubscribe

File

./notifications.list.inc, line 160
Drupal Notifications Framework - Default class file

Class

Notifications_Subscription_List
List of subscriptions or subscription types

Code

public function get_links($type = 'subscription', $options = array()) {
  if ($type == 'grouped') {
    $items = array();
    $groups = array(
      'subscribe' => t('Subscribe to:'),
      'unsubscribe' => t('Unsubscribe from:'),
    );
    foreach ($groups as $group_type => $title) {
      if ($subscriptions = $this
        ->get_links($group_type)) {
        $items[] = theme('item_list', array(
          'items' => $subscriptions,
          'title' => $title,
        ));
      }
    }
    return $items;
  }
  if ($type == 'subscribe' || $type == 'unsubscribe') {

    // Filter out the ones that don't match
    $subscriptions = $this
      ->get_stored($type == 'unsubscribe');
  }
  else {
    $subscriptions = $this
      ->get_instances();
  }
  $links = array();
  foreach ($subscriptions as $subscription) {
    $links[] = $subscription
      ->get_link($type, $options);
  }
  return $links;
}