Navigation Menu

Skip to content

Commit

Permalink
1018684 and 1116098 - porting the feature from 6.x which allows the f…
Browse files Browse the repository at this point in the history
…rontpage redirection to be disabled
  • Loading branch information
njt1982 committed Apr 28, 2011
1 parent 072aa97 commit 2a4ab9f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
19 changes: 17 additions & 2 deletions globalredirect.admin.inc
Expand Up @@ -86,9 +86,24 @@ function globalredirect_settings() {
'#default_value' => $settings['term_path_handler'],
);

$form['settings']['frontpage_redirect'] = array(
'#type' => 'checkbox',
'#title' => t('Frontpage Redirect Handler'),
'#description' => t('If enabled, any request to the frontpage path (e.g. /node) will redirect to the site root.'),
'#default_value' => $settings['frontpage_redirect'],
);

$form['buttons']['submit'] = array('#type' => 'submit', '#submit' => array('globalredirect_settings_submit_save'), '#value' => t('Save Configuration') );
$form['buttons']['reset'] = array('#type' => 'submit', '#submit' => array('globalredirect_settings_submit_reset'), '#value' => t('Reset to defaults') );
$form['buttons']['submit'] = array(
'#type' => 'submit',
'#submit' => array('globalredirect_settings_submit_save'),
'#value' => t('Save Configuration'),
);

$form['buttons']['reset'] = array(
'#type' => 'submit',
'#submit' => array('globalredirect_settings_submit_reset'),
'#value' => t('Reset to defaults'),
);

return $form;
}
Expand Down
6 changes: 6 additions & 0 deletions globalredirect.module
Expand Up @@ -85,6 +85,11 @@ function globalredirect_init() {

// Do a check if this is a front page
if (drupal_is_front_page()) {
// If frontpage redirection is disabled, halt here
if (!$settings['frontpage_redirect']) {
return;
}

// Redirect if the current request does not refer to the front page in the
// configured fashion (with or without a prefix)
if ($request_path != $prefix) {
Expand Down Expand Up @@ -339,6 +344,7 @@ function _globalredirect_get_settings($default_only = FALSE) {
'canonical' => 0,
'content_location_header' => 0,
'term_path_handler' => 1,
'frontpage_redirect' => 1,
);

if ($default_only) {
Expand Down
7 changes: 5 additions & 2 deletions globalredirect.test
Expand Up @@ -87,10 +87,11 @@ class GlobalRedirectTestCase extends DrupalWebTestCase {
),

// "node" is the default frontpage. Should redirect to base path. --- Test for frontpage redirect
// The result depends on settings
array(
'request' => 'node',
'return-code' => 301,
'expected-path' => '',
'return-code' => $settings['frontpage_redirect'] ? 301 : 200,
'expected-path' => $settings['frontpage_redirect'] ? '' : 'node',
),

// "node/1" has been defined above as having an alias ("test-node"). Should 301 redirect to the alias. --- Test for source path request on aliased path
Expand Down Expand Up @@ -254,6 +255,7 @@ class GlobalRedirectTestCaseDefault extends GlobalRedirectTestCase {
'nonclean_to_clean' => 1,
'case_sensitive_urls' => 1,
'term_path_handler' => 0,
'frontpage_redirect' => 1,
));
$this->_globalredirect_batch_test();
}
Expand All @@ -276,6 +278,7 @@ class GlobalRedirectTestCaseConfigAlpha extends GlobalRedirectTestCase {
'nonclean_to_clean' => 0,
'case_sensitive_urls' => 0,
'term_path_handler' => 1,
'frontpage_redirect' => 1,
));

$this->_globalredirect_batch_test();
Expand Down

0 comments on commit 2a4ab9f

Please sign in to comment.