You are here

function notifications_page_unsubscribe_overview in Notifications 6.4

Same name and namespace in other branches
  1. 7 notifications.pages.inc \notifications_page_unsubscribe_overview()

Display unsubscribe options for this page

1 call to notifications_page_unsubscribe_overview()
notifications_page_unsubscribe in ./notifications.pages.inc
Menu callback for unsubscribe page

File

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

Code

function notifications_page_unsubscribe_overview() {
  global $user;
  notifications_include('destination.inc');

  //drupal_set_title(t('Unsubscribe'));
  $output = '';
  $send_methods = notifications_destination_anonymous_methods();
  $subscriptions = 0;

  // Provide information for user subscriptions if logged in
  if ($user->uid) {
    $subscriptions = db_result(db_query("SELECT COUNT(*) FROM {notifications} WHERE uid = %d", $user->uid));
    if ($subscriptions) {
      $output .= '<p>' . format_plural($subscriptions, 'There is one subscription for this user account.', 'There are @count subscriptions for this user account.') . '</p>';
      $output .= '<p>' . t('You can:') . '<br />';
      $options = array();
      if (notifications_access_user($account, 'maintain')) {
        $options[] = l(t('Administer your subscriptions'), "user/{$user->uid}/notifications");
        $options[] = l(t('Temporarily disable all your subscriptions'), "user/{$user->uid}/notifications/update/disable");
      }
      $options[] = notifications_build_link('unsubscribe', array(
        'title' => t('Cancel all your subscriptions'),
      ), 'user', $user, 'link');
      $output .= theme('item_list', $options);
    }
    else {
      $output .= '<p>' . t('There are no subscriptions for this user account') . '</p>';
      if ($send_methods) {
        $output .= '<p>' . t('However if you are still getting notifications from this site, enter your address below and you\'ll get a link to disable that address.') . '</p>';
      }
    }
  }
  if (!$subscriptions && $send_methods) {

    // Present destination unsubscribe request form
    $output .= drupal_get_form('notifications_destination_request_form', $account, $send_methods);
  }
  elseif (!$user->uid) {

    // WTF? Someone is getting spam from here?
    $output .= '<p>' . t('You may have an account on this site or someone may have created it for you.') . '</p>';
    $output .= '<p>' . t('You can try to <a href="@user-login">log in</a>, request a <a href="@request-password">new password</a>, or contact the site administrator.', array(
      '@user-login' => url('user/login'),
      '@request-password' => url('user/password'),
    )) . '</p>';
  }
  return $output;
}