Esempio n. 1
0
 /**
  * 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);
 }
Esempio n. 2
0
 /**
  * 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);
 }
Esempio n. 3
0
 /**
  * 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');
     }
 }
Esempio n. 4
0
 protected function validate(Data $data)
 {
     if (!$data->title) {
         throw new ValidFailException('Require Title');
     }
     if (!UserHelper::isAdmin()) {
         throw new ValidFailException('Permission deny');
     }
 }
Esempio n. 5
0
 /**
  * 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();
 }
Esempio n. 6
0
 /**
  * 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');
     }
 }
Esempio n. 7
0
 /**
  * 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');
     }
 }