You are here

function notifications_page_subscribe in Notifications 6.3

Same name and namespace in other branches
  1. 5 notifications.admin.inc \notifications_page_subscribe()
  2. 6.4 notifications.pages.inc \notifications_page_subscribe()
  3. 6 notifications.pages.inc \notifications_page_subscribe()
  4. 6.2 notifications.pages.inc \notifications_page_subscribe()
  5. 7 notifications.pages.inc \notifications_page_subscribe()

Menu callback add subscription

Presents confirmation page or not depending on confirm parameter

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

File

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

Code

function notifications_page_subscribe($account, $type, $fields, $values, $send_interval = NULL, $send_method = NULL) {
  global $user;

  // Check signature if present
  $params = array(
    'subscribe',
    $account->uid,
    $type,
    $fields,
    $values,
  );
  $signed = !empty($_GET['signature']) && $_GET['signature'] == _notifications_signature($params, !empty($_GET['confirm']));

  // Build subscriptions object
  $subscription = (object) array(
    'uid' => $account->uid,
    'type' => $type,
    'fields' => notifications_field_args($fields, $values),
    'send_interval' => $send_interval ? $send_interval : notifications_user_setting('send_interval', $account),
    'send_method' => $send_method ? $send_method : notifications_user_setting('send_method', $account),
    'event_type' => notifications_subscription_types($type, 'event_type'),
  );
  if (notifications_user_allowed('subscription', $account, $subscription)) {

    // Display subscription information
    if (!empty($_GET['confirm']) && $signed) {

      // Subscribe, no confirmation
      notifications_save_subscription($subscription);
      drupal_set_message(t('Your subscription was activated.'));
      drupal_goto();
    }
    else {

      // Ask for confirmation
      drupal_set_title(t('Confirm your subscription'));
      return drupal_get_form('notifications_form_subscribe_confirm', $subscription, $account);
    }
  }
  else {
    drupal_set_message(t('Subscription type or parameters not allowed'), 'error');
    drupal_goto();
  }
  drupal_access_denied();
}