/** * 添加草稿 * * @return void */ public function doAddAction() { list($title, $content) = $this->getInput(array('atc_title', 'atc_content')); if (!$title || !$content) { $this->showError('BBS:draft.content.empty'); } if ($this->_getDraftDs()->countByUid($this->loginUser->uid) >= $this->maxNum) { $this->showError('BBS:draft.num.max'); } $draftDm = new PwDraftDm(); $draftDm->setTitle($title)->setContent($content)->setCreatedUserid($this->loginUser->uid)->setCreatedTime(PW::getTime()); $this->_getDraftDs()->addDraft($draftDm); $this->showMessage('success'); }
/** * 编辑 * * @param int $id * @param array $data * @return array */ public function updateDraft($id, PwDraftDm $dm) { if (($result = $dm->beforeUpdate()) instanceof PwError) { return $result; } return $this->_getDraftDao()->update($id, $dm->getData()); }