You are here

function notifications_tokens in Notifications 7

Implements hook_tokens().

File

./notifications.module, line 1326
Notifications module

Code

function notifications_tokens($type, $tokens, array $data = array(), array $options = array()) {
  if ($type == 'user' && !empty($data['user'])) {
    $user = $data['user'];
    $replacements = array();
    foreach ($tokens as $name => $original) {
      switch ($name) {

        // Signed unsubscribe url
        case 'unsubscribe-url':
          $url_options = array(
            'absolute' => TRUE,
          );
          if ($user->uid) {
            $url_options['signed'] = TRUE;
            $path = 'notifications/unsubscribe/user/' . $user->uid;
            $url_options = notifications_url_options($path, $url_options);
          }
          else {
            $path = 'notifications/unsubscribe';
          }
          $replacements[$original] = url($path, $url_options);
          break;
      }
    }
    return $replacements;
  }
}