public function listAction($productId = 0, $commentId = 0) { $productId = intval($productId); $commentId = intval($commentId); $productId = $productId > 0 ? $productId : $this->request->getPost("product_id", "int"); if ($commentId == 0) { $commentId = intval($this->request->getPost("comment_id", "int")); } if ($productId < 1 || $commentId < 0) { $this->flashJson(500, array(), "非法主求"); return; } $comments = CommentModel::find(array("product_id={$productId} AND reply_to_comment_id={$commentId}", 'order' => "addtime DESC", 'limit' => 10)); $this->view->setVar('comments', $comments); }
public function messagesAction() { if (!$this->user) { $this->flashJson(403); exit; } $comments = CommentModel::find(array('reply_to_user_id=' . $this->user->id, 'order' => 'addtime DESC')); $this->view->setVar('comments', $comments); }
public function detailAction($productId) { $productId = intval($productId); if ($productId <= 0) { $this->flash->error("产品ID必须大于0!"); exit(1); } $product = ProductModel::findFirst('id=' . $productId); if (empty($product)) { $this->flash->error("抱歉,您请求的产品不存在!"); exit(1); } $comments = CommentModel::find(array("product_id={$productId} AND reply_to_comment_id=0", 'order' => "addtime DESC", 'limit' => 10)); $otherProducts = ProductModel::find(array('id != ' . $productId, 'order' => 'likeit DESC', 'limit' => 9)); $this->view->setVar("other_products", $otherProducts); $this->view->setVar("comments", $comments); $this->view->setVar("product", $product); }