diff options
author | David Rothstein <drothstein@gmail.com> | 2012-10-28 23:12:12 -0400 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2012-10-28 23:12:12 -0400 |
commit | 160e454224fdd1dd2492cc0c29238143bfc1984e (patch) | |
tree | 81e9589d53dc3c9cafbf0e3303b5132306f72e1c | |
parent | a6d4a9199115922a614002e7423e3ffc5102b107 (diff) | |
download | brdo-160e454224fdd1dd2492cc0c29238143bfc1984e.tar.gz brdo-160e454224fdd1dd2492cc0c29238143bfc1984e.tar.bz2 |
Issue #934714 by swentel, caiovlp, dcam | Coornail: Fixed Cannot add frontpage as shortcut.
-rw-r--r-- | modules/shortcut/shortcut.admin.inc | 11 | ||||
-rw-r--r-- | modules/shortcut/shortcut.module | 4 | ||||
-rw-r--r-- | modules/shortcut/shortcut.test | 4 |
3 files changed, 14 insertions, 5 deletions
diff --git a/modules/shortcut/shortcut.admin.inc b/modules/shortcut/shortcut.admin.inc index 91ce7c837..c592a3185 100644 --- a/modules/shortcut/shortcut.admin.inc +++ b/modules/shortcut/shortcut.admin.inc @@ -471,7 +471,7 @@ function _shortcut_link_form_elements($shortcut_link = NULL) { ); } else { - $shortcut_link['link_path'] = drupal_get_path_alias($shortcut_link['link_path']); + $shortcut_link['link_path'] = ($shortcut_link['link_path'] == '<front>') ? '' : drupal_get_path_alias($shortcut_link['link_path']); } $form['shortcut_link']['#tree'] = TRUE; @@ -520,7 +520,11 @@ function shortcut_link_edit_validate($form, &$form_state) { */ function shortcut_link_edit_submit($form, &$form_state) { // Normalize the path in case it is an alias. - $form_state['values']['shortcut_link']['link_path'] = drupal_get_normal_path($form_state['values']['shortcut_link']['link_path']); + $shortcut_path = drupal_get_normal_path($form_state['values']['shortcut_link']['link_path']); + if (empty($shortcut_path)) { + $shortcut_path = '<front>'; + } + $form_state['values']['shortcut_link']['link_path'] = $shortcut_path; $shortcut_link = array_merge($form_state['values']['original_shortcut_link'], $form_state['values']['shortcut_link']); @@ -577,6 +581,9 @@ function shortcut_admin_add_link($shortcut_link, &$shortcut_set, $limit = NULL) // Normalize the path in case it is an alias. $shortcut_link['link_path'] = drupal_get_normal_path($shortcut_link['link_path']); + if (empty($shortcut_link['link_path'])) { + $shortcut_link['link_path'] = '<front>'; + } // Add the link to the end of the list. $shortcut_set->links[] = $shortcut_link; diff --git a/modules/shortcut/shortcut.module b/modules/shortcut/shortcut.module index 71284bb84..2f6db0ad3 100644 --- a/modules/shortcut/shortcut.module +++ b/modules/shortcut/shortcut.module @@ -617,8 +617,8 @@ function shortcut_valid_link($path) { if ($path != $normal_path) { $path = $normal_path; } - // Only accept links that correspond to valid paths on the site itself. - return !url_is_external($path) && menu_get_item($path); + // An empty path is valid too and will be converted to <front>. + return (!url_is_external($path) && menu_get_item($path)) || empty($path) || $path == '<front>'; } /** diff --git a/modules/shortcut/shortcut.test b/modules/shortcut/shortcut.test index 322c63f11..801d58550 100644 --- a/modules/shortcut/shortcut.test +++ b/modules/shortcut/shortcut.test @@ -124,6 +124,7 @@ class ShortcutLinksTestCase extends ShortcutTestCase { // Create some paths to test. $test_cases = array( + array('path' => ''), array('path' => 'admin'), array('path' => 'admin/config/system/site-information'), array('path' => "node/{$this->node->nid}/edit"), @@ -141,7 +142,8 @@ class ShortcutLinksTestCase extends ShortcutTestCase { $this->assertResponse(200); $saved_set = shortcut_set_load($set->set_name); $paths = $this->getShortcutInformation($saved_set, 'link_path'); - $this->assertTrue(in_array(drupal_get_normal_path($test['path']), $paths), 'Shortcut created: '. $test['path']); + $test_path = empty($test['path']) ? '<front>' : $test['path']; + $this->assertTrue(in_array(drupal_get_normal_path($test_path), $paths), 'Shortcut created: '. $test['path']); $this->assertLink($title, 0, 'Shortcut link found on the page.'); } } |