summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2012-10-06 17:51:39 (GMT)
committer webchick2012-10-06 17:51:39 (GMT)
commit2cbf221c01ea322c0ddbf72dbb8797f75a28037a (patch)
tree17abe73f465e2e49e9a19473162ecf410f658c19
parent408f3a0d9c78bb7f0a633d77b8f2644652acf009 (diff)
Issue #1197622 by lyricnz, xjm, tim.plunkett, Cottser: Fixed My account (disabled).
-rw-r--r--modules/menu/menu.admin.inc9
-rw-r--r--modules/user/user.module2
-rw-r--r--modules/user/user.test36
3 files changed, 44 insertions, 3 deletions
diff --git a/modules/menu/menu.admin.inc b/modules/menu/menu.admin.inc
index 226c3b0..868ddad 100644
--- a/modules/menu/menu.admin.inc
+++ b/modules/menu/menu.admin.inc
@@ -99,7 +99,14 @@ function _menu_overview_tree_form($tree) {
$mlid = 'mlid:' . $item['mlid'];
$form[$mlid]['#item'] = $item;
$form[$mlid]['#attributes'] = $item['hidden'] ? array('class' => array('menu-disabled')) : array('class' => array('menu-enabled'));
- $form[$mlid]['title']['#markup'] = l($item['title'], $item['href'], $item['localized_options']) . ($item['hidden'] ? ' (' . t('disabled') . ')' : '');
+ $form[$mlid]['title']['#markup'] = l($item['title'], $item['href'], $item['localized_options']);
+ if ($item['hidden']) {
+ $form[$mlid]['title']['#markup'] .= ' (' . t('disabled') . ')';
+ }
+ elseif ($item['link_path'] == 'user' && $item['module'] == 'system') {
+ $form[$mlid]['title']['#markup'] .= ' (' . t('logged in users only') . ')';
+ }
+
$form[$mlid]['hidden'] = array(
'#type' => 'checkbox',
'#title' => t('Enable @title menu link', array('@title' => $item['title'])),
diff --git a/modules/user/user.module b/modules/user/user.module
index 72880f7..0e074d9 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -1873,7 +1873,7 @@ function user_menu_link_alter(&$link) {
*/
function user_translated_menu_link_alter(&$link) {
// Hide the "User account" link for anonymous users.
- if ($link['link_path'] == 'user' && $link['module'] == 'system' && user_is_anonymous()) {
+ if ($link['link_path'] == 'user' && $link['module'] == 'system' && !$GLOBALS['user']->uid) {
$link['hidden'] = 1;
}
}
diff --git a/modules/user/user.test b/modules/user/user.test
index b53db07..92af9fa 100644
--- a/modules/user/user.test
+++ b/modules/user/user.test
@@ -1487,7 +1487,7 @@ class UserAutocompleteTestCase extends DrupalWebTestCase {
/**
- * Test user-links in secondary menu.
+ * Tests user links in the secondary menu.
*/
class UserAccountLinksUnitTests extends DrupalWebTestCase {
public static function getInfo() {
@@ -1498,6 +1498,10 @@ class UserAccountLinksUnitTests extends DrupalWebTestCase {
);
}
+ function setUp() {
+ parent::setUp('menu');
+ }
+
/**
* Tests the secondary menu.
*/
@@ -1533,6 +1537,36 @@ class UserAccountLinksUnitTests extends DrupalWebTestCase {
$element = $this->xpath('//ul[@id=:menu_id]', array(':menu_id' => 'secondary-menu-links'));
$this->assertEqual(count($element), 0, 'No secondary-menu for logged-out users.');
}
+
+ /**
+ * Tests disabling the 'My account' link.
+ */
+ function testDisabledAccountLink() {
+ // Create an admin user and log in.
+ $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer menu')));
+
+ // Verify that the 'My account' link is enabled.
+ $this->drupalGet('admin/structure/menu/manage/user-menu');
+ $this->assertFieldChecked('edit-mlid2-hidden', "The 'My account' link is enabled by default.");
+
+ // Disable the 'My account' link.
+ $edit = array(
+ 'mlid:2[hidden]' => FALSE,
+ );
+ $this->drupalPost('admin/structure/menu/manage/user-menu', $edit, t('Save configuration'));
+
+ // Get the homepage.
+ $this->drupalGet('<front>');
+
+ // Verify that the 'My account' link does not appear when disabled.
+ $link = $this->xpath('//ul[@id=:menu_id]/li/a[contains(@href, :href) and text()=:text]', array(
+ ':menu_id' => 'secondary-menu-links',
+ ':href' => 'user',
+ ':text' => 'My account',
+ ));
+ $this->assertEqual(count($link), 0, 'My account link is not in the secondary menu.');
+ }
+
}
/**