public function ajaxAddAction() { $data = array('user_id' => $this->loginUserInfo['id']); DocInterface::save($data); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '添加了新文章'); $this->renderAjax(0); }
public function defaultAction() { $docId = (int) Request::getGET('doc-id'); $docInfo = DocInterface::getById(array('id' => $docId)); if (empty($docInfo)) { $this->renderError(); } $userInfo = UserCommonInterface::getById(array('id' => $docInfo['user_id'])); $this->renderFramework(array('docInfo' => $docInfo, 'userInfo' => $userInfo), 'doc/detail.php'); }
public function ajaxHideAction() { $docId = (int) Request::getPOST('doc-id'); $docInfo = DocInterface::getById(array('id' => $docId)); if (empty($docInfo)) { $this->renderError('文章不存在!'); } if ($docInfo['hidden']) { $this->renderError('文章已经隐藏!'); } DocInterface::hide(array('id' => $docId)); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '操作成功'); $this->renderAjax(0); }
public function defaultAction() { $docId = (int) Request::getGET('doc-id', 0); $docInfo = array(); if (!empty($docId)) { $docInfo = DocInterface::getById(array('id' => $docId)); if (empty($docInfo) || $docInfo['hidden'] || $docInfo['category'] != 1) { $this->renderError('文章不存在!'); } } $where = array(); $where[] = array('category', '=', 1); $where[] = array('hidden', '=', 0); $where[] = array('title', '!=', ''); $order = array('title' => 'ASC'); $docList = DocInterface::getList(array('where' => $where, 'order' => $order)); $this->renderFramework(array('docList' => $docList, 'docInfo' => $docInfo), 'doc/list.php'); }
public function ajaxChangeAction() { // 获取参数 $docId = (int) Request::getPOST('doc-id'); $username = trim(Request::getPOST('username', '')); $category = (int) Request::getPOST('category'); if (empty($username) || !array_key_exists($category, DocVars::$CATEGORY)) { $this->renderError('参数错误!'); } // 校验用户 $userInfo = UserCommonInterface::getByLoginName(array('login_name' => $username)); if (empty($userInfo)) { $this->renderError('用户不存在!'); } // 校验doc $docInfo = DocInterface::getById(array('id' => $docId)); if (empty($docInfo)) { $this->renderError('文章不存在!'); } // 更新 DocInterface::change(array('id' => $docId, 'username' => $username, 'category' => $category)); $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '操作成功'); $this->renderAjax(0); }