public function actionBan($id = null)
    {
        $model = User::find()->where(['id' => $id])->limit(1)->one();
        if (empty($model)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find Member with this ID.'));
            return $this->redirect(['admin/members']);
        }
        if ($model->id == User::loggedId()) {
            $this->error(Yii::t('podium/flash', 'Sorry! You can not ban or unban your own account.'));
            return $this->redirect(['admin/members']);
        }
        if ($model->status == User::STATUS_ACTIVE) {
            if ($model->ban()) {
                $this->module->podiumCache->delete('members.fieldlist');
                Log::info('User banned', $model->id, __METHOD__);
                $this->success(Yii::t('podium/flash', 'User has been banned.'));
            } else {
                Log::error('Error while banning user', $model->id, __METHOD__);
                $this->error(Yii::t('podium/flash', 'Sorry! There was some error while banning the user.'));
            }
            return $this->redirect(['admin/members']);
        }
        if ($model->status == User::STATUS_BANNED) {
            if ($model->unban()) {
                $this->module->podiumCache->delete('members.fieldlist');
                Log::info('User unbanned', $model->id, __METHOD__);
                $this->success(Yii::t('podium/flash', 'User has been unbanned.'));
            } else {
                Log::error('Error while unbanning user', $model->id, __METHOD__);
                $this->error(Yii::t('podium/flash', 'Sorry! There was some error while unbanning the user.'));
            }
            return $this->redirect(['admin/members']);
        }
        $this->error(Yii::t('podium/flash', 'Sorry! User has got the wrong status.'));
        return $this->redirect(['admin/members']);
    }
public function actionBan($id = null)
    {
        $model = User::find()->where(['id' => $id])->limit(1)->one();
        if (empty($model)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find Member with this ID.'));
            return $this->redirect(['admin/members']);
        }
        if ($model->id == User::loggedId()) {
            $this->error(Yii::t('podium/flash', 'Sorry! You can not ban or unban your own account.'));
            return $this->redirect(['admin/members']);
        }
        if ($model->status == User::STATUS_ACTIVE) {
            if ($model->ban()) {
                $this->module->podiumCache->delete('members.fieldlist');
                Log::info('User banned', $model->id, __METHOD__);
                $this->success(Yii::t('podium/flash', 'User has been banned.'));
            } else {
                Log::error('Error while banning user', $model->id, __METHOD__);
                $this->error(Yii::t('podium/flash', 'Sorry! There was some error while banning the user.'));
            }
            return $this->redirect(['admin/members']);
        }
        if ($model->status == User::STATUS_BANNED) {
            if ($model->unban()) {
                $this->module->podiumCache->delete('members.fieldlist');
                Log::info('User unbanned', $model->id, __METHOD__);
                $this->success(Yii::t('podium/flash', 'User has been unbanned.'));
            } else {
                Log::error('Error while unbanning user', $model->id, __METHOD__);
                $this->error(Yii::t('podium/flash', 'Sorry! There was some error while unbanning the user.'));
            }
            return $this->redirect(['admin/members']);
        }
        $this->error(Yii::t('podium/flash', 'Sorry! User has got the wrong status.'));
        return $this->redirect(['admin/members']);
    }
public function actionBan ( $ id = null ) { $ model = User :: find ( ) -> where ( [ 'id' => $ id ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ model ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find Member with this ID.' ) ) ; return $ this -> redirect ( [ 'admin/members' ] ) ; } if ( $ model -> id == User :: loggedId ( ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! You can not ban or unban your own account.' ) ) ; return $ this -> redirect ( [ 'admin/members' ] ) ; } if ( $ model -> status == User :: STATUS_ACTIVE ) { if ( $ model -> ban ( ) ) { $ this -> module -> podiumCache -> delete ( 'members.fieldlist' ) ; Log :: info ( 'User banned' , $ model -> id , __METHOD__ ) ; $ this -> success ( Yii :: t ( 'podium/flash' , 'User has been banned.' ) ) ; } else { Log :: error ( 'Error while banning user' , $ model -> id , __METHOD__ ) ; $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was some error while banning the user.' ) ) ; } return $ this -> redirect ( [ 'admin/members' ] ) ; } if ( $ model -> status == User :: STATUS_BANNED ) { if ( $ model -> unban ( ) ) { $ this -> module -> podiumCache -> delete ( 'members.fieldlist' ) ; Log :: info ( 'User unbanned' , $ model -> id , __METHOD__ ) ; $ this -> success ( Yii :: t ( 'podium/flash' , 'User has been unbanned.' ) ) ; } else { Log :: error ( 'Error while unbanning user' , $ model -> id , __METHOD__ ) ; $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was some error while unbanning the user.' ) ) ; } return $ this -> redirect ( [ 'admin/members' ] ) ; } $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! User has got the wrong status.' ) ) ; return $ this -> redirect ( [ 'admin/members' ] ) ; }
Banning the user of given ID.
@param int $id
@return Response
Banning the user of given ID .