예제 #1
0
 /**
  * Creates inherited user account.
  * @throws Exception
  */
 public function init()
 {
     parent::init();
     if (!Yii::$app->user->isGuest) {
         if (PodiumModule::getInstance()->userComponent == PodiumModule::USER_INHERIT) {
             $user = User::findMe();
             if (empty($user)) {
                 if (User::createInheritedAccount()) {
                     $this->success(Yii::t('podium/flash', 'Hey! Your new forum account has just been automatically created! Go to {link} to complement it.', ['link' => Html::a(Yii::t('podium/view', 'Profile'))]));
                 } else {
                     throw new Exception(Yii::t('podium/view', 'There was an error while creating inherited user account. Podium can not run with the current configuration. Please contact administrator about this problem.'));
                 }
             }
         } else {
             $user = Yii::$app->user->identity;
         }
         if ($user->status == User::STATUS_BANNED) {
             return $this->redirect(['default/ban']);
         }
         if ($user && !empty($user->timezone)) {
             Yii::$app->formatter->timeZone = $user->timezone;
         }
     }
 }