Exemple #1
0
 /**
  * Make save
  * @return bool
  */
 public function save()
 {
     // check if target is myself or always exist in block list
     if ($this->_user->getId() === (int) $this->id || Blacklist::have($this->_user->getId(), $this->id)) {
         return false;
     }
     // save data to db
     $record = new Blacklist();
     $record->user_id = $this->_user->getId();
     $record->target_id = $this->id;
     $record->comment = $this->comment;
     $record->save();
     return true;
 }
Exemple #2
0
 /**
  * Check if target user in blacklist
  * @param int $target_id
  * @return bool
  */
 public function inBlacklist($target_id)
 {
     return Blacklist::have($this->getId(), $target_id);
 }
Exemple #3
0
 /**
  * Unblock always blocked user
  * @param string $target_id
  * @return string
  * @throws \Ffcms\Core\Exception\SyntaxException
  * @throws \Ffcms\Core\Exception\NativeException
  * @throws ForbiddenException
  * @throws NotFoundException
  */
 public function actionUnblock($target_id)
 {
     // check if user is auth
     if (!App::$User->isAuth()) {
         throw new ForbiddenException();
     }
     // check if target is defined
     if (!Obj::isLikeInt($target_id) || $target_id < 1 || !App::$User->isExist($target_id)) {
         throw new NotFoundException();
     }
     $user = App::$User->identity();
     // check if target user in blacklist of current user
     if (!Blacklist::have($user->getId(), $target_id)) {
         throw new NotFoundException();
     }
     $model = new FormIgnoreDelete($user, $target_id);
     if ($model->send() && $model->validate()) {
         $model->make();
         $this->response->redirect(Url::to('profile/ignore'));
     }
     return $this->view->render('unblock', ['model' => $model]);
 }