| @@ 32-56 (lines=25) @@ | ||
| 29 | * |
|
| 30 | * @return void |
|
| 31 | */ |
|
| 32 | public function addAction() |
|
| 33 | { |
|
| 34 | $isPosted = $this->request->getPost('doCreate'); |
|
| 35 | ||
| 36 | if (!$isPosted) { |
|
| 37 | $this->response->redirect($this->request->getPost('redirect')); |
|
| 38 | } |
|
| 39 | ||
| 40 | $comment = [ |
|
| 41 | 'content' => $this->request->getPost('content'), |
|
| 42 | 'name' => $this->request->getPost('name'), |
|
| 43 | 'web' => $this->request->getPost('web'), |
|
| 44 | 'mail' => $this->request->getPost('mail'), |
|
| 45 | 'timestamp' => time(), |
|
| 46 | 'ip' => $this->request->getServer('REMOTE_ADDR'), |
|
| 47 | 'comment-flow' => $this->request->getPost('comment-flow'), |
|
| 48 | ]; |
|
| 49 | ||
| 50 | $comments = new \Phpmvc\Comment\CommentsInSession(); |
|
| 51 | $comments->setDI($this->di); |
|
| 52 | ||
| 53 | $comments->add($comment); |
|
| 54 | ||
| 55 | $this->response->redirect($this->request->getPost('redirect')); |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Edit a comment. |
|
| @@ 88-113 (lines=26) @@ | ||
| 85 | * |
|
| 86 | * @return void |
|
| 87 | */ |
|
| 88 | public function updateAction() |
|
| 89 | { |
|
| 90 | $isPosted = $this->request->getPost('doUpdate'); |
|
| 91 | ||
| 92 | if (!$isPosted) { |
|
| 93 | $this->response->redirect($this->request->getPost('redirect')); |
|
| 94 | } |
|
| 95 | ||
| 96 | $comment = [ |
|
| 97 | 'content' => $this->request->getPost('content'), |
|
| 98 | 'name' => $this->request->getPost('name'), |
|
| 99 | 'web' => $this->request->getPost('web'), |
|
| 100 | 'mail' => $this->request->getPost('mail'), |
|
| 101 | 'timestamp' => time(), |
|
| 102 | 'ip' => $this->request->getServer('REMOTE_ADDR'), |
|
| 103 | 'comment-flow' => $this->request->getPost('comment-flow'), |
|
| 104 | ]; |
|
| 105 | $id = $this->request->getPost('id'); |
|
| 106 | ||
| 107 | $comments = new \Loom\Comment\CommentsInSession(); |
|
| 108 | $comments->setDI($this->di); |
|
| 109 | ||
| 110 | $comments->update($comment, $id); |
|
| 111 | ||
| 112 | $this->response->redirect($this->request->getPost('redirect')); |
|
| 113 | } |
|
| 114 | ||
| 115 | /** |
|
| 116 | * Delete a comment. |
|