/** * 将文章置为某种状态,如置顶 */ public function actionSetStatus() { Users::checkPower('setstatus'); $keyid = zmf::filterInput($_POST['a']); $classify = zmf::filterInput($_POST['b'], 't', 1); $_status = zmf::filterInput($_POST['c'], 't', 1); if (!$keyid) { $this->jsonOutPut(0, '请选择对象'); } if (!in_array($classify, array('posts', 'attachments', 'comments', 'travel'))) { $this->jsonOutPut(0, '不允许的类型'); } if (!in_array($_status, array('top', 'canceltop', 'del'))) { $this->jsonOutPut(0, '不允许的类型'); } if ($_status == 'top') { if ($classify == 'travel') { $attr = array('toped' => 1, 'lastTime' => zmf::now()); } elseif ($classify == 'posts') { $attr = array('top' => 1, 'updateTime' => zmf::now()); } else { $attr = array('top' => 1); } } else { if ($_status == 'canceltop') { if ($classify == 'travel') { $attr = array('toped' => 0); } else { $attr = array('top' => 0); } } else { if ($_status == 'del') { $status = Posts::STATUS_DELED; $attr = array('status' => Posts::STATUS_DELED); } } } $ucClassify = ucfirst($classify); if (!class_exists($ucClassify)) { $this->jsonOutPut(0, '不存在的类型'); } $checkInfo = Posts::checkInfo($info, $keyid, $classify); if (!$checkInfo['status']) { $this->jsonOutPut(0, $checkInfo['msg']); } $model = new $ucClassify(); if ($model->updateByPk($keyid, $attr)) { if ($info['uid'] != zmf::uid()) { if ($_status == 'top' && $classify == 'posts') { $_noticedata = array('uid' => $info['uid'], 'authorid' => zmf::uid(), 'content' => '您的文章已被置顶,' . CHtml::link('查看详情', array('posts/index', 'id' => $keyid)), 'new' => 1, 'type' => $_status . $ucClassify, 'cTime' => zmf::now(), 'from_id' => $keyid, 'from_num' => 1); Notification::add($_noticedata); } } //记录管理员的操作 $attr = array('logid' => $keyid, 'classify' => 'top', 'actype' => 'post', 'acvalue' => $_status . $ucClassify, 'desc' => ''); AdminAction::add($attr); $this->jsonOutPut(1, '操作成功'); } else { $this->jsonOutPut(0, '操作失败'); } }