Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
224
Merge Requests
224
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
39671958
Commit
39671958
authored
Dec 23, 2014
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2393577
by vladan.me, Berdir: Access issue with default settings set to disabled
parent
508aa670
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
core/modules/contact/src/Access/ContactPageAccess.php
core/modules/contact/src/Access/ContactPageAccess.php
+6
-4
core/modules/contact/src/Tests/ContactPersonalTest.php
core/modules/contact/src/Tests/ContactPersonalTest.php
+9
-0
No files found.
core/modules/contact/src/Access/ContactPageAccess.php
View file @
39671958
...
...
@@ -83,12 +83,14 @@ public function access(UserInterface $user, AccountInterface $account) {
return
$access
;
}
// If the requested user has disabled their contact form, do not allow users
// to contact them.
// Load preference of the requested user.
$account_data
=
$this
->
userData
->
get
(
'contact'
,
$contact_account
->
id
(),
'enabled'
);
if
(
isset
(
$account_data
)
&&
empty
(
$account_data
))
{
if
(
isset
(
$account_data
))
{
// Forbid access if the requested user has disabled their contact form.
if
(
empty
(
$account_data
))
{
return
$access
;
}
}
// If the requested user did not save a preference yet, deny access if the
// configured default is disabled.
else
if
(
!
$this
->
configFactory
->
get
(
'contact.settings'
)
->
get
(
'user_default_enabled'
))
{
...
...
core/modules/contact/src/Tests/ContactPersonalTest.php
View file @
39671958
...
...
@@ -185,6 +185,15 @@ function testPersonalContactAccess() {
$this
->
drupalPostForm
(
NULL
,
array
(
'contact'
=>
TRUE
),
t
(
'Save'
));
$this
->
assertFieldChecked
(
'edit-contact--2'
);
$this
->
assertTrue
(
\
Drupal
::
service
(
'user.data'
)
->
get
(
'contact'
,
$this
->
webUser
->
id
(),
'enabled'
),
'Personal contact form enabled'
);
// Test with disabled global default contact form in combination with a user
// that has the contact form enabled.
\
Drupal
::
config
(
'contact.settings'
)
->
set
(
'user_default_enabled'
,
FALSE
)
->
save
();
$this
->
contactUser
=
$this
->
drupalCreateUser
();
\
Drupal
::
service
(
'user.data'
)
->
set
(
'contact'
,
$this
->
contactUser
->
id
(),
'enabled'
,
1
);
$this
->
drupalGet
(
'user/'
.
$this
->
contactUser
->
id
()
.
'/contact'
);
$this
->
assertResponse
(
200
);
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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