Esempio n. 1
0
 public function createAction()
 {
     $resp = new Response();
     $request = $this->app->request;
     $post_id = $request->getPostParam('post_id');
     $content = $request->getPostParam('content');
     if ($post_id && $content) {
         $comment = new Comment(array('post_id' => $post_id, 'content' => $content, 'user_id' => $this->app->user->getId()));
         $comment->save();
     }
     $resp->redirectBack();
     return $resp;
 }
Esempio n. 2
0
 protected function addComment()
 {
     if (!$this->data["permission"]) {
         $this->sendFlashMessage("You do not have permission add comments to pack with ID " . $this->data["pack"]->getId() . ".", "error");
     } else {
         if (isset($_POST["text"])) {
             $comment = new Comment();
             $comment->setText($_POST["text"]);
             $comment->setUser($this->data["loggedUser"]);
             $comment->setPack($this->data["pack"]);
             if ($comment->save() <= 0) {
                 $failures = $comment->getValidationFailures();
                 var_dump($failures);
                 exit;
                 setStatus("error");
                 if (count($failures) > 0) {
                     foreach ($failures as $failure) {
                         $this->sendFlashMessage("Your comment has not been added. " . $failure->getMessage(), "error");
                     }
                 }
             }
         } else {
             setHTTPStatusCode("400");
         }
         $this->viewString(json_encode($this->data["response"]));
     }
 }
Esempio n. 3
0
 public function comment($name)
 {
     $id = explode('-', $name);
     $id = $id[0];
     if (!$this->isLogged()) {
         $this->addPopup('danger', 'Pro přidání komentáře musíte být přihlášeni.');
         redirectTo('/clanek/' . $id);
     }
     $comment = new Comment();
     $comment->setIdUser($_SESSION["user"]->getId());
     $comment->setIdArticle($id);
     $comment->setContent($_POST["comment_text"]);
     $comment->save();
     $this->addPopup('success', 'Váš komentář byl úspěšně přidán.');
     redirectTo('/clanek/' . $id);
 }
Esempio n. 4
0
 protected function comment($id)
 {
     //TODO: check rights
     $note = NoteQuery::create()->findPK($id);
     $comment = new Comment();
     $comment->setUser($this->params['user']);
     $comment->setNote($note);
     $comment->setText($_POST['msg']);
     $comment->save();
     $this->params['comments'] = $note->getComments();
     $this->renderType('js.phtml');
 }