From 55fedab56536af5e4b5b96322801a8ded788292a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Gonz=C3=A1lez?= Date: Sun, 19 Feb 2023 16:38:24 +0100 Subject: [PATCH] Add Comment blocks --- src/Controllers/CommentingController.php | 18 ++++++++++++++++++ src/Model/Comment.php | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/src/Controllers/CommentingController.php b/src/Controllers/CommentingController.php index 7041ab4..85641aa 100644 --- a/src/Controllers/CommentingController.php +++ b/src/Controllers/CommentingController.php @@ -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')) { diff --git a/src/Model/Comment.php b/src/Model/Comment.php index c7be015..294efc1 100755 --- a/src/Model/Comment.php +++ b/src/Model/Comment.php @@ -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);