You are here

function notifications_subscription_destination_subform_submit in Notifications 7

Same name and namespace in other branches
  1. 6.4 notifications.module \notifications_subscription_destination_subform_submit()

Create submitted destination

1 string reference to 'notifications_subscription_destination_subform_submit'
notifications_subscription_destination_subform in notifications_account/notifications_account.module
Add destination subform

File

notifications_account/notifications_account.module, line 249
Notifications module - User subscriptions tabs

Code

function notifications_subscription_destination_subform_submit($form, &$form_state) {
  notifications_include('destination.inc');

  // Get destination from form and add method / destination to form values
  $dest = notifications_destination_parse_submitted($form_state['values'], FALSE);
  if ($destination = Messaging_Destination::create($dest)) {
    $form_state['values']['send_method'] = $dest['method'];
    $form_state['values']['destination'] = $destination;
    $form_state['values']['subscription_fields'][] = 'send_method';
    $form_state['values']['subscription_fields'][] = 'destination';
  }
  else {

    // We should have trapped this on validation. Just in case print an error message.
    drupal_set_message(t('Cannot create a destination for this subscription.'), 'error');
  }
}