Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
a478badb
Commit
a478badb
authored
Jun 29, 2012
by
Dries Buytaert
Browse files
- Patch
#602234
by rocket_nova, neochief: contact yourself tab in user profile when you're admin.
parent
f09dcf17
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/modules/contact/contact.module
View file @
a478badb
...
...
@@ -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'
]))
{
...
...
core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
View file @
a478badb
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment