Esempio n. 1
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. 2
0
 /**
  * @param ChildComment $comment The ChildComment object to add.
  */
 protected function doAddComment(ChildComment $comment)
 {
     $this->collComments[] = $comment;
     $comment->setPack($this);
 }