function createFromDBRow($row) { $type = $row[DB::POST_TYPE]; if ($type == Post::NEWS || $type == Post::VIDEOREP) { $content = $row[DB::POST_CONTENT]; } else { $content = unserialize($row[DB::POST_CONTENT]); } $data = array("title" => $row[DB::POST_TITLE], "subtitle" => $row[DB::POST_SUBTITLE], "headline" => $row[DB::POST_HEADLINE], "author" => intval($row[DB::POST_AUTHOR]), "tags" => $row[DB::POST_TAGS], "categories" => $row[DB::POST_CATEGORIES], "content" => $content, "visible" => $row[DB::POST_VISIBLE] > 0, "type" => $type, "place" => $row[DB::POST_PLACE]); if ($type == Post::NEWS) { require_once "dataobject/News.php"; $p = new News($data); } else { if ($type == Post::VIDEOREP) { require_once "dataobject/VideoReportage.php"; $p = new VideoReportage($data); } else { if ($type == Post::ALBUM) { require_once "dataobject/Album.php"; $p = new Album($data); } else { if ($type == Post::MAGAZINE) { require_once "dataobject/Magazine.php"; $p = new Magazine($data); } else { if ($type == Post::PHOTOREP) { require_once "dataobject/PhotoReportage.php"; $p = new PhotoReportage($data); } else { if ($type == Post::PLAYLIST) { require_once "dataobject/Playlist.php"; $p = new Playlist($data); } else { if ($type == Post::COLLECTION) { require_once "dataobject/Collection.php"; $p = new Collection($data); } else { throw new Exception("Errore!!! Il tipo inserito non esiste!"); } } } } } } } $p->setCreationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[DB::POST_CREATION_DATE]))); $p->setID(intval($row[DB::POST_ID])); if (!is_null($row[DB::POST_MODIFICATION_DATE])) { $p->setModificationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[DB::POST_MODIFICATION_DATE]))); } else { $p->setModificationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[DB::POST_CREATION_DATE]))); } if ($this->loadComments) { require_once 'dao/CommentDao.php'; $commentDao = new CommentDao(); $commentDao->loadAll($p); } $p->setPermalink($row[DB::POST_PERMALINK]); require_once 'dao/VoteDao.php'; $voteDao = new VoteDao(); $p->setVote($voteDao->getVote($p)); //setto lo stato $p->setEditable($row[DB::EDITABLE])->setRemovable($row[DB::REMOVABLE]); $p->setBlackContent($row[DB::BLACK_CONTENT])->setRedContent($row[DB::RED_CONTENT])->setYellowContent($row[DB::YELLOW_CONTENT])->setAutoBlackContent($row[DB::AUTO_BLACK_CONTENT]); $user = Session::getUser(); if ($this->loadReports && AuthorizationManager::canUserDo(AuthorizationManager::READ_REPORTS, $r)) { require_once 'dao/ReportDao.php'; $reportDao = new ReportDao(); $reportDao->loadAll($p); } $p->setAccessCount($this->getAccessCount($p)); return $p; }
<?php require '../dao/CommentDao.php'; $userId = $_REQUEST['userId']; $commentDao = new CommentDao(); if ($commentDao->setAllRead($userId) > 0) { echo json_encode(array('mesg' => 'success', 'result' => true)); } else { echo json_encode(array('mesg' => 'fail', 'result' => false)); }
<?php require '../dao/CommentDao.php'; $commentId = $_REQUEST['commentId']; $commentDao = new CommentDao(); if ($commentDao->cancelComment($commentId) > 0) { echo json_encode(array('mesg' => 'success', 'result' => true)); } else { echo json_encode(array('mesg' => 'fail', 'result' => false)); }
static function loadComment($id) { require_once "dao/CommentDao.php"; $commentdao = new CommentDao(); return $commentdao->load($id); }
<?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();
/** * * @param type $link * @return Analyse */ public function getAnAnalysis($link, $withoutComments = false) { $statment = "SELECT * FROM analysis \r\n WHERE link = :link LIMIT 1"; $query = $this->session->prepare($statment); $query->bindParam(":link", $link); $query->execute(); if ($query->rowCount() > 0) { $result = $query->fetch(PDO::FETCH_ASSOC); $analysis = $this->buildAnalysis($result); $analysis->setId($result['id']); $analysis->setText($result['text']); if (!$withoutComments) { $commentDao = new CommentDao($this->session); $analysis->loadComments($commentDao->getCommentsOfAnAnalysis($analysis)); } return $analysis; } return null; }
<?php require '../dao/CommentDao.php'; $userId = $_REQUEST['userId']; $commentDao = new CommentDao(); echo $commentDao->userCommentList($userId);
<?php require '../dao/CommentDao.php'; require '../dao/PostDao.php'; $userId = $_REQUEST['userId']; $postId = $_REQUEST['postId']; $commentDao = new CommentDao(); $postDao = new PostDao(); $obj = json_decode($commentDao->postCommentList($postId)); $obj->post = json_decode($postDao->getPostById($userId, $postId))->resultArray[0]; echo json_encode($obj);
<?php require '../dao/CommentDao.php'; $replyId = $_REQUEST['replyId']; $commentDao = new CommentDao(); if ($commentDao->setRead($replyId) > 0) { echo json_encode(array('mesg' => 'success', 'result' => true)); } else { echo json_encode(array('mesg' => 'fail', 'result' => false)); }
<?php require '../dao/CommentDao.php'; $userId = $_REQUEST['userId']; $postId = $_REQUEST['postId']; $commentTarget = $_REQUEST['commentTarget']; //回复的用户,他的userId $commentContent = $_REQUEST['commentContent']; $commentAfter = (int) $_REQUEST['commentAfter']; //回复的评论id,如果直接评论的帖子,传空值即可 $isAnonymity = (int) $_REQUEST['isAnonymity']; //此条评论是否匿名 boolean $commentDao = new CommentDao(); if (($obj = $commentDao->setComment($postId, $userId, $commentTarget, $commentContent, $commentAfter, $isAnonymity)) != null) { echo json_encode(array('mesg' => 'success', 'result' => true, 'data' => json_decode($obj)->resultArray[0])); } else { echo json_encode(array('mesg' => 'fail', 'result' => false, 'data' => null)); }