You are here

function _notifications_forum_toggle_subscription_url in Forum notifications 6

Same name and namespace in other branches
  1. 7 notifications_forum.module \_notifications_forum_toggle_subscription_url()
1 call to _notifications_forum_toggle_subscription_url()
notifications_forum_preprocess_forum_list in ./notifications_forum.module
Preprocess function for theme_forum_list().

File

./notifications_forum.module, line 279

Code

function _notifications_forum_toggle_subscription_url($tid) {
  global $user;
  $original = NULL;
  if ($subscriptions = notifications_get_subscriptions(array(
    'type' => 'taxonomy',
    'uid' => $user->uid,
    'event_type' => 'node',
  ), array(
    'tid' => $tid,
  ), TRUE)) {
    $original = array_shift($subscriptions);
  }
  $type = is_null($original) ? 'subscribe' : 'unsubscribe';
  $url = notifications_build_link($type, array(
    'type' => 'taxonomy',
    'uid' => $user->uid,
    'fields' => array(
      'tid' => $tid,
    ),
    'event_type' => 'node',
    'destination' => TRUE,
  ), 'subscription', $original, 'url');
  return array(
    $type,
    $url,
  );
}