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


PHP UserAction::recordAction方法代码示例

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


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

示例1: actionFavor

 /**
  * 问题的赞成反对及其他点赞
  */
 public function actionFavor()
 {
     //        Users::checkPower('favor');
     $type = zmf::filterInput($_POST['type'], 't', 1);
     $keyid = zmf::filterInput($_POST['keyid']);
     if (!$keyid) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     }
     if (!isset($type) or empty($type) or !in_array($type, array('naodong'))) {
         //Forbidden::updateTimes();
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (zmf::actionLimit('favor-' . $type, $keyid)) {
         $this->jsonOutPut(0, '操作太频繁,请稍后再试');
     }
     if ($type == 'naodong') {
         $classify = 'favorNaodong';
         $model = new Naodong();
         $field = 'favors';
     }
     if (!$model) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     $info = $model->findByPk($keyid);
     if (!$info) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     } elseif ($info['status'] != Posts::STATUS_PASSED) {
         $this->jsonOutPut(0, '您操作的内容正在审核或已删除');
     }
     //        elseif ($info['uid'] == zmf::uid()) {
     //            $this->jsonOutPut(0, '不能操作自己的哦~');
     //        }
     if (UserAction::checkAction($keyid, $classify)) {
         if (UserAction::delAction($keyid, $classify)) {
             if ($field) {
                 $model->updateCounters(array($field => -1), 'id=:id', array(':id' => $keyid));
             }
             $this->jsonOutPut(3, '取消赞成功');
         } else {
             $this->jsonOutPut(0, '取消赞失败');
         }
     } else {
         if (UserAction::recordAction($keyid, $classify, $info['uid'])) {
             if ($field) {
                 if ($model->updateCounters(array($field => 1), 'id=:id', array(':id' => $keyid))) {
                     if ($type == 'naodong') {
                         $_url = CHtml::link('查看详情', array('index/view', 'id' => $keyid));
                         $_content = '您的作品有了新的赞,' . $_url;
                         $toNotice = true;
                     }
                     if ($toNotice) {
                         $_noticedata = array('uid' => $info['uid'], 'authorid' => $this->uid, 'content' => $_content, 'new' => 1, 'type' => 'favor', 'cTime' => zmf::now(), 'from_id' => $keyid, 'from_num' => 1);
                         Notification::add($_noticedata);
                     }
                 }
             }
             $this->jsonOutPut(1, '添加赞成功');
         } else {
             $this->jsonOutPut(0, '添加赞失败');
         }
     }
 }
开发者ID:ph7pal,项目名称:naodong,代码行数:65,代码来源:AjaxController.php

示例2: actionFavor

 /**
  * 问题的赞成反对及其他点赞
  */
 public function actionFavor()
 {
     Users::checkPower('favor');
     $type = zmf::filterInput($_POST['type'], 't', 1);
     $keyid = zmf::filterInput($_POST['keyid']);
     if (!$keyid) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     }
     if (!isset($type) or empty($type) or !in_array($type, array('post', 'image', 'poipost', 'poitips', 'answer', 'dislike-answer', 'goods'))) {
         //Forbidden::updateTimes();
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (zmf::actionLimit('favor-' . $type, $keyid)) {
         $this->jsonOutPut(0, '操作太频繁,请稍后再试');
     }
     if ($type == 'image') {
         $classify = 'favorImg';
         $model = new Attachments();
         $field = 'favor';
     } elseif ($type == 'post') {
         $classify = 'favorPost';
         $model = new Posts();
         $field = 'favors';
     } elseif ($type == 'poipost') {
         $classify = 'favorPoiPost';
         $model = new PoiPost();
         $field = 'favor';
     } elseif ($type == 'poitips') {
         $classify = 'favorPoiTips';
         $model = new PoiTips();
         $field = 'favor';
     } elseif ($type == 'answer') {
         $classify = 'favorAnswer';
         $model = new Answer();
         $field = 'favor';
     } elseif ($type == 'dislike-answer') {
         $classify = 'dislikeAnswer';
         $model = new Answer();
         $field = 'nouse';
     } elseif ($type == 'goods') {
         $classify = 'goods';
         $model = new Goods();
         $field = 'favors';
     }
     if (!$model) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     $info = $model->findByPk($keyid);
     if (!$info) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     } elseif ($info['status'] != Posts::STATUS_PASSED) {
         $this->jsonOutPut(0, '您操作的内容正在审核或已删除');
     } elseif ($info['uid'] == zmf::uid()) {
         $this->jsonOutPut(0, '不能操作自己的哦~');
     }
     if ($type == 'answer' || $type == 'dislike-answer') {
         if ($type == 'answer') {
             if (UserAction::checkAction($keyid, 'dislikeAnswer')) {
                 UserAction::delAction($keyid, 'dislikeAnswer');
                 $model->updateCounters(array('nouse' => -1), 'id=:id', array(':id' => $keyid));
             }
         } else {
             if (UserAction::checkAction($keyid, 'favorAnswer')) {
                 UserAction::delAction($keyid, 'favorAnswer');
                 $model->updateCounters(array('favor' => -1), 'id=:id', array(':id' => $keyid));
             }
         }
     }
     if (UserAction::checkAction($keyid, $classify)) {
         if (UserAction::delAction($keyid, $classify)) {
             if ($field) {
                 $model->updateCounters(array($field => -1), 'id=:id', array(':id' => $keyid));
             }
             $this->jsonOutPut(3, '取消赞成功');
         } else {
             $this->jsonOutPut(0, '取消赞失败');
         }
     } else {
         if (UserAction::recordAction($keyid, $classify, $info['uid'])) {
             if ($field) {
                 $model->updateCounters(array($field => 1), 'id=:id', array(':id' => $keyid));
             }
             $this->jsonOutPut(1, '添加赞成功');
         } else {
             $this->jsonOutPut(0, '添加赞失败');
         }
     }
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:91,代码来源:AjaxController.php


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