You are here

function notifications_get_link in Notifications 5

Same name and namespace in other branches
  1. 6.4 notifications.module \notifications_get_link()
  2. 6 notifications.module \notifications_get_link()
  3. 6.2 notifications.module \notifications_get_link()
  4. 6.3 notifications.module \notifications_get_link()

Return url for subscriptions. Confirmation form is not optional.

3 calls to notifications_get_link()
Notifications_Content_Tests::testNotificationsContent in tests/notifications_content.test
Play with creating, retrieving, deleting a pair subscriptions
notifications_token_values in ./notifications.module
Implementation of hook_token_values()
notifications_ui_link in notifications_ui/notifications_ui.module
Implementation of hook_link()

File

./notifications.module, line 893
Notifications module

Code

function notifications_get_link($type, $params) {
  global $user;
  $params += array(
    'uid' => $user->uid,
    'signed' => FALSE,
    'destination' => $_GET['q'],
  );
  switch ($type) {
    case 'subscribe':
      $elements = array(
        'subscribe',
        $params['uid'],
        $params['type'],
        implode(',', array_keys($params['fields'])),
        implode(',', $params['fields']),
      );
      break;
    case 'unsubscribe':
      $elements = array(
        'unsubscribe',
        $params['sid'],
      );
      break;
  }

  // Build query string
  $query = array();
  if ($params['destination']) {
    $query[] = 'destination=' . $params['destination'];
  }
  if ($params['signed']) {
    $query[] = 'signature=' . _notifications_signature($elements);
  }
  return array(
    'href' => 'notifications/' . implode('/', $elements),
    'query' => implode('&', $query),
  );
}