You are here

protected function Notifications_Subscription::get_link_options in Notifications 7

Get default link options

2 calls to Notifications_Subscription::get_link_options()
Notifications_Subscription::element_link in ./notifications.subscription.inc
Get link element
Notifications_Subscription::get_path in ./notifications.subscription.inc
Get path for links

File

./notifications.subscription.inc, line 231
Drupal Notifications Framework - Default class file

Class

Notifications_Subscription
Common base for subscription type and subscription instance

Code

protected function get_link_options($operation, $options = array()) {
  $options += array(
    'query' => array(),
    'destination' => TRUE,
  );
  switch ($operation) {
    case 'subscribe':
      $options += array(
        'base_path' => 'notifications/subscribe',
        'skip_confirmation' => variable_get('notifications_option_subscribe_links', 0),
      );

      // Add instance fields to the query string indexed by position
      foreach ($this
        ->get_fields(TRUE) as $field) {
        $options['query'][$field->position] = $field->value;
      }
      break;
    case 'unsubscribe':
      $options += array(
        'base_path' => 'notifications/unsubscribe',
        'skip_confirmation' => variable_get('notifications_option_unsubscribe_links', 0),
      );
      break;
    default:
      $options += array(
        'base_path' => 'notifications/subscription/' . ($this
          ->is_stored() ? $this->sid . '/' : '') . $operation,
      );
      break;
  }

  // Translate destination option into actual destination
  if (!empty($options['destination'])) {
    $destination = isset($_REQUEST['destination']) ? $_REQUEST['destination'] : (isset($_GET['q']) ? $_GET['q'] : '');
    if ($destination) {
      $options['query'] += array(
        'destination' => $destination,
      );
    }
  }
  return $options;
}