summaryrefslogtreecommitdiff
path: root/modules/user
diff options
context:
space:
mode:
Diffstat (limited to 'modules/user')
-rw-r--r--modules/user/user-picture.tpl.php2
-rw-r--r--modules/user/user-profile.tpl.php2
-rw-r--r--modules/user/user.api.php16
-rw-r--r--modules/user/user.install2
-rw-r--r--modules/user/user.module12
-rw-r--r--modules/user/user.test36
6 files changed, 66 insertions, 4 deletions
diff --git a/modules/user/user-picture.tpl.php b/modules/user/user-picture.tpl.php
index a33d2661d..ee8218786 100644
--- a/modules/user/user-picture.tpl.php
+++ b/modules/user/user-picture.tpl.php
@@ -12,6 +12,8 @@
* check_plain() before use.
*
* @see template_preprocess_user_picture()
+ *
+ * @ingroup themeable
*/
?>
<?php if ($user_picture): ?>
diff --git a/modules/user/user-profile.tpl.php b/modules/user/user-profile.tpl.php
index a1611c835..0a64fed84 100644
--- a/modules/user/user-profile.tpl.php
+++ b/modules/user/user-profile.tpl.php
@@ -30,6 +30,8 @@
* @see user-profile-item.tpl.php
* Where the html is handled for each item in the group.
* @see template_preprocess_user_profile()
+ *
+ * @ingroup themeable
*/
?>
<div class="profile"<?php print $attributes; ?>>
diff --git a/modules/user/user.api.php b/modules/user/user.api.php
index f610408dc..64c863fe4 100644
--- a/modules/user/user.api.php
+++ b/modules/user/user.api.php
@@ -299,6 +299,14 @@ function hook_user_login(&$edit, $account) {
/**
* The user just logged out.
*
+ * Note that when this hook is invoked, the changes have not yet been written to
+ * the database, because a database transaction is still in progress. The
+ * transaction is not finalized until the save operation is entirely completed
+ * and user_save() goes out of scope. You should not rely on data in the
+ * database at this time as it is not updated yet. You should also note that any
+ * write/update database queries executed from this hook are also not committed
+ * immediately. Check user_save() and db_transaction() for more info.
+ *
* @param $account
* The user object on which the operation was just performed.
*/
@@ -317,6 +325,14 @@ function hook_user_logout($account) {
* The module should format its custom additions for display and add them to the
* $account->content array.
*
+ * Note that when this hook is invoked, the changes have not yet been written to
+ * the database, because a database transaction is still in progress. The
+ * transaction is not finalized until the save operation is entirely completed
+ * and user_save() goes out of scope. You should not rely on data in the
+ * database at this time as it is not updated yet. You should also note that any
+ * write/update database queries executed from this hook are also not committed
+ * immediately. Check user_save() and db_transaction() for more info.
+ *
* @param $account
* The user object on which the operation is being performed.
* @param $view_mode
diff --git a/modules/user/user.install b/modules/user/user.install
index 217577de7..cff873a45 100644
--- a/modules/user/user.install
+++ b/modules/user/user.install
@@ -384,7 +384,7 @@ function user_update_dependencies() {
* An array of permissions names.
* @param $module
* The name of the module defining the permissions.
- * @ingroup update-api-6.x-to-7.x
+ * @ingroup update_api
*/
function _update_7000_user_role_grant_permissions($rid, array $permissions, $module) {
// Grant new permissions for the role.
diff --git a/modules/user/user.module b/modules/user/user.module
index 47ac64273..0e074d97b 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -187,7 +187,7 @@ function user_entity_info() {
}
/**
- * Entity uri callback.
+ * Entity URI callback.
*/
function user_uri($user) {
return array(
@@ -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;
}
}
@@ -2574,6 +2574,14 @@ function user_build_content($account, $view_mode = 'full', $langcode = NULL) {
// Remove previously built content, if exists.
$account->content = array();
+ // Allow modules to change the view mode.
+ $context = array(
+ 'entity_type' => 'user',
+ 'entity' => $account,
+ 'langcode' => $langcode,
+ );
+ drupal_alter('entity_view_mode', $view_mode, $context);
+
// Build fields content.
field_attach_prepare_view('user', array($account->uid => $account), $view_mode, $langcode);
entity_prepare_view('user', array($account->uid => $account), $langcode);
diff --git a/modules/user/user.test b/modules/user/user.test
index b53db0769..92af9fa9a 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.');
+ }
+
}
/**