Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
95019fa6
Commit
95019fa6
authored
Aug 12, 2014
by
alexpott
Browse files
Issue
#2318827
by larowlan, thehong | mgifford: Fixed Can't unpublish a comment.
parent
36675eaa
Changes
4
Hide whitespace changes
Inline
Side-by-side
core/modules/comment/src/CommentForm.php
View file @
95019fa6
...
@@ -114,7 +114,7 @@ public function form(array $form, FormStateInterface $form_state) {
...
@@ -114,7 +114,7 @@ public function form(array $form, FormStateInterface $form_state) {
// Prepare default values for form elements.
// Prepare default values for form elements.
if
(
$is_admin
)
{
if
(
$is_admin
)
{
$author
=
$comment
->
getAuthorName
();
$author
=
$comment
->
getAuthorName
();
$status
=
$comment
->
isPublished
();
$status
=
$comment
->
getStatus
();
if
(
empty
(
$form_state
[
'comment_preview'
]))
{
if
(
empty
(
$form_state
[
'comment_preview'
]))
{
$form
[
'#title'
]
=
$this
->
t
(
'Edit comment %title'
,
array
(
$form
[
'#title'
]
=
$this
->
t
(
'Edit comment %title'
,
array
(
'%title'
=>
$comment
->
getSubject
(),
'%title'
=>
$comment
->
getSubject
(),
...
...
core/modules/comment/src/CommentInterface.php
View file @
95019fa6
...
@@ -212,6 +212,14 @@ public function getChangedTime();
...
@@ -212,6 +212,14 @@ public function getChangedTime();
*/
*/
public
function
isPublished
();
public
function
isPublished
();
/**
* Returns the comment's status.
*
* @return int
* One of CommentInterface::PUBLISHED or CommentInterface::NOT_PUBLISHED
*/
public
function
getStatus
();
/**
/**
* Sets the published status of the comment entity.
* Sets the published status of the comment entity.
*
*
...
...
core/modules/comment/src/Entity/Comment.php
View file @
95019fa6
...
@@ -471,6 +471,13 @@ public function isPublished() {
...
@@ -471,6 +471,13 @@ public function isPublished() {
return
$this
->
get
(
'status'
)
->
value
==
CommentInterface
::
PUBLISHED
;
return
$this
->
get
(
'status'
)
->
value
==
CommentInterface
::
PUBLISHED
;
}
}
/**
* {@inheritdoc}
*/
public
function
getStatus
()
{
return
$this
->
get
(
'status'
)
->
value
;
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
...
...
core/modules/comment/src/Tests/CommentAdminTest.php
View file @
95019fa6
...
@@ -136,6 +136,8 @@ function testApprovalNodeInterface() {
...
@@ -136,6 +136,8 @@ function testApprovalNodeInterface() {
$this
->
assertResponse
(
403
,
'Forged comment approval was denied.'
);
$this
->
assertResponse
(
403
,
'Forged comment approval was denied.'
);
$this
->
drupalGet
(
'comment/1/approve'
,
array
(
'query'
=>
array
(
'token'
=>
'forged'
)));
$this
->
drupalGet
(
'comment/1/approve'
,
array
(
'query'
=>
array
(
'token'
=>
'forged'
)));
$this
->
assertResponse
(
403
,
'Forged comment approval was denied.'
);
$this
->
assertResponse
(
403
,
'Forged comment approval was denied.'
);
$this
->
drupalGet
(
'comment/1/edit'
);
$this
->
assertFieldChecked
(
'edit-status-0'
);
$this
->
drupalGet
(
'node/'
.
$this
->
node
->
id
());
$this
->
drupalGet
(
'node/'
.
$this
->
node
->
id
());
$this
->
clickLink
(
t
(
'Approve'
));
$this
->
clickLink
(
t
(
'Approve'
));
$this
->
drupalLogout
();
$this
->
drupalLogout
();
...
...
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