protected function loadReplyList() { $this->num_per_page = $this->db->real_escape_string($this->num_per_page); $this->page_num = $this->db->real_escape_string($this->page_num); $this->userID = trim($this->db->real_escape_string($this->userID)); $start_record = $this->page_num * $this->num_per_page; $query = "select newsID from news_reply where userID = {$this->userID} group by newsID order by newsID desc"; $resultArr = $this->db->query($query); if (is_array($resultArr) && count($resultArr) > 0) { $this->replyArr['newsList'] = array(); foreach ($resultArr as $idx => $row) { $newsObj = new News($row['newsID'], 0); $news = $newsObj->getArray(); $this->replyArr['newsList'][$idx] = array("newsID" => $news['news']['newsID'], "newsTitle" => $news['news']['newsTitle'], "newsQuestion" => $news['news']['newsQuestion'], "newsCreatedDateTime" => $news['news']['nacreatedDateTime']); $newsReplyListObj = new NewsReplyList($row['newsID']); $newsReplyArr = $newsReplyListObj->getArray(); $this->replyArr['newsList'][$idx]['replyList'] = $this->filterReplyList($newsReplyArr['replyList']); } } }
require_once '../nl-init.php'; require_once '../class/nl-auth-class.php'; require_once '../class/nl-reply-class.php'; require_once 'api_headers.php'; try { if (is_get()) { $newsID = _get("newsID", 0); $replyID = _get("replyID", 0); $userID = _get("userID", 0); $withSubReplies = _get("withSubReplies", true); if ($replyID > 0) { $reply = new Reply($replyID, $withSubReplies); echo $reply->getJson(); } else { if ($newsID > 0) { $replies = new NewsReplyList($newsID, $withSubReplies); echo $replies->getJson(); } else { if ($userID > 0) { $auth = Auth::getInstance(); if ($userID != $auth->getUserID()) { throw new Exception("unauthorised operation", -1); } $replies = new UserReplyList($userID); echo $replies->getJson(); } } } } else { if (is_post()) { $auth = Auth::getInstance();