You are here

function notifications_account_overview in Notifications 7

Menu callback. Overview page for user subscriptions.

We create the page as a form so it can be altered

1 string reference to 'notifications_account_overview'
notifications_account_menu in notifications_account/notifications_account.module
Implementation of hook_menu()

File

notifications_account/notifications_account.pages.inc, line 13
User pages for Notifications

Code

function notifications_account_overview($account) {
  $form['account'] = array(
    '#type' => 'value',
    '#value' => $account,
  );
  $path = 'user/' . $account->uid;

  // Status, send method, interval
  $count = db_query("SELECT status, COUNT(*) AS num FROM {notifications_subscription} WHERE uid = :uid GROUP BY status", array(
    ':uid' => $account->uid,
  ));
  $status_list = Notifications_Subscription::status_list();
  while ($current = $count
    ->fetchObject()) {
    $status[$current->status] = t('You have %count @status subscriptions.', array(
      '%count' => $current->num,
      '@status' => $status_list[$current->status],
    ));
  }
  if (empty($status)) {
    $status['none'] = t('You don\'t have any subscriptions yet.');
  }
  $send_intervals = notifications_send_intervals($account);
  $send_methods = notifications_send_methods($account);
  if ($method = notifications_user_setting('send_method', $account)) {
    if (isset($send_methods[$method])) {
      $status['method'] = t('Your default sending method for new subscriptions is @send_method', array(
        '@send_method' => $send_methods[$method],
      ));
    }
  }
  $interval = notifications_user_setting('send_interval', $account);
  if (isset($send_intervals[$interval])) {
    $status['interval'] = t('Your default sending interval for new subscriptions is @send_interval', array(
      '@send_interval' => $send_intervals[$interval],
    ));
  }
  $form['status'] = array(
    '#type' => 'item',
    '#weight' => 10,
    '#title' => t('Current status'),
    '#markup' => theme('item_list', array(
      'items' => $status,
    )),
  );

  // Build shortcut tips
  if (notifications_access_user($account, 'manage')) {
    $tips['admin'] = l(t('Administer your subscriptions'), "{$path}/notifications/subscription");
  }
  $tips['edit'] = l(t('Edit your notifications settings'), "{$path}/edit");

  // Enable / disable all subscriptions
  if (notifications_access_user($account, 'maintain')) {
    if (!empty($status[Notifications_Subscription::STATUS_ACTIVE])) {
      $tips['disable'] = l(t('Temporarily disable all your subscriptions'), "{$path}/notifications/update/disable");
    }
    if (!empty($status[Notifications_Subscription::STATUS_INACTIVE]) || !empty($status[Notifications_Subscription::STATUS_BLOCKED])) {
      $tips['enable'] = l(t('Enable all your subscriptions'), "{$path}/notifications/update/enable");
    }
  }

  /*
  $link = notifications_get_link('unsubscribe', array('uid' => $account->uid, 'destination' => TRUE));
  $tips['cancel'] = l(t('Cancel all your subscriptions'), $link['href'], $link['options']);
  */

  //$output .= theme('item_list', $tips, t('You can'));
  $form['tips'] = array(
    '#type' => 'item',
    '#weight' => 20,
    '#title' => t('You can'),
    '#markup' => theme('item_list', array(
      'items' => $tips,
    )),
  );
  return $form;
}