You are here

function acquia_lift_personalize_blocks_form_submit in Acquia Lift Connector 7

Same name and namespace in other branches
  1. 7.2 acquia_lift.module \acquia_lift_personalize_blocks_form_submit()

Submit handler for altered personalize_elements_form.

1 string reference to 'acquia_lift_personalize_blocks_form_submit'
acquia_lift_form_personalize_blocks_form_alter in ./acquia_lift.module
Implements hook_form_FORM_ID_alter().

File

./acquia_lift.module, line 2577
acquia_lift.module Provides Acquia Lift-specific personalization functionality.

Code

function acquia_lift_personalize_blocks_form_submit($form, &$form_state) {
  $redirect = $form_state['redirect'];
  if ($redirect === FALSE) {
    return;
  }

  // If there is a destination specified, then it should take priority over the
  // existing redirect value (which is what happens in Drupal form handling).
  // Check this manually rather than using drupal_get_destination() as it
  // returns the current URL if the destination is not yet.
  $destination = drupal_get_destination();
  if (isset($_GET['destination'])) {
    $redirect = $destination['destination'];

    // Now that it has been handled, remove it so taht it doesn't overwrite
    // our own redirect location.
    unset($_GET['destination']);
  }
  else {
    if (empty($redirect)) {

      // If there is no destination and no redirect, then use the default
      // Drupal destination of the current path.
      $redirect = $destination['redirect'];
    }
  }

  // Convert the existing redirect into a redirect that accepts query parameters.
  if (is_string($redirect)) {
    $redirect = array(
      $redirect,
      array(
        'query' => array(),
      ),
    );
  }

  // Add a message to be shown.
  $redirect[1]['query']['liftpm'] = 'new_block|' . $form_state['values']['title'];
  $form_state['redirect'] = $redirect;
}