Commit a478badb authored by Dries's avatar Dries

- Patch #602234 by rocket_nova, neochief: contact yourself tab in user profile when you're admin.

parent f09dcf17
......@@ -122,16 +122,16 @@ function _contact_personal_tab_access($account) {
return FALSE;
}
// User administrators should always have access to personal contact forms.
if (user_access('administer users')) {
return TRUE;
}
// Users may not contact themselves.
if ($user->uid == $account->uid) {
return FALSE;
}
// User administrators should always have access to personal contact forms.
if (user_access('administer users')) {
return TRUE;
}
// If the requested user has disabled their contact form, or this preference
// has not yet been saved, do not allow users to contact them.
if (empty($account->data['contact'])) {
......
......@@ -41,6 +41,17 @@ function setUp() {
* Tests access to the personal contact form.
*/
function testPersonalContactAccess() {
// Test allowed access to admin user's contact form.
$this->drupalLogin($this->web_user);
$this->drupalGet('user/' . $this->admin_user->uid . '/contact');
$this->assertResponse(200);
// Test denied access to admin user's own contact form.
$this->drupalLogout();
$this->drupalLogin($this->admin_user);
$this->drupalGet('user/' . $this->admin_user->uid . '/contact');
$this->assertResponse(403);
// Test allowed access to user with contact form enabled.
$this->drupalLogin($this->web_user);
$this->drupalGet('user/' . $this->contact_user->uid . '/contact');
......@@ -60,10 +71,16 @@ function testPersonalContactAccess() {
$this->drupalGet('user/' . $this->contact_user->uid . '/contact');
$this->assertResponse(200);
// Test that anonymous users can access admin user's contact form.
$this->drupalGet('user/' . $this->admin_user->uid . '/contact');
$this->assertResponse(200);
// Revoke the personal contact permission for the anonymous user.
user_role_revoke_permissions(DRUPAL_ANONYMOUS_RID, array('access user contact forms'));
$this->drupalGet('user/' . $this->contact_user->uid . '/contact');
$this->assertResponse(403);
$this->drupalGet('user/' . $this->admin_user->uid . '/contact');
$this->assertResponse(403);
// Disable the personal contact form.
$this->drupalLogin($this->admin_user);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment