You are here

function notifications_anonymous_token_values in Notifications 6.4

Implementation of hook_token_values()

Provide user-like tokens for anonymous users

File

notifications_anonymous/notifications_anonymous.module, line 424
Notifications for anonymous users

Code

function notifications_anonymous_token_values($type, $object = NULL, $options = array()) {
  switch ($type) {
    case 'destination':
      $values = array();

      // Just for anonymous destinations, for the others the notifications module will do the job
      if (($destination = messaging_check_object($object, 'Messaging_Destination')) && empty($destination->uid)) {
        $missing = '';
        $links = notifications_anonymous_manage_links('destination', $destination, 'url');
        $values['destination-unsubscribe-url'] = isset($links['delete']) ? $links['delete'] : $missing;
        $values['destination-manage-url'] = isset($links['manage']) ? $links['manage'] : $missing;
        $values['destination-edit-url'] = isset($links['edit']) ? $links['edit'] : $missing;

        // This user token goes with destination for anonymous
        $values['unsubscribe-url-global'] = $values['destination-unsubscribe-url'];
        $values['subscriptions-manage'] = $values['destination-manage-url'];
      }
      return $values;
  }
}