You are here

protected function Notifications_Subscription::form_operation in Notifications 7

Run form operation

1 call to Notifications_Subscription::form_operation()
Notifications_Subscription::form_submit in ./notifications.subscription.inc
Process form submission

File

./notifications.subscription.inc, line 393
Drupal Notifications Framework - Default class file

Class

Notifications_Subscription
Common base for subscription type and subscription instance

Code

protected function form_operation($operation, $form, &$form_state) {
  switch ($operation) {
    case 'cancel':
      drupal_set_message(t('Operation cancelled.'), 'warning');
      $this->result = FALSE;
      break;
    case 'subscribe':
    case 'add':
    case 'edit':
      $this->result = $this
        ->save();
      switch ($this->result) {
        case SAVED_NEW:
          drupal_set_message(t('The subscription has been created.'));
          break;
        case SAVED_UPDATED:
          drupal_set_message(t('The subscription has been updated.'));
          break;
        default:
          drupal_set_message(t('Error saving the subscription.'), 'error');
      }
      if (!empty($this->sid)) {
        $form_state['redirect'] = 'notifications/subscription/' . $this->sid;
      }
      break;
    case 'unsubscribe':
    case 'delete':
      $this->result = $this
        ->delete();
      if ($this->result) {
        drupal_set_message(t('The subscription has been removed.'));
      }
      else {
        drupal_set_message(t('Error deleting the subscription.'), 'error');
      }
      $form_state['redirect'] = variable_get('notifications_frontpage', '<front>');
      break;
    default:
      drupal_set_message(t('Operation not implemented yet.'), 'warning');
      $this->result = FALSE;
      break;
  }
}