/** * Guarda un comentario en la base de datos * * @param Comment $coment * El comentario a ser guardado * @throws PDOException Si ocurre un error de base de datos * @return void */ public function save(Comment $comment) { $stmt = $this->db->prepare("INSERT INTO comments(`dateComment`,`content`,`numLikes`,`author`,`idPost`) values(?,?,?,?,?)"); $stmt->execute(array($comment->getDate(), $comment->getContent(), 0, $comment->getAuthor(), $comment->getIdPost())); }
function add_comment() { $this->assertLoggedIn(); try { $this->setTitle('Add Comment'); $content_id = $this->args('content_id'); $content_type = $this->args('content_type'); $content = Comment::getContent($content_id, $content_type); if (!is_object($content)) { throw new Exception("That content does not exist."); } if (!$content->isHydrated()) { throw new Exception("That content does not exist."); } if (!$content->canComment()) { throw new Exception("You cannot comment on this content."); } $form = $this->_createAddCommentForm($content_id, $content_type); //handle our form if ($form->checkSubmitAndValidate($this->args())) { $comment = new Comment(); $comment->set('content_id', $form->data('content_id')); $comment->set('content_type', $form->data('content_type')); $comment->set('comment', $form->data('comment')); $comment->set('user_id', User::$me->id); $comment->set('comment_date', date("Y-m-d H:i:s")); $comment->save(); Activity::log("commented on " . $content->getLink() . "."); $this->forwardToUrl($content->getUrl()); } $this->set('form', $form); } catch (Exception $e) { $this->setTitle('Add Comment - Error'); $this->set('megaerror', $e->getMessage()); } }
if (!$client->query('time.getGMTTime')) { die("Something went wrong - " . $client->getErrorCode() . $client->getErrorMessage()); } echo($client->getResponse());*/ /*---------- Design Patterns: Decorator Pattern ----------*/ print "<br/><br/>"; $bbcode_enabled = 0; $emoticon_enabled = 1; $post = new Post(); $comment = new Comment(); $post->filter("Test Title: A Test", "Lorem Ipsum Amet"); $comment->filter("Dolot avenus persina olatus"); if ($bbcode_enabled == false && $emoticon_enabled == false) { $postcontent = $post->getContent(); $commentcontent = $comment->getContent(); } elseif ($bbcode_enabled == true && $emoticon_enabled == false) { $bb = new BBCodeParser($post); // Passing the Post() object to BBCodeParser() $postcontent = $bb->getContent(); $bb = new BBCodeParser($comment); $commentcontent = $bb->getContent(); } elseif ($bbcode_enabled == false && $emoticon_enabled == true) { $em = new EmoticonParser($post); $postcontent = $em->getContent(); $em = new EmoticonParser($comment); $commentcontent = $em->getContent(); } /*---------- Design Patterns: Facade Pattern ----------*/ $F = new Facade(); $F->findApartments("London, Greater London", "mapdiv");
if ($comment->getAuthor() == $uid) { $permEdit = true; } $blog_user = Database::get()->querySingle("SELECT user_id FROM blog_post WHERE id = ?d", $comment->getRid()); if ($blog_user->user_id == $uid) { $permEdit = true; } if (isset($is_admin) && $is_admin) { $permEdit = true; } } if ($permEdit) { if ($comment->edit($_POST['commentText'])) { $response[0] = 'OK'; $response[1] = "<div class='alert alert-success'>".$langCommentsSaveSuccess."</div>"; $response[2] = '<div id="comment_content-'.$comment->getId().'">'.q($comment->getContent()).'</div>'; } else { $response[0] = 'ERROR'; $response[1] = "<div class='alert alert-warning'>".$langCommentsSaveFail."</div>"; } } else { $response[0] = 'ERROR'; $response[1] = "<div class='alert alert-warning'>".$langCommentsEditNoPerm."</div>"; } } else { $response[0] = 'ERROR'; $response[1] = "<div class='alert alert-warning'>".$langCommentsLoadFail."</div>"; } echo json_encode($response); } }
/** * Saves a comment * * @param Comment $comment The comment to save * @throws PDOException if a database error occurs * @return void */ public function save(Comment $comment) { $stmt = $this->db->prepare("INSERT INTO comments(content, author, post) values (?,?,?)"); $stmt->execute(array($comment->getContent(), $comment->getAuthor()->getUsername(), $comment->getPost()->getId())); }
if (getUser()->getRank() < RANK_WRITER) { header("Location: " . orongoURL("orongo-admin/index.php?msg=0")); exit; } $comment = null; $view->setTitle("Viewing Comment"); try { $comment = new Comment($id); } catch (Exception $e) { if ($e->getCode() == COMMENT_NOT_EXIST) { header("Location: " . orongoURL("orongo-admin/manage.php?msg=0&obj=comments")); exit; } else { header("Location: " . orongoURL("orongo-admin/index.php?msg=2")); exit; } } $form = new AdminFrontendForm(100, l("Comment") . " (" . $comment->getID() . ")", "GET", "", false); $form->addInput("ID", "id", "text", $comment->getID(), false, true); $form->addInput("Date", "date", "text", date("Y-m-d H:i:s", $comment->getTimestamp()), false, true); $form->addInput("Commenter", "title", "text", $comment->getAuthorName(), false, true); $form->addInput("Comment", "content", "textarea", $comment->getContent(), false, true); $form->addButton("Delete", false, orongoURL("orongo-admin/delete.php?comment." . $id)); $view->addObject($form); $view->render(); break; default: header("Location: " . orongoURL("orongo-admin/index.php?msg=1")); exit; break; }