當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserAction::delAction方法代碼示例

本文整理匯總了PHP中UserAction::delAction方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserAction::delAction方法的具體用法?PHP UserAction::delAction怎麽用?PHP UserAction::delAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserAction的用法示例。


在下文中一共展示了UserAction::delAction方法的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::delAction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。