You are here

function notifications_page_subscribe in Notifications 7

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. 6.3 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 12
User pages for Notifications

Code

function notifications_page_subscribe($substype) {
  $account = $GLOBALS['user'];

  // Build subscriptions object
  if ($substype
    ->user_access($account, 'subscribe')) {
    $subscription = $substype
      ->instance()
      ->set_user($account)
      ->set_properties_from_url();

    // If everything is ok and signed to skip confirmation, go ahead
    if ($subscription
      ->check_destination() && $subscription
      ->check_fields() && notifications_check_signature('skip')) {
      $subscription
        ->save();
      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_subscription_subscribe_form', $subscription);
    }
  }
  drupal_set_message(t('Subscription or parameters not allowed.'), 'error');
  drupal_goto();
  return "HOW WE REACHED HERE?";
}