You are here

function forward_js_submit in Forward 7.3

Same name and namespace in other branches
  1. 7.2 forward.module \forward_js_submit()
1 string reference to 'forward_js_submit'
forward_form_alter in ./forward.module
Implements hook_form_alter().

File

./forward.module, line 1125
Allows forwarding of entities by email, and provides a record of how often each has been forwarded.

Code

function forward_js_submit($form, &$form_state) {

  // If there were errors, need to re-display the form
  if (form_get_errors()) {
    return $form;
  }

  // Notify next page that a message is waiting - this is needed because Ajax can't set the message queue
  $recipient_list = _forward_recipient_list($form_state);
  $_SESSION['forward_message_pending'] = array(
    'forward' => $recipient_list['token'],
  );

  // Form passed validation, so redirect to a good landing page
  $returnurl = isset($form['message']['path']['#value']) ? $form['message']['path']['#value'] : '';
  $markup = '
    <script type="text/javascript">
      (function ($) {
        $(document).ready(function() {
          $.fn.colorbox.close();
          window.location = "' . url($returnurl, array(
    'absolute' => TRUE,
  )) . '";
        });
      })(jQuery);
    </script>';

  // Return our markup.
  $confirmation = array(
    '#type' => 'markup',
    '#markup' => $markup,
  );
  return $confirmation;
}