Ejemplo n.º 1
0
<?php

$merchdao = new MerchandiseDao();
$dao = new CommentDao();
$item_id = Utils::getUrlParam('item_id');
$comment = new Comment();
$item = $merchdao->findById($item_id);
if (array_key_exists('save', $_POST)) {
    $data = array('comment' => filter_var($_POST['comment']['comment'], FILTER_SANITIZE_STRING), 'username' => $_SESSION['username'], 'user_id' => $_SESSION['user_id'], 'item_id' => filter_var($_GET['item_id'], FILTER_SANITIZE_NUMBER_INT));
    CommentMapper::map($comment, $data);
    $dao->save($comment);
    $comment->setComment('');
}
$comment_list = $dao->find();
Ejemplo n.º 2
0
 /**
  * Aggiunge un commento al post selezionato e lo salva nel database.
  *
  * @param author: id dell'autore del commento
  * @param post: variabile di tipo Post
  * @param comment: testo del commento
  * @return post: aggiornato.
  */
 static function commentPost($post, $author, $comment)
 {
     $comment = Filter::filterText($comment);
     require_once "dataobject/Comment.php";
     require_once "dao/CommentDao.php";
     $c = new Comment(array("author" => $author, "post" => $post->getID(), "comment" => $comment));
     $commentdao = new CommentDao();
     $comm = $commentdao->save($c);
     $post->addComment($comm);
     return $post;
 }