当前位置: 首页>>代码示例>>PHP>>正文


PHP Posts::updateCount方法代码示例

本文整理汇总了PHP中Posts::updateCount方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::updateCount方法的具体用法?PHP Posts::updateCount怎么用?PHP Posts::updateCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Posts的用法示例。


在下文中一共展示了Posts::updateCount方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionView

 public function actionView()
 {
     $id = zmf::val('id', 2);
     if (!$id) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $info = $this->loadModel($id);
     $pageSize = 30;
     $comments = Comments::getCommentsByPage($id, 'posts', 1, $pageSize);
     $tags = Tags::getByIds($info['tagids']);
     $relatePosts = Posts::getRelations($id, 5);
     if (!zmf::actionLimit('visit-Posts', $id, 5, 60)) {
         Posts::updateCount($id, 'Posts', 1, 'hits');
     }
     $size = '600';
     if ($this->isMobile) {
         $size = '640';
     }
     $info['content'] = zmf::text(array(), $info['content'], true, $size);
     $data = array('info' => $info, 'comments' => $comments, 'tags' => $tags, 'relatePosts' => $relatePosts, 'loadMore' => count($comments) == $pageSize ? 1 : 0);
     $this->favorited = Favorites::checkFavored($id, 'post');
     $this->pageTitle = $info['title'];
     $this->selectNav = 'posts';
     $this->render('view', $data);
 }
开发者ID:ph7pal,项目名称:momo,代码行数:25,代码来源:PostsController.php

示例2: actionIndex

 public function actionIndex()
 {
     if ($this->mySelf == 'yes') {
         $sql = "SELECT id,title,faceimg,uid,colid,cTime,updateTime FROM {{posts}} WHERE (uid='{$this->uid}' OR uid IN(SELECT logid FROM {{favorites}} WHERE uid='{$this->uid}' AND classify='user')) AND classify='" . Posts::CLASSIFY_WEDDING . "' ORDER BY cTime DESC";
     } else {
         $sql = "SELECT id,title,faceimg,uid,colid,cTime,updateTime FROM {{posts}} WHERE uid='{$this->uid}' AND classify='" . Posts::CLASSIFY_WEDDING . "' ORDER BY cTime DESC";
     }
     Posts::getAll(array('sql' => $sql), $pages, $lists);
     if (!empty($lists)) {
         foreach ($lists as $k => $p) {
             if ($p['faceimg'] > 0) {
                 $_attach = Attachments::getOne($p['faceimg']);
                 $_url = Attachments::getUrl($_attach);
                 $lists[$k]['faceimg'] = $_url;
             } else {
                 $lists[$k]['faceimg'] = '';
             }
         }
     }
     if ($this->mySelf != 'yes') {
         Posts::updateCount($this->uid, 'Users');
     }
     $data = array('posts' => $lists, 'pages' => $pages);
     $this->pageTitle = $this->userInfo['truename'] . '的主页 - ' . zmf::config('sitename');
     $this->render('index', $data);
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:26,代码来源:UsersController.php

示例3: actionView

 public function actionView($code)
 {
     $code = zmf::filterInput($code, 't', 1);
     $info = SiteInfo::model()->find('code=:code', array(':code' => $code));
     if (!$info) {
         throw new CHttpException(404, '您所查看的页面不存在');
     }
     $allInfos = SiteInfo::model()->findAll(array('select' => 'code,title', 'condition' => 'status=' . Posts::STATUS_PASSED));
     //更新访问统计
     Posts::updateCount($info['id'], 'SiteInfo');
     $data = array('info' => $info, 'allInfos' => $allInfos, 'code' => $code);
     $this->pageTitle = $info['title'] . ' - ' . zmf::config('sitename');
     $this->render('/site/siteinfo', $data);
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:14,代码来源:SiteinfoController.php

示例4: favorite

 public static function favorite($code, $type, $from = 'web', $uid = '')
 {
     if (!$code || !$type) {
         return array('status' => 0, 'msg' => '数据不全,请核实');
     }
     if (!in_array($type, array('post'))) {
         return array('status' => 0, 'msg' => '暂不允许的分类');
     }
     if (is_numeric($code)) {
         $id = $code;
     } else {
         $codeArr = Posts::decode($code);
         if ($codeArr['type'] != $type || !is_numeric($codeArr['id']) || $codeArr['id'] < 1) {
             $this->jsonOutPut(0, '您所查看的内容不存在');
         }
         $id = $codeArr['id'];
     }
     if (!$uid) {
         $uid = zmf::uid();
     }
     if ($uid) {
         if (zmf::actionLimit('favorite-' . $type, $id)) {
             return array('status' => 0, 'msg' => '操作太频繁,请稍后再试');
         }
     } else {
         //没有登录的访客点收藏时判断是否已收藏过
         if (zmf::actionLimit('favorite-' . $type, $id, 1, 86400, true)) {
             return array('status' => 1, 'msg' => '已点赞', 'state' => 1);
         }
         $uid = 0;
     }
     $postInfo = Posts::model()->findByPk($id);
     if (!$postInfo || $postInfo['status'] != Posts::STATUS_PASSED) {
         return array('status' => 0, 'msg' => '文章不存在');
     }
     $attr = array('uid' => $uid, 'logid' => $id, 'classify' => $type);
     $info = false;
     if ($uid) {
         $info = Favorites::model()->findByAttributes($attr);
     }
     if ($info) {
         if (Favorites::model()->deleteByPk($info['id'])) {
             if ($type == 'post') {
                 Posts::updateCount($id, 'Posts', -1, 'favorite');
             }
             return array('status' => 1, 'msg' => '取消点赞', 'state' => 3);
         } else {
             return array('status' => 0, 'msg' => '取消点赞失败', 'state' => 4);
         }
     } else {
         $attr['cTime'] = zmf::now();
         $model = new Favorites();
         $model->attributes = $attr;
         if ($model->save()) {
             if ($type == 'post') {
                 Posts::updateCount($id, 'Posts', 1, 'favorite');
             }
             //点赞后给对方发提醒
             $_noticedata = array('uid' => $postInfo['uid'], 'authorid' => $uid, 'content' => "您的文章【{$postInfo['title']}】有了新的赞", 'new' => 1, 'type' => 'favorite', 'cTime' => zmf::now(), 'from_id' => $model->id, 'from_num' => 1);
             Notification::add($_noticedata);
             return array('status' => 1, 'msg' => '点赞成功', 'state' => 1);
         } else {
             return array('status' => 0, 'msg' => '点赞失败', 'state' => 2);
         }
     }
 }
开发者ID:ph7pal,项目名称:momo,代码行数:66,代码来源:Posts.php

示例5: actionDelPost

 /**
  * 删除内容
  */
 public function actionDelPost()
 {
     $logid = zmf::filterInput($_POST['logid']);
     $type = zmf::filterInput($_POST['type'], 't', 1);
     $admin = false;
     if (empty($logid) or !is_numeric($logid)) {
         $this->jsonOutPut(0, Yii::t('default', 'unkownerror'));
     }
     if (!Yii::app()->request->isAjaxRequest) {
         //Forbidden::updateTimes();
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (Yii::app()->user->isGuest) {
         $this->jsonOutPut(0, Yii::t('default', 'loginfirst'));
     }
     if (!in_array($type, array('naodong', 'comment', 'notice'))) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if ($type == 'naodong') {
         $tinfo = Naodong::model()->findByPk($logid);
         if (!$tinfo) {
             $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
         } elseif ($tinfo['uid'] != zmf::uid()) {
             //                $admin = Users::checkPower('delpost', false, true);
             //                if (!$admin) {
             //                    $this->jsonOutPut(0, '请勿越权操作');
             //                }
         }
         $status = Posts::STATUS_DELED;
         $attr = array('status' => Posts::STATUS_DELED);
         if (Naodong::model()->updateByPk($logid, $attr)) {
             $this->jsonOutPut(1, '操作成功!');
         } else {
             $this->jsonOutPut(1, '操作失败!');
         }
     } elseif ($type == 'comment') {
         $cinfo = Comments::model()->findByPk($logid);
         if (!$cinfo) {
             $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
         } elseif ($cinfo['uid'] != zmf::uid()) {
             //                $admin = Users::checkPower('delcomment', false, true);
             //                if (!$admin) {
             //                    $this->jsonOutPut(0, '请勿越权操作');
             //                }
         }
         $status = Posts::STATUS_DELED;
         $attr = array('status' => $status);
         if (Comments::model()->updateByPk($logid, $attr)) {
             if (strtolower($cinfo['classify']) == 'naodong') {
                 Posts::updateCount($cinfo['logid'], 'Naodong', -1, 'comments');
             }
             $this->jsonOutPut(1, '操作成功!');
         } else {
             $this->jsonOutPut(1, '操作失败!');
         }
     } elseif ($type == 'notice') {
         $cinfo = Notification::model()->findByPk($logid);
         if (!$cinfo) {
             $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
         } elseif ($cinfo['uid'] != zmf::uid()) {
             $this->jsonOutPut(0, '请勿越权操作');
         }
         if (Notification::model()->deleteByPk($logid)) {
             $this->jsonOutPut(1, '操作成功!');
         } else {
             $this->jsonOutPut(0, '操作失败');
         }
     }
 }
开发者ID:ph7pal,项目名称:naodong,代码行数:72,代码来源:AjaxController.php

示例6: actionUpload

 public function actionUpload()
 {
     $uptype = zmf::filterInput($_GET['type'], 't', 1);
     $logid = zmf::filterInput($_GET['id']);
     //所属对象
     $reImgsize = zmf::filterInput($_GET['imgsize']);
     //返回图片的尺寸
     $fileholder = zmf::filterInput($_GET['fileholder'], 't', 1);
     //上传控件的ID
     //将ads替换为flash
     if (!isset($uptype) or !in_array($uptype, array('columns', 'coverimg', 'flash', 'link', 'album', 'posts', 'poi', 'poipost', 'answer', 'question', 'siteinfo', 'goods', 'group', 'avatar'))) {
         $this->jsonOutPut(0, '请设置上传所属类型' . $uptype);
     }
     if (Yii::app()->request->getParam('PHPSESSID')) {
         Yii::app()->session->close();
         $res = Yii::app()->session->setSessionID(Yii::app()->request->getParam('PHPSESSID'));
         Yii::app()->session->open();
     }
     if (Yii::app()->user->isGuest) {
         $this->jsonOutPut(0, Yii::t('default', 'loginfirst'));
     }
     $checkInfo = UserPower::check('addImage', true);
     if (!$checkInfo['status']) {
         $this->jsonOutPut(0, $checkInfo['msg']);
     }
     if ($uptype == 'poi') {
         if (!$logid || !is_numeric($logid)) {
             $this->jsonOutPut(0, '无效上传,请重试');
         } else {
             $poiInfo = Position::model()->findByPk($logid);
             if (!$poiInfo || $poiInfo['status'] != Posts::STATUS_PASSED) {
                 $this->jsonOutPut(0, '无效上传,请重试');
             }
         }
     }
     if (!$fileholder) {
         $fileholder = 'filedata';
     }
     if (!isset($_FILES[$fileholder]) || !is_uploaded_file($_FILES[$fileholder]["tmp_name"]) || $_FILES[$fileholder]["error"] != 0) {
         $this->jsonOutPut(0, '无效上传,请重试');
     }
     $model = new Attachments();
     $img = CUploadedFile::getInstanceByName($fileholder);
     $ext = $img->getExtensionName();
     $size = $img->getSize();
     if ($size > zmf::config('imgMaxSize')) {
         $this->jsonOutPut(0, '上传文件最大尺寸为:' . tools::formatBytes(zmf::config('imgMaxSize')));
     }
     $upExt = zmf::config("imgAllowTypes");
     if (!preg_match('/^(' . str_replace('*.', '|', str_replace(';', '', $upExt)) . ')$/i', $ext)) {
         $this->jsonOutPut(0, '上传文件扩展名必需为:' . $upExt);
     }
     $sizeinfo = getimagesize($_FILES[$fileholder]["tmp_name"]);
     if ($sizeinfo['0'] < zmf::config('imgMinWidth') or $sizeinfo[1] < zmf::config('imgMinHeight')) {
         $this->jsonOutPut(0, "要求上传的图片尺寸,宽不能不小于" . zmf::config('imgMinWidth') . "px,高不能小于" . zmf::config('imgMinHeight') . "px.");
     }
     $ctime = zmf::now();
     $uid = zmf::uid();
     $dirs = zmf::uploadDirs($ctime, 'app', $uptype, null, true);
     $fileName = uniqid() . '.' . $ext;
     $origin = $dirs['origin'];
     unset($dirs['origin']);
     $uploadedFiles = array();
     $uploadedFiles[] = array('from' => $origin . $fileName, 'to' => zmf::ftpPath($ctime, $uptype, 'origin') . $fileName);
     if (move_uploaded_file($_FILES[$fileholder]["tmp_name"], $origin . $fileName)) {
         $data = array();
         if ($uptype == 'posts') {
             $status = Posts::STATUS_DELED;
         } else {
             $status = Posts::STATUS_PASSED;
         }
         $data['uid'] = $uid;
         $data['logid'] = $logid;
         $data['filePath'] = $fileName;
         $data['fileDesc'] = $fileName;
         $data['classify'] = $uptype;
         $data['covered'] = '0';
         $data['cTime'] = time();
         $data['status'] = $status;
         $data['width'] = $sizeinfo[0];
         $data['height'] = $sizeinfo[1];
         $data['size'] = $size;
         if ($uptype == 'poi') {
             $data['areaid'] = $poiInfo['areaid'];
         }
         $model->attributes = $data;
         if ($model->validate()) {
             if ($model->save()) {
                 if ($uptype == 'poi') {
                     Posts::updateCount($logid, 'Position', 1, 'attach');
                 } elseif ($uptype == 'avatar') {
                     Users::model()->updateByPk($uid, array('avatar' => $model->id));
                 }
                 //                    $image = Yii::app()->image->load($origin . $fileName);
                 //                    $_quality = zmf::config('imgQuality');
                 //                    $quality = isset($quality) ? $quality : 100;
                 Yii::import('application.vendors.thinkphp.*');
                 require_once 'ImageGd.php';
                 if (in_array($uptype, array('group', 'avatar'))) {
                     $rate = 1;
//.........这里部分代码省略.........
开发者ID:ph7pal,项目名称:wedding,代码行数:101,代码来源:AttachmentsController.php

示例7: actionView

 public function actionView($id)
 {
     $keyid = zmf::filterInput($id);
     $checkInfo = Posts::checkInfo($info, $keyid, 'posts');
     if (!$checkInfo['status']) {
         $this->message(0, $checkInfo['msg']);
     }
     if ($info['redirect'] != '') {
         $this->redirect(zmf::config('domain') . $info['redirect'], true, 301);
     }
     if ($info['classify'] == Posts::CLASSIFY_BLOG) {
         $this->redirect(zmf::config('blog_domain') . '/post/' . $keyid . '.html', true, 301);
     }
     $groupInfo = array();
     if ($info['groupid'] > 0) {
         $groupInfo = WeddingGroup::getOne($info['groupid']);
         if ($groupInfo['status'] != Posts::STATUS_PASSED) {
             $this->message(0, '该团队已不存在');
         }
         $groupInfo['avatar'] = Users::getAvatar($groupInfo['avatar']);
     }
     $keyid = $info['id'];
     $this->currentColid = $info['colid'];
     $colinfo = Column::getSimpleInfo($info['colid']);
     $breads[] = CHtml::link('作品', array('posts/index'));
     if ($colinfo) {
         $breads[] = CHtml::link($colinfo['title'], array('posts/index', 'colid' => $colinfo['id']));
     }
     //更新统计
     Posts::updateCount($keyid, 'Posts');
     //获取用户推荐文章
     $sqlUser = "SELECT id,title,faceimg,uid,colid,cTime,updateTime FROM {{posts}} WHERE id!='{$id}' AND uid='{$info['uid']}' AND classify=" . Posts::CLASSIFY_WEDDING . " ORDER BY hits DESC LIMIT 5";
     $userPosts = Yii::app()->db->createCommand($sqlUser)->queryAll();
     //获取标签
     $info['tagids'] = join(',', explode(',', $info['tagids']));
     $relPosts = array();
     if ($info['tagids'] != '') {
         //获取与本文类似文章
         //计算方法为与本文提到的标签相关文章出现次数最多的
         $relPosts = Posts::getTopPostsByTags($id, $info['tagids']);
         $_sql = "SELECT id,title FROM {{tags}} WHERE classify='posts' AND id IN({$info['tagids']})";
         $info['tagids'] = Yii::app()->db->createCommand($_sql)->queryAll();
     }
     if (!empty($userPosts)) {
         foreach ($userPosts as $k => $p) {
             if ($p['faceimg'] > 0) {
                 $_attach = Attachments::getOne($p['faceimg']);
                 $_url = Attachments::getUrl($_attach);
                 $userPosts[$k]['faceimg'] = $_url;
             } else {
                 $userPosts[$k]['faceimg'] = '';
             }
         }
     }
     if (!empty($relPosts)) {
         foreach ($relPosts as $k => $p) {
             if ($p['faceimg'] > 0) {
                 $_attach = Attachments::getOne($p['faceimg']);
                 $_url = Attachments::getUrl($_attach);
                 $relPosts[$k]['faceimg'] = $_url;
             } else {
                 $relPosts[$k]['faceimg'] = '';
             }
         }
     }
     //判断是否已收藏和赞过
     if (!Yii::app()->user->isGuest) {
         if (Favorites::checkFavored($keyid, 'posts')) {
             $this->favorited = true;
         }
         if (UserAction::checkAction($keyid, 'favorPost')) {
             $this->favored = true;
         }
     }
     $breads[] = $info['title'];
     $data = array('colinfo' => $colinfo, 'data' => $info, 'breads' => $breads, 'userPosts' => $userPosts, 'relPosts' => $relPosts, 'groupInfo' => $groupInfo);
     $this->pageTitle = (!empty($colinfo) ? "【{$colinfo['title']}】" : '') . $info['title'] . ' - ' . zmf::config('sitename');
     $this->render('view', $data);
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:79,代码来源:PostsController.php

示例8: actionMedia

 public function actionMedia()
 {
     $id = tools::val('id');
     if (!$id || !is_numeric($id)) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $userInfo = Users::getUserInfo($id);
     if (!$userInfo || $userInfo['status'] != Posts::STATUS_PASSED) {
         throw new CHttpException(404, '您所查看的页面不存在或已删除');
     }
     $criteria = new CDbCriteria();
     $criteria->order = 'hits DESC';
     //        $criteria->select='id,truename,`desc`,avatar,posts,hits';
     $criteria->condition = "uid='{$id}' AND status=" . Posts::STATUS_PASSED;
     $count = Naodong::model()->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = $this->pageSize;
     $pager->applyLimit($criteria);
     $posts = Naodong::model()->findAll($criteria);
     $posts = self::foreachNaodong($posts);
     Posts::updateCount($id, 'Users');
     $this->pageTitle = $userInfo['truename'] . ' - ' . zmf::config('sitename');
     $this->mobileTitle = $userInfo['truename'];
     $this->pageDescription = $userInfo['desc'] != '' ? $userInfo['desc'] : zmf::config('siteDesc');
     $this->render('media', array('pages' => $pager, 'posts' => $posts, 'userInfo' => $userInfo));
 }
开发者ID:ph7pal,项目名称:naodong,代码行数:26,代码来源:IndexController.php

示例9: actionView

 public function actionView($id)
 {
     $id = zmf::filterInput($id);
     $info = $this->loadModel($id);
     if ($info['redirect'] > 0) {
         $this->redirect(array('position/view', 'id' => $info['redirect']));
     }
     $_title = '';
     if ($info['title_cn'] != '') {
         $_title = $info['title_cn'];
     }
     if ($info['title_en'] != '' && $_title != '') {
         $_title .= '(' . $info['title_en'] . ')';
     } elseif ($info['title_local'] && $_title != '') {
         $_title .= '(' . $info['title_local'] . ')';
     } elseif ($info['title_en'] != '') {
         $_title .= $info['title_en'];
     } else {
         $_title .= $info['title_local'];
     }
     $_address = '';
     if ($info['address_cn'] != '') {
         $_address = $info['address_cn'];
     } elseif ($info['address_en'] != '') {
         $_address = $info['address_en'];
     } else {
         $_address = $info['address_local'];
     }
     if (!Yii::app()->user->isGuest) {
         if (Favorites::checkFavored($id, 'poi')) {
             $this->favorited = true;
         }
         $tipinfo = PoiPost::model()->findByAttributes(array('logid' => $id, 'uid' => Yii::app()->user->id), 'status=' . Posts::STATUS_PASSED);
         if ($tipinfo) {
             $this->tiped = $tipinfo;
         }
     }
     $info->faceimg = Attachments::faceImg($info, 600);
     //获取图片
     $images = Attachments::model()->findAll(array('condition' => "logid=:id AND " . ($info['faceimg'] > 0 ? "id!=" . $info['faceimg'] . ' AND ' : '') . " classify='poi' AND status=" . Posts::STATUS_PASSED, 'select' => 'id,filePath,classify,cTime', 'limit' => 6, 'order' => 'favor DESC', 'params' => array(':id' => $id)));
     $breads = array();
     $breads[] = CHtml::link('目的地', array('position/index'));
     if ($info['areaid']) {
         $areaInfo = Area::model()->findByPk($info['areaid']);
         if ($areaInfo) {
             $breads[] = CHtml::link($areaInfo['title'], array('position/index', 'areaid' => $areaInfo['id']));
         }
     }
     //获取购买地址
     $buylinks = array();
     if ($info['classify'] == Position::HOTEL) {
         $buylinks = Buylink::getAll('poi', $info->id);
     }
     //更新访问统计
     Posts::updateCount($id, 'Position');
     $breads[] = $_title;
     $this->pageTitle = $_title . ' - ' . zmf::config('sitename');
     $this->pageDescription = '【' . $_title . '】位于' . $_address . ',' . zmf::subStr($info['content'], 200);
     $this->render('view', array('info' => $info, 'type' => $type, 'breads' => $breads, 'buylinks' => $buylinks, 'images' => $images));
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:60,代码来源:PositionController.php

示例10: actionInfo

 public function actionInfo()
 {
     $code = zmf::val('code', 1);
     $_title = SiteInfo::exTypes($code);
     if (!$_title) {
         throw new CHttpException(404, '您所查看的页面不存在');
     }
     $info = SiteInfo::model()->find('code=:code', array(':code' => $code));
     if (!$info) {
         throw new CHttpException(404, '您所查看的页面不存在');
     }
     $allInfos = SiteInfo::model()->findAll(array('select' => 'code,title', 'condition' => 'code!=:code AND status=' . Posts::STATUS_PASSED, 'params' => array(':code' => $code)));
     //更新访问统计
     Posts::updateCount($info['id'], 'SiteInfo');
     $data = array('info' => $info, 'code' => $code, 'allInfos' => $allInfos);
     $this->pageTitle = $info['title'] . ' - ' . zmf::config('sitename');
     $this->selectNav = 'about';
     $this->render('about', $data);
 }
开发者ID:ph7pal,项目名称:momo,代码行数:19,代码来源:SiteController.php

示例11: actionComment

 /**
  * 写评论
  */
 public function actionComment()
 {
     if (!Yii::app()->request->isAjaxRequest) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (Yii::app()->user->isGuest) {
         $this->jsonOutPut(2, Yii::t('default', 'loginfirst'));
     } else {
         $uid = zmf::uid();
     }
     $checkInfo = UserPower::check('addComment', true);
     if (!$checkInfo['status']) {
         $this->jsonOutPut(0, $checkInfo['msg']);
     }
     $keyid = zmf::filterInput($_POST['k']);
     $to = zmf::filterInput($_POST['to']);
     $type = zmf::filterInput($_POST['t'], 't', 1);
     $content = zmf::filterInput($_POST['c'], 't', 1);
     if (!isset($type) or !in_array($type, array('attachments', 'posts', 'poipost', 'poitips', 'question', 'answer', 'yueban', 'goods'))) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (!isset($keyid) or !is_numeric($keyid)) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     }
     if (!$content) {
         $this->jsonOutPut(0, '评论不能为空哦~');
     }
     $status = Posts::STATUS_PASSED;
     //判断是否应被禁止
     //        $forbidInfo = Posts::isForbidden($content, 'comment');
     //        if ($forbidInfo['status'] != Posts::STATUS_PASSED) {
     //            //todo,增加用户非法操作次数
     //            $status = Posts::STATUS_STAYCHECK;
     //        }
     //处理文本
     $filter = Posts::handleContent($content);
     $content = $filter['content'];
     if (Yii::app()->session['checkHasBadword'] == 'yes') {
         $status = Posts::STATUS_STAYCHECK;
     }
     $model = new Comments();
     $ainfo = Posts::getSimpleInfo(array('keyid' => $keyid, 'origin' => strtolower($type)));
     if (!$ainfo) {
         $this->jsonOutPut(0, Yii::t('default', 'contentnotexists'));
     }
     $toNotice = true;
     if ($ainfo['uid'] == $uid) {
         $toNotice = false;
     }
     //当为商品评论且不是回复某人时,不提醒发布商品的人
     if ($type == 'goods' && !$to) {
         $toNotice = false;
     }
     $touid = $ainfo['uid'];
     if ($to) {
         $comInfo = Posts::getSimpleInfo(array('keyid' => $to, 'origin' => 'comments'));
         if (!$comInfo || $comInfo['status'] != Posts::STATUS_PASSED) {
             $to = '';
         } elseif ($comInfo['uid'] == $uid) {
             $toNotice = false;
         } else {
             $touid = $comInfo['uid'];
             $toNotice = true;
         }
     }
     $intoData = array('logid' => $keyid, 'uid' => $uid, 'content' => $content, 'cTime' => zmf::now(), 'classify' => $type, 'platform' => $this->platform, 'tocommentid' => $to, 'status' => $status);
     unset(Yii::app()->session['checkHasBadword']);
     $model->attributes = $intoData;
     if ($model->validate()) {
         if ($model->save()) {
             if ($type == 'answer') {
                 Answer::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_url = CHtml::link('查看详情', array('question/answer', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 $_content = '您的回答有了新的评论,' . $_url;
             } elseif ($type == 'poitips') {
                 PoiTips::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_url = CHtml::link('查看详情', array('question/answer', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 $_content = '您的短评有了新的评论,' . $_url;
             } elseif ($type == 'poipost') {
                 $_url = CHtml::link('查看详情', array('poipost/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 PoiPost::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_content = '您的点评有了新的评论,' . $_url;
             } elseif ($type == 'question') {
                 $_url = CHtml::link('查看详情', array('question/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 Question::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_content = '您的提问有了新的评论,' . $_url;
             } elseif ($type == 'posts') {
                 $_url = CHtml::link('查看详情', array('posts/index', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 Posts::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_content = '您的文章有了新的评论,' . $_url;
             } elseif ($type == 'attachments') {
                 $_url = CHtml::link('查看详情', array('attachments/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 Attachments::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_content = '您的图片有了新的评论,' . $_url;
             } elseif ($type == 'yueban') {
                 $_url = CHtml::link('查看详情', array('yueban/index', 'areaid' => $ainfo['toAreaid'], 'year' => zmf::time($ainfo['startTime'], 'Y'), 'month' => zmf::time($ainfo['startTime'], 'm'), 'day' => zmf::time($ainfo['startTime'], 'd')));
                 Posts::updateCount($keyid, 'UserYueban', 1, 'comments');
//.........这里部分代码省略.........
开发者ID:ph7pal,项目名称:wedding,代码行数:101,代码来源:AjaxController.php


注:本文中的Posts::updateCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。