Esempio n. 1
0
 /**
  * 删除我的发帖.
  * 
  * @access public
  * @return void
  */
 public function deletePostAction()
 {
     $ids = I('post.ids', []);
     $ids = array_map(function ($id) {
         if ((int) $id > 0) {
             return (int) $id;
         }
     }, $ids);
     $postType = (int) I('post.postType', 0);
     // 发贴类型: 0: 分类, 1: 社区资讯.
     $allowType = [0, 1];
     if (empty($ids) || !in_array($postType, $allowType, TRUE)) {
         $this->setAjaxData(Message::PARAM_ERROR, Message::get(Message::PARAM_ERROR))->myAjaxReturn();
     }
     $loginedInfo = $this->getLoginedUserInfo();
     // 登录的用户信息.
     $model = NULL;
     switch ($postType) {
         case 0:
             $model = new CtgDataModel();
             break;
         case 1:
             $model = new SqDataModel();
             break;
         default:
     }
     try {
         $result = $model->remove($loginedInfo['uid'], $ids, TRUE);
         if ($result) {
             $this->setAjaxData(Message::SUCCESS, '删除成功')->myAjaxReturn();
         } else {
             $this->setAjaxData(Message::FAILED, '删除失败')->myAjaxReturn();
         }
     } catch (\Exception $e) {
         $this->setAjaxData($e->getCode(), $e->getMessage())->myAjaxReturn();
     }
 }