You are here

function notifications_page_unsubscribe_user in Notifications 7

Menu callback for unsubscribe page

Parameters

$type: Either 'sid' or 'uid' (for unsubscribe all)

$id: Subscription id or user id, depending on typeunt

1 string reference to 'notifications_page_unsubscribe_user'
notifications_menu in ./notifications.module
Implementation of hook_menu().

File

./notifications.pages.inc, line 69
User pages for Notifications

Code

function notifications_page_unsubscribe_user($account) {

  // If everything is ok and signed to skip confirmation, go ahead
  if (notifications_check_signature('skip')) {
    $count = Notifications_Subscription::delete_multiple(array(
      'uid' => $account->uid,
    ));
    drupal_set_message(t('All your subscriptions have been removed.'));
    drupal_goto();
  }
  else {
    $subscriptions = new Notifications_Subscription_List();
    $subscriptions
      ->load_multiple(array(), array(
      'uid' => $account->uid,
    ));
    if ($subscriptions
      ->count()) {

      // Ask for confirmation
      return drupal_get_form('notifications_subscription_list_form', 'unsubscribe', $subscriptions);
    }
    else {

      // No subscriptions. Print warning and fall back to access denied.
      drupal_set_message(t('You don\'t have any subscriptions on this site.'), 'error');
    }
  }
  drupal_access_denied();
}