/** * save * * @param int|string $pk * @param Data $data * * @return mixed|void * * @throws ValidFailException */ protected function save($pk, Data $data) { if (!UserHelper::canEditTopic($this->record)) { throw new ValidFailException('Permission deny'); } parent::save($pk, $data); }
/** * save * * @param int|string $pk * @param Data $data * * @return void * * @throws ValidFailException */ protected function save($pk, Data $data) { // Validate if (!UserHelper::isAdmin()) { throw new ValidFailException('Permission deny'); } parent::save($pk, $data); }
/** * validate * * @param Data $data * * @return void * * @throws ValidFailException */ protected function validate(Data $data) { if (!$data->title) { throw new ValidFailException('Require Title'); } if (!UserHelper::canEditTopic($this->record)) { throw new ValidFailException('Permission deny'); } }
protected function validate(Data $data) { if (!$data->title) { throw new ValidFailException('Require Title'); } if (!UserHelper::isAdmin()) { throw new ValidFailException('Permission deny'); } }
/** * save * * @param int|string $pk * @param Data $data * * @return void * * @throws ValidFailException */ protected function save($pk, Data $data) { // Pre save if (!UserHelper::canDeletePost($this->record)) { throw new ValidFailException('Permission deny'); } if ($this->primary) { $this->hmvc($controller = new TopicDeleteController(), array('cid' => $this->record->topic_id)); } else { parent::save($pk, $data); } // Post save $this->topic->replies--; $this->topic->store(); }
/** * validate * * @param Data $data * * @return void * * @throws ValidFailException */ protected function validate(Data $data) { if (!$data->body) { throw new ValidFailException('Require Content'); } if ($this->record->id && !UserHelper::canEditOwnPost($this->record)) { throw new ValidFailException('Permission deny'); } elseif (UserHelper::isGuest()) { throw new ValidFailException('Permission deny'); } }
/** * validate * * @param Data $data * * @return void * * @throws ValidFailException */ protected function validate(Data $data) { if (!trim($data->title)) { throw new ValidFailException('Require Title'); } if (!trim($data->body)) { throw new ValidFailException('Require Content'); } if ($this->record->id && !UserHelper::canEditTopic($this->record)) { throw new ValidFailException('Permission deny'); } }