コード例 #1
0
 /**
  * Delete Action
  *
  * Its only possible if the user is not owner of a workspace.
  */
 public function actionDelete()
 {
     $isSpaceOwner = false;
     $user = Yii::$app->user->getIdentity();
     if (!Yii::$app->user->canDeleteAccount()) {
         throw new HttpException(500, 'Account deletion not allowed');
     }
     foreach (\humhub\modules\space\models\Membership::GetUserSpaces() as $space) {
         if ($space->isSpaceOwner($user->id)) {
             $isSpaceOwner = true;
         }
     }
     $model = new \humhub\modules\user\models\forms\AccountDelete();
     if (!$isSpaceOwner && $model->load(Yii::$app->request->post()) && $model->validate()) {
         $user->delete();
         Yii::$app->user->logout();
         return $this->goHome();
     }
     return $this->render('delete', array('model' => $model, 'isSpaceOwner' => $isSpaceOwner));
 }
コード例 #2
0
 /**
  * Delete Action
  *
  * Its only possible if the user is not owner of a workspace.
  */
 public function actionDelete()
 {
     $isSpaceOwner = false;
     $user = Yii::$app->user->getIdentity();
     if ($user->auth_mode != User::AUTH_MODE_LOCAL) {
         throw new HttpException(500, 'This is not a local account! You cannot delete it. (e.g. LDAP)!');
     }
     foreach (\humhub\modules\space\models\Membership::GetUserSpaces() as $space) {
         if ($space->isSpaceOwner($user->id)) {
             $isSpaceOwner = true;
         }
     }
     $model = new \humhub\modules\user\models\forms\AccountDelete();
     if (!$isSpaceOwner && $model->load(Yii::$app->request->post()) && $model->validate()) {
         $user->delete();
         Yii::$app->user->logout();
         $this->redirect(Yii::$app->homeUrl);
     }
     return $this->render('delete', array('model' => $model, 'isSpaceOwner' => $isSpaceOwner));
 }