summaryrefslogtreecommitdiff
path: root/modules/shortcut
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-10-15 04:21:02 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-10-15 04:21:02 +0000
commitf6ceeca471955b02b4d87ec69a8363d51f282698 (patch)
tree1c68f96382bc919b971a6873b719c1e958d0dbde /modules/shortcut
parent4a9cd0fcc1374a852044bb5cc8893f978862bf67 (diff)
downloadbrdo-f6ceeca471955b02b4d87ec69a8363d51f282698.tar.gz
brdo-f6ceeca471955b02b4d87ec69a8363d51f282698.tar.bz2
#901404 by bleen18, David_Rothstein: Fixed Saving a shortcut from the admin screen doesn't work correctly if a path alias is used.
Diffstat (limited to 'modules/shortcut')
-rw-r--r--modules/shortcut/shortcut.admin.inc10
-rw-r--r--modules/shortcut/shortcut.test13
2 files changed, 22 insertions, 1 deletions
diff --git a/modules/shortcut/shortcut.admin.inc b/modules/shortcut/shortcut.admin.inc
index 27384a669..92492be7c 100644
--- a/modules/shortcut/shortcut.admin.inc
+++ b/modules/shortcut/shortcut.admin.inc
@@ -459,6 +459,9 @@ function _shortcut_link_form_elements($shortcut_link = NULL) {
'link_path' => ''
);
}
+ else {
+ $shortcut_link['link_path'] = drupal_get_path_alias($shortcut_link['link_path']);
+ }
$form['shortcut_link']['#tree'] = TRUE;
$form['shortcut_link']['link_title'] = array(
@@ -504,7 +507,11 @@ function shortcut_link_edit_validate($form, &$form_state) {
* Submit handler for shortcut_link_edit().
*/
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_link = array_merge($form_state['values']['original_shortcut_link'], $form_state['values']['shortcut_link']);
+
menu_link_save($shortcut_link);
$form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $shortcut_link['menu_name'];
drupal_set_message(t('The shortcut %link has been updated.', array('%link' => $shortcut_link['link_title'])));
@@ -556,6 +563,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']);
+
// Add the link to the end of the list.
$shortcut_set->links[] = $shortcut_link;
shortcut_set_reset_link_weights($shortcut_set);
diff --git a/modules/shortcut/shortcut.test b/modules/shortcut/shortcut.test
index 34ae06183..abb531ccc 100644
--- a/modules/shortcut/shortcut.test
+++ b/modules/shortcut/shortcut.test
@@ -36,8 +36,10 @@ class ShortcutTestCase extends DrupalWebTestCase {
// Create users.
$this->admin_user = $this->drupalCreateUser(array('access toolbar', 'administer shortcuts', 'create article content', 'create page content', 'access content overview'));
$this->shortcut_user = $this->drupalCreateUser(array('customize shortcut links', 'switch shortcut sets'));
+
// Create a node.
$this->node = $this->drupalCreateNode(array('type' => 'article'));
+
// Log in as admin and grab the default shortcut set.
$this->drupalLogin($this->admin_user);
$this->set = shortcut_set_load(SHORTCUT_DEFAULT_SET_NAME);
@@ -114,10 +116,19 @@ class ShortcutLinksTestCase extends ShortcutTestCase {
function testShortcutLinkAdd() {
$set = $this->set;
+ // Create an alias for the node so we can test aliases.
+ $path = array(
+ 'source' => 'node/' . $this->node->nid,
+ 'alias' => $this->randomName(8),
+ );
+ path_save($path);
+
+ // Create some paths to test.
$test_cases = array(
array('path' => 'admin'),
array('path' => 'admin/config/system/site-information'),
array('path' => "node/{$this->node->nid}/edit"),
+ array('path' => $path['alias']),
);
// Check that each new shortcut links where it should.
@@ -131,7 +142,7 @@ 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($test['path'], $paths), 'Shortcut created: '. $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.');
}
}