You are here

function notifications_subscription_list_form_submit in Notifications 6.4

Same name and namespace in other branches
  1. 7 notifications.module \notifications_subscription_list_form_submit()

Submit list of subscriptions

1 call to notifications_subscription_list_form_submit()
notifications_user_form_submit in ./notifications.module
Process generic form submission

File

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

Code

function notifications_subscription_list_form_submit($form, &$form_state) {
  $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : NULL;
  $updated = 0;
  switch ($op) {
    case t('Add'):
      $subscription = notifications_build_subscription($form_state['values']['template']);
      $subscription
        ->add_fields($form_state['values']['parsed_fields']);
      notifications_subscription_list_form_values($form_state['values']['subscriptions'], $subscription, 'new');
      notifications_submit_subscription($subscription);
      break;
    case t('Update'):
      $updated = 0;
      foreach ($form_state['values']['current_subscriptions'] as $key => $subscription) {
        if (notifications_subscription_list_form_values($form_state['values']['subscriptions'], $subscription)) {
          $subscription
            ->save();
          $updated++;
        }
      }
      break;
    case t('Delete'):
      $form_state['rebuild'] = TRUE;
      break;
  }
  if ($updated) {
    drupal_set_message(format_plural($updated, 'One subscription has been updated.', '@count subscriptions have been updated.'));
  }
}