You are here

function notifications_destination_request_form_submit in Notifications 6.4

Process submitted values

File

includes/destination.inc, line 436
Destination management

Code

function notifications_destination_request_form_submit($form, &$form_state) {
  $dest = notifications_destination_parse_submitted($form_state['values']);
  if ($dest['type'] && $dest['address'] && ($destination = Messaging_Destination::get_by_address($dest['type'], $dest['address']))) {
    if ($destination->uid && ($account = $destination
      ->get_account())) {

      // It is possible also that a registered user has used someone else's address.
      // If so, we send a link to delete all user's subscriptions. Fuck them!
      $result = notifications_destination_message_send('user-unsubscribe', $destination, $dest['method'], array(
        'user' => $account,
      ));
    }
    else {

      // It is a destination for an anonymous user
      $result = notifications_destination_message_send('destination-unsubscribe', $destination, $dest['method']);
    }
    if (!empty($result)) {
      drupal_set_message(t('A message has been sent to that address with instructions to unsubscribe.'));
    }
    else {
      drupal_set_message(t('Cannot send message to that address. Please contact the site administrator.'), 'warning');
    }
  }
  else {
    drupal_set_message(t('We cannot find that address on this site.'), 'error');
  }
}