#901404 by bleen18, David_Rothstein: Fixed Saving a shortcut from the admin screen doesn't work correctly if a path alias is used.
parent
4a9cd0fcc1
commit
f6ceeca471
|
@ -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);
|
||||
|
|
|
@ -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.');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue