function notifications_submit_subscription in Notifications 7
Same name and namespace in other branches
- 6.4 notifications.pages.inc \notifications_submit_subscription()
Submit subscription printing out the results
2 calls to notifications_submit_subscription()
- notifications_account_subscription_list_form_submit in notifications_account/
notifications_account.pages.inc - Submit list of subscriptions
- notifications_subscription_base_form_submit in ./
notifications.pages.inc - Save edited subscription
File
- ./
notifications.pages.inc, line 335 - User pages for Notifications
Code
function notifications_submit_subscription($subscription) {
global $user;
$instance = $subscription
->is_instance();
// If a new subscription we may need to set current user
if (!isset($subscription->uid)) {
$subscription
->set_user($user);
}
// Check some parameters are ok (checking fills in some missing values too)
if (!$subscription
->check_all()) {
drupal_set_message($subscription->error_message, 'error');
return FALSE;
}
// Check permissions for current user to create this subscription
if (!$subscription
->check_access($user)) {
if (!empty($subscription->error_message)) {
drupal_set_message($subscription->error_message);
}
else {
drupal_set_message(t("You are not allowed to create this type of subscription."), 'error');
}
return FALSE;
}
// Actually update or create subscription, skipping checks that we've already done.
$result = notifications_save_subscription($subscription, FALSE);
switch ($result) {
case SAVED_NEW:
drupal_set_message(t('Your subscription has been created.'));
return TRUE;
case SAVED_UPDATED:
if ($instance) {
drupal_set_message(t('Your subscription has been updated.'));
}
else {
drupal_set_message(t('Your subscription has been created updating an existing one of the same type.'));
}
return TRUE;
default:
if ($instance) {
drupal_set_message(t('Your subscription cannot be updated.'), 'error');
}
else {
drupal_set_message(t('Your subscription cannot be created.'), 'error');
}
return FALSE;
}
}