function rules_action_drupal_goto

Action: Page redirect.

See also

rules_page_build()

rules_drupal_goto_alter()

Related topics

1 string reference to 'rules_action_drupal_goto'
rules_system_action_info in modules/system.rules.inc
Implements hook_rules_action_info() on behalf of the system module.

File

modules/system.eval.inc, line 39

Code

function rules_action_drupal_goto($url, $force = FALSE, $destination = FALSE) {
    // Don't let administrators lock them out from Rules administration pages.
    if (isset($_GET['q']) && strpos($_GET['q'], 'admin/config/workflow/rules') === 0) {
        rules_log('Skipped page redirect on Rules administration page.', array(), RulesLog::WARN);
        return;
    }
    // Do not redirect during batch processing.
    if (($batch = batch_get()) && isset($batch['current_set'])) {
        rules_log('Skipped page redirect during batch processing.');
        return;
    }
    // Keep the current destination parameter if there is one set.
    if ($destination) {
        $url .= strpos($url, '?') === FALSE ? '?' : '&';
        $url .= drupal_http_build_query(drupal_get_destination());
    }
    // If force is enabled, remove any destination parameter.
    if ($force && isset($_GET['destination'])) {
        unset($_GET['destination']);
    }
    // We don't invoke drupal_goto() right now, as this would end the current
    // page execution unpredictably for modules. So we'll take over drupal_goto()
    // calls from somewhere else via hook_drupal_goto_alter() and make sure
    // a drupal_goto() is invoked before the page is output with
    // rules_page_build().
    $GLOBALS['_rules_action_drupal_goto_do'] = array(
        $url,
        $force,
    );
}