function _globalredirect_is_active in Global Redirect 7
Same name and namespace in other branches
- 6 globalredirect.module \_globalredirect_is_active()
Internal function to determine if GlobalRedirect is active. Several rules have to be checked prior to execution, such as an empty post array, the site must be online and we cannot be running in CLI mode (eg Drush).
1 call to _globalredirect_is_active()
- globalredirect_init in ./
globalredirect.module - Implements hook_init().
File
- ./
globalredirect.module, line 340 - The Global Redirect module redirects for all paths which have aliases but are not using the aliases which reduces the risk of duplicate content.
Code
function _globalredirect_is_active($settings) {
/**
* We need to do a test to make sure we only clean up URL's for the main
* request. This stops modules such as the Ad Module which had its own script
* in its folder doing a bootstrap which invoked hook_init() and caused some
* banners to get "cleaned up"
*
* @see http://drupal.org/node/205810
* @see http://drupal.org/node/278615
*/
if ($_SERVER['SCRIPT_NAME'] != $GLOBALS['base_path'] . 'index.php') {
return FALSE;
}
/**
* If this is a command line request (Drush, etc), skip processing.
*/
if (drupal_is_cli()) {
return FALSE;
}
/**
* If the site is in offline mode there is little point doing any of this as
* you might end up redirecting to a 503.
*/
if (variable_get('maintenance_mode', 0) == 1) {
return FALSE;
}
/**
* If there is something posted, GlobalRedirect is not active
*/
if (!empty($_POST)) {
return FALSE;
}
/**
* If drupal_get_path_alias isn't preset, GlobalRedirect is not active
*/
if (!function_exists('drupal_get_path_alias')) {
return FALSE;
}
/**
* If menu_check is enabled AND the menu_get_item function is missing,
* GlobalRedirect is disabled.
*/
if ($settings['menu_check'] && !function_exists('menu_get_item')) {
return FALSE;
}
/**
* If we're going to ignore the admin path, return false.
* This is added to allow people to continue to get to the 'admin*' paths,
* even if the module is misbehaving.
*/
if ($settings['ignore_admin_path'] && (arg(0) == 'admin' || arg(0) == 'batch')) {
return FALSE;
}
/**
* We seem to have passed all the tests - let say we're active
*/
return TRUE;
}