summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-09-30 12:59:38 -0700
committerwebchick <webchick@24967.no-reply.drupal.org>2011-09-30 12:59:38 -0700
commit39994dd88f83bd20a72ee1b39e9e16854266e146 (patch)
tree40cb4fba07f4ceaf44a77f329bcc0c1c1a40affe
parentc80806ab7531f0571a4c7bd842238bba13ab383d (diff)
downloadbrdo-39994dd88f83bd20a72ee1b39e9e16854266e146.tar.gz
brdo-39994dd88f83bd20a72ee1b39e9e16854266e146.tar.bz2
Issue #790770 by swentel, jhodgdon, David_Rothstein, naxoc: Fixed 'Add to shortcuts' link should not appear on 403/404 pages.
-rw-r--r--modules/shortcut/shortcut.module6
-rw-r--r--modules/shortcut/shortcut.test23
2 files changed, 28 insertions, 1 deletions
diff --git a/modules/shortcut/shortcut.module b/modules/shortcut/shortcut.module
index 8642d9de7..f8ddcc24f 100644
--- a/modules/shortcut/shortcut.module
+++ b/modules/shortcut/shortcut.module
@@ -643,7 +643,11 @@ function shortcut_renderable_links($shortcut_set = NULL) {
* Implements hook_preprocess_page().
*/
function shortcut_preprocess_page(&$variables) {
- if (shortcut_set_edit_access()) {
+ // Only display the shortcut link if the user has the ability to edit
+ // shortcuts and if the page's actual content is being shown (for example,
+ // we do not want to display it on "access denied" or "page not found"
+ // pages).
+ if (shortcut_set_edit_access() && ($item = menu_get_item()) && $item['access']) {
$link = $_GET['q'];
$query_parameters = drupal_get_query_parameters();
if (!empty($query_parameters)) {
diff --git a/modules/shortcut/shortcut.test b/modules/shortcut/shortcut.test
index 75a5a67bf..322c63f11 100644
--- a/modules/shortcut/shortcut.test
+++ b/modules/shortcut/shortcut.test
@@ -197,6 +197,29 @@ class ShortcutLinksTestCase extends ShortcutTestCase {
$mlids = $this->getShortcutInformation($saved_set, 'mlid');
$this->assertFalse(in_array($set->links[0]['mlid'], $mlids), 'Successfully deleted a shortcut.');
}
+
+ /**
+ * Tests that the add shortcut link is not displayed for 404/403 errors.
+ *
+ * Tests that the "Add to shortcuts" link is not displayed on a page not
+ * found or a page the user does not have access to.
+ */
+ function testNoShortcutLink() {
+ // Change to a theme that displays shortcuts.
+ variable_set('theme_default', 'seven');
+
+ $this->drupalGet('page-that-does-not-exist');
+ $this->assertNoRaw('add-shortcut', t('Add to shortcuts link was not shown on a page not found.'));
+
+ // The user does not have access to this path.
+ $this->drupalGet('admin/modules');
+ $this->assertNoRaw('add-shortcut', t('Add to shortcuts link was not shown on a page the user does not have access to.'));
+
+ // Verify that the testing mechanism works by verifying the shortcut
+ // link appears on admin/content/node.
+ $this->drupalGet('admin/content/node');
+ $this->assertRaw('add-shortcut', t('Add to shortcuts link was shown on a page the user does have access to.'));
+ }
}
/**