|
@@ 46-54 (lines=9) @@
|
| 43 |
|
$newForm = new ModelForm('new-comment-form', Comment::class); |
| 44 |
|
$loggedInUser = $this->di->userController->getLoggedInUserId(); |
| 45 |
|
|
| 46 |
|
if ($this->di->request->getMethod() == 'POST' && $this->di->session->has("username")) { |
| 47 |
|
$comment = $newForm->populateModel(); |
| 48 |
|
$newForm->validate(); |
| 49 |
|
if ($newForm->isValid()) { |
| 50 |
|
$comment->user = $loggedInUser; |
| 51 |
|
$this->comments->save($comment); |
| 52 |
|
$this->di->response->redirect("comment/$postid#{$comment->id}"); |
| 53 |
|
} |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
$comments = $this->getComments($postid, $loggedInUser); |
| 57 |
|
$sortBy = $this->sortBy(); |
|
@@ 86-94 (lines=9) @@
|
| 83 |
|
|
| 84 |
|
$replyForm = new ModelForm('reply-comment-form', Comment::class); |
| 85 |
|
|
| 86 |
|
if ($this->di->request->getMethod() == 'POST') { |
| 87 |
|
$comment = $replyForm->populateModel(); |
| 88 |
|
$replyForm->validate(); |
| 89 |
|
if ($replyForm->isValid()) { |
| 90 |
|
$comment->user = $loggedInUser; |
| 91 |
|
$this->comments->save($comment); |
| 92 |
|
$this->di->response->redirect("comment/$postid#{$comment->id}"); |
| 93 |
|
} |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
$newForm = new ModelForm('new-comment-form', Comment::class); |
| 97 |
|
|