Add Comment blocks

This commit is contained in:
Juan José González 2023-02-19 16:38:24 +01:00
parent 6bf1708772
commit 55fedab565
2 changed files with 24 additions and 0 deletions

View File

@ -459,6 +459,15 @@ class CommentingController extends Controller
return $form;
}
/**
* Create a form for updating an existing comment.
*
* Extend the existing form to post a comment to update a comment.
* Add an extra frield and preload existing data.
*
* @param Comment $comment
* @return Form
*/
public function UpdateForm($comment)
{
$form = $this->CommentsForm();
@ -499,6 +508,15 @@ class CommentingController extends Controller
return $this->httpError(404);
}
/**
* Request handler for update form.
*
* Get Comment to be updated and build an update form.
*
* @param HTTPRequest $request
* @throws HTTPResponse_Exception
* @return Form
*/
public function updateComment(HTTPRequest $request)
{
if ($commentID = $request->param('ParentCommentID')) {

View File

@ -381,6 +381,12 @@ class Comment extends DataObject
return false;
}
/**
* Checks if the comment can be updated by its author.
*
* @param null|int|Member $member
* @return Boolean
*/
public function canUpdate($member = null)
{
$member = $this->getMember($member);