Пример #1
0
 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);
 }
Пример #2
0
 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);
 }
Пример #3
0
 public function removeAction()
 {
     if (!$this->user) {
         $this->flashJson(403);
         return;
     }
     $commentId = intval($this->request->getPost('comment_id'));
     if ($commentId < 1) {
         $this->flashJson(500, array(), "非法请求");
         return;
     }
     $commentModel = CommentModel::findFirst($commentId);
     if (empty($commentModel)) {
         $this->flashJson(500, array(), "该评论不存");
         return;
     }
     if ($this->user->id != $commentModel->user_id) {
         $this->flashJson(500, array(), "您没有权限删除别人的评论");
         return;
     }
     $this->flashJson(200);
     return;
 }