You are here

function notifications_page_subscribe in Notifications 5

Same name and namespace in other branches
  1. 6.4 notifications.pages.inc \notifications_page_subscribe()
  2. 6 notifications.pages.inc \notifications_page_subscribe()
  3. 6.2 notifications.pages.inc \notifications_page_subscribe()
  4. 6.3 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.admin.inc, line 429

Code

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

  // Access checking
  if ($uid && ($uid == $user->uid || user_access('administer notifications'))) {
    if ($account = user_load(array(
      'uid' => $uid,
    ))) {

      // Build subscriptions object
      $subscription = (object) array(
        'uid' => $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 and confirmation form
        drupal_set_title(t('Confirm your subscription'));
        return drupal_get_form('notifications_form_confirm', $subscription);
      }
      else {
        drupal_set_message(t('Subscription type or parameters not allowed'), 'error');
        drupal_goto();
      }
    }
  }
  drupal_access_denied();
}