예제 #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;
 }
예제 #2
0
 /**
  * Form submit action - delete user from database
  * @throws \Exception
  */
 public function make()
 {
     Blacklist::where('user_id', '=', $this->_user->getId())->where('target_id', '=', $this->_target_id)->delete();
 }
예제 #3
0
파일: User.php 프로젝트: phpffcms/ffcms
 /**
  * Check if target user in blacklist
  * @param int $target_id
  * @return bool
  */
 public function inBlacklist($target_id)
 {
     return Blacklist::have($this->getId(), $target_id);
 }
예제 #4
0
파일: Profile.php 프로젝트: phpffcms/ffcms
 /**
  * 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]);
 }
예제 #5
0
파일: Profile.php 프로젝트: phpffcms/ffcms
 /**
  * Send message via AJAX
  * @param $target_id
  * @return string
  * @throws ForbiddenException
  * @throws NativeException
  */
 public function actionMessagesend($target_id)
 {
     // check if user is auth
     if (!App::$User->isAuth()) {
         throw new ForbiddenException('Auth required');
     }
     // get current user object
     $user = App::$User->identity();
     if (!Blacklist::check($user->id, $target_id)) {
         throw new ForbiddenException('In blacklist');
     }
     // check input params
     $msg = App::$Security->strip_tags($this->request->get('message'));
     if (!Obj::isLikeInt($target_id) || $target_id < 1 || Str::length($msg) < 1) {
         throw new NativeException('Wrong input data');
     }
     $this->setJsonHeader();
     // try to save message
     $message = new Message();
     $message->target_id = $target_id;
     $message->sender_id = $user->id;
     $message->message = $msg;
     $message->save();
     return json_encode(['status' => 1]);
 }