You are here

function notifications_ui_build_links in Notifications 6

Same name and namespace in other branches
  1. 6.2 notifications_ui/notifications_ui.module \notifications_ui_build_links()
  2. 6.3 notifications_ui/notifications_ui.module \notifications_ui_build_links()

Build subscription options as an array of links

These links can be added as node link elements or rendered some other way

Parameters

$options: Array of subscription options, like the one produced by notifications_ui_user_node()

$prefix: Prefix to use for the link indexes

2 calls to notifications_ui_build_links()
notifications_ui_link in notifications_ui/notifications_ui.module
Implementation of hook_link()
notifications_ui_user in notifications_ui/notifications_ui.module

File

notifications_ui/notifications_ui.module, line 352
User Interface for subscriptions modules

Code

function notifications_ui_build_links($options, $prefix = 'notifications_') {
  $links = array();
  foreach ($options as $index => $option) {
    if (!empty($option['subscription'])) {

      // Unsubscribe link
      $title = t('Unsubscribe from: !name', array(
        '!name' => $option['name'],
      ));
      $props = notifications_get_link('unsubscribe', array(
        'sid' => $option['subscription']->sid,
      ));
    }
    else {

      // Subscribe link
      $title = t('Subscribe to: !name', array(
        '!name' => $option['name'],
      ));
      $props = notifications_get_link('subscribe', array(
        'type' => $option['type'],
        'confirm' => TRUE,
        'fields' => $option['fields'],
      ));
    }
    $links[$prefix . $index] = array(
      'title' => $title,
      'html' => TRUE,
      'href' => $props['href'],
    ) + $props['options'];
  }
  return $links;
}