/**
  * Registering the new account and sending the activation link.
  * @return string|\yii\web\Response
  */
 public function actionRegister()
 {
     $model = new User();
     $model->setScenario('register');
     if ($model->load(Yii::$app->request->post()) && $model->register()) {
         $email = Content::find()->where(['name' => 'email-reg'])->one();
         if ($email) {
             $topic = $email->topic;
             $content = $email->content;
         } else {
             $topic = Content::REG_TITLE;
             $content = Content::REG_BODY;
         }
         $forum = Config::getInstance()->get('name');
         if (Email::queue($model->email, str_replace('{forum}', $forum, $topic), str_replace('{forum}', $forum, str_replace('{link}', Html::a(Url::to(['account/activate', 'token' => $model->activation_token], true), Url::to(['account/activate', 'token' => $model->activation_token], true)), $content)), !empty($model->id) ? $model->id : null)) {
             Log::info('Activation link queued', !empty($model->id) ? $model->id : '', __METHOD__);
             $this->success('Your account has been created but it is not active yet. Click the activation link that has been sent to your e-mail address.');
         } else {
             Log::warning('Error while queuing activation link', !empty($model->id) ? $model->id : '', __METHOD__);
             $this->warning('Your account has been created but it is not active yet. ' . 'Unfortunately there was some error while sending you the activation link. ' . 'Contact administrator about this or try to {link}resend the link{closelink}.', ['link' => Html::beginTag('a', ['href' => Url::to('account/reactivate')]), 'closelink' => Html::endTag('a')]);
         }
         return $this->module->goPodium();
     }
     return $this->render('register', ['model' => $model, 'terms' => Content::findOne(['name' => 'terms'])]);
 }
 /**
  * Registering the new account and sending the activation link.
  * @return string|\yii\web\Response
  */
 public function actionRegister()
 {
     if (PodiumModule::getInstance()->userComponent == PodiumModule::USER_INHERIT) {
         $this->info(Yii::t('podium/flash', 'Please use application Register form to sign up.'));
         return $this->module->goPodium();
     }
     $model = new User();
     $model->setScenario('register');
     if ($model->load(Yii::$app->request->post()) && $model->register()) {
         $email = Content::find()->where(['name' => 'email-reg'])->limit(1)->one();
         if ($email) {
             $topic = $email->topic;
             $content = $email->content;
         } else {
             $topic = Messages::EMAIL_REG_TITLE;
             $content = Messages::EMAIL_REG_BODY;
         }
         $forum = Config::getInstance()->get('name');
         if (!empty($model->email)) {
             if (Email::queue($model->email, str_replace('{forum}', $forum, $topic), str_replace('{forum}', $forum, str_replace('{link}', Html::a(Url::to(['account/activate', 'token' => $model->activation_token], true), Url::to(['account/activate', 'token' => $model->activation_token], true)), $content)), !empty($model->id) ? $model->id : null)) {
                 Log::info('Activation link queued', !empty($model->id) ? $model->id : '', __METHOD__);
                 $this->success(Yii::t('podium/flash', 'Your account has been created but it is not active yet. Click the activation link that has been sent to your e-mail address.'));
             } else {
                 Log::warning('Error while queuing activation link', !empty($model->id) ? $model->id : '', __METHOD__);
                 $this->warning(Yii::t('podium/flash', 'Your account has been created but it is not active yet. ' . 'Unfortunately there was some error while sending you the activation link. ' . 'Contact administrator about this or try to {resend the link}.', ['resend the link' => Html::a(Yii::t('podium/flash', 'resend the link'), ['account/reactivate'])]));
             }
         } else {
             Log::error('Error while queuing activation link - no email set', $model->id, __METHOD__);
             $this->error(Yii::t('podium/flash', 'Sorry! There is no e-mail address saved with your account. Contact administrator about activating.'));
         }
         return $this->module->goPodium();
     }
     return $this->render('register', ['model' => $model, 'terms' => Content::findOne(['name' => 'terms'])]);
 }
 /**
  * Registering the new account and sending the activation link.
  * @return string|\yii\web\Response
  */
 public function actionRegister()
 {
     if (PodiumModule::getInstance()->userComponent == PodiumModule::USER_INHERIT) {
         $this->info(Yii::t('podium/flash', 'Please use application Register form to sign up.'));
         return $this->module->goPodium();
     }
     $model = new User();
     $model->scenario = 'register';
     if ($model->load(Yii::$app->request->post()) && $model->register()) {
         if (!empty($model->email)) {
             $forum = Config::getInstance()->get('name');
             $email = Content::fill(Content::EMAIL_REGISTRATION);
             if ($email !== false && Email::queue($model->email, str_replace('{forum}', $forum, $email->topic), str_replace('{forum}', $forum, str_replace('{link}', Html::a(Url::to(['account/activate', 'token' => $model->activation_token], true), Url::to(['account/activate', 'token' => $model->activation_token], true)), $email->content)), !empty($model->id) ? $model->id : null)) {
                 Log::info('Activation link queued', !empty($model->id) ? $model->id : '', __METHOD__);
                 $this->success(Yii::t('podium/flash', 'Your account has been created but it is not active yet. Click the activation link that will be sent to your e-mail address in few minutes.'));
             } else {
                 Log::warning('Error while queuing activation link', !empty($model->id) ? $model->id : '', __METHOD__);
                 $this->warning(Yii::t('podium/flash', 'Your account has been created but it is not active yet. Unfortunately there was some error while sending you the activation link. Contact administrator about this or try to {resend the link}.', ['resend the link' => Html::a(Yii::t('podium/flash', 'resend the link'), ['account/reactivate'])]));
             }
         } else {
             Log::error('Error while queuing activation link - no email set', $model->id, __METHOD__);
             $this->error(Yii::t('podium/flash', 'Sorry! There is no e-mail address saved with your account. Contact administrator about activating.'));
         }
         return $this->module->goPodium();
     }
     $model->captcha = null;
     return $this->render('register', ['model' => $model, 'terms' => Content::fill(Content::TERMS_AND_CONDS)]);
 }