本文整理匯總了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, '添加讚失敗');
}
}
}
示例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, '添加讚失敗');
}
}
}