示例#1
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();
 }
示例#2
0
 /**
  * Show users in blacklist and allow add new users
  * @return string
  * @throws \Ffcms\Core\Exception\SyntaxException
  * @throws \Ffcms\Core\Exception\NativeException
  * @throws ForbiddenException
  */
 public function actionIgnore()
 {
     // check if not auth
     if (!App::$User->isAuth()) {
         throw new ForbiddenException();
     }
     // get user object and init model of it
     $user = App::$User->identity();
     $model = new FormIgnoreAdd($user);
     // set user id from ?id= get param if form not sended
     if (!$model->send()) {
         $uid = (int) $this->request->query->get('id');
         if ($uid > 0) {
             $model->id = $uid;
         }
     }
     // sended new block add?
     if ($model->send() && $model->validate()) {
         if ($model->save()) {
             App::$Session->getFlashBag()->add('success', __('User was successful blocked!'));
         } else {
             App::$Session->getFlashBag()->add('error', __('This user is always in ignore list'));
         }
     }
     // get blocked users
     $records = Blacklist::where('user_id', '=', $user->getId());
     $page = (int) $this->request->query->get('page');
     $offset = $page * self::BLOCK_PER_PAGE;
     // build pagination
     $pagination = new SimplePagination(['url' => ['profile/ignore'], 'page' => $page, 'step' => self::BLOCK_PER_PAGE, 'total' => $records->count()]);
     return $this->view->render('ignore', ['records' => $records->skip($offset)->take(self::BLOCK_PER_PAGE)->get(), 'model' => $model, 'pagination' => $pagination]);
 }