Ejemplo n.º 1
0
 public function ajaxSubmitAction()
 {
     $setId = Request::getPOST('set-id');
     $title = trim(Request::getPOST('title'));
     $refreshAt = strtotime(trim(Request::getPOST('refresh-at')));
     if (empty($setId)) {
         $this->renderError('参数错误!');
     }
     if (empty($title) || mb_strlen($title, 'utf8') > 50) {
         $this->renderError('标题必填,限制50个字以内!');
     }
     $currentDay = intval(time() / 86400) * 86400 + 86400;
     if (empty($refreshAt) || $refreshAt > $currentDay) {
         $this->renderError('刷新时间不能超过今天!');
     }
     $setInfo = OjProblemSetInterface::getById(array('id' => $setId));
     if (empty($setInfo)) {
         $this->renderError('专题不存在!');
     }
     // 属主验证
     if ($setInfo['user_id'] != $this->loginUserInfo['id']) {
         $this->renderError('你没有修改权限!');
     }
     $data = array('id' => $setId, 'title' => $title, 'refresh_at' => $refreshAt);
     OjProblemSetInterface::save($data);
     $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '修改成功!');
     $this->renderAjax(0);
 }
Ejemplo n.º 2
0
 public function ajaxSubmitAction()
 {
     // 如果空专题超过20,提示编辑
     $where = array(array('user_id', '=', $this->loginUserInfo['id']), array('title', '=', ''));
     $count = OjProblemSetInterface::getCount($where);
     if ($count > 20) {
         $this->renderError('您有很多空的专题,请先编辑!');
     }
     // 创建空的专题
     $data = array('user_id' => $this->loginUserInfo['id']);
     OjProblemSetInterface::save($data);
     $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '您成功创建了专题,请编辑!');
     $this->renderAjax(0);
 }