예제 #1
0
 /**
  * Updating the profile details.
  * @return string|\yii\web\Response
  */
 public function actionDetails()
 {
     $model = User::findMe();
     if (empty($model)) {
         return $this->redirect(['account/login']);
     }
     $model->scenario = PodiumModule::getInstance()->userComponent == PodiumModule::USER_INHERIT ? 'accountInherit' : 'account';
     $model->current_password = null;
     $previous_new_email = $model->new_email;
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             if ($model->saveChanges()) {
                 if ($previous_new_email != $model->new_email) {
                     $forum = Config::getInstance()->get('name');
                     $email = Content::fill(Content::EMAIL_NEW);
                     if ($email !== false && Email::queue($model->new_email, str_replace('{forum}', $forum, $email->topic), str_replace('{forum}', $forum, str_replace('{link}', Html::a(Url::to(['account/new-email', 'token' => $model->email_token], true), Url::to(['account/new-email', 'token' => $model->email_token], true)), $email->content)), !empty($model->id) ? $model->id : null)) {
                         Log::info('New email activation link queued', $model->id, __METHOD__);
                         $this->success(Yii::t('podium/flash', 'Your account has been updated but your new e-mail address is not active yet. Click the activation link that will be sent to your new e-mail address in few minutes.'));
                     } else {
                         Log::error('Error while queuing new email activation link', $model->id, __METHOD__);
                         $this->warning(Yii::t('podium/flash', 'Your account has been updated but your new e-mail address is not active yet. Unfortunately there was some error while sending you the activation link. Contact administrator about this problem.'));
                     }
                 } else {
                     Log::info('Details updated', $model->id, __METHOD__);
                     $this->success(Yii::t('podium/flash', 'Your account has been updated.'));
                 }
                 return $this->refresh();
             }
         }
     }
     $model->current_password = null;
     return $this->render('details', ['model' => $model]);
 }
예제 #2
0
 /**
  * Prepares notification email.
  * @param integer $thread
  */
 public static function notify($thread)
 {
     if (is_numeric($thread) && $thread > 0) {
         $forum = Config::getInstance()->get('name');
         $email = Content::fill(Content::EMAIL_SUBSCRIPTION);
         $subs = static::find()->where(['thread_id' => $thread, 'post_seen' => self::POST_SEEN]);
         foreach ($subs->each() as $sub) {
             $sub->post_seen = self::POST_NEW;
             if ($sub->save()) {
                 if ($email !== false && !empty($sub->user->email)) {
                     if (Email::queue($sub->user->email, str_replace('{forum}', $forum, $email->topic), str_replace('{forum}', $forum, str_replace('{link}', Html::a(Url::to(['default/last', 'id' => $sub->thread_id], true), Url::to(['default/last', 'id' => $sub->thread_id], true)), $email->content)), $sub->user_id)) {
                         Log::info('Subscription notice link queued', $sub->user_id, __METHOD__);
                     } else {
                         Log::error('Error while queuing subscription notice link', $sub->user_id, __METHOD__);
                     }
                 } else {
                     Log::error('Error while queuing subscription notice link - no email set', $sub->user_id, __METHOD__);
                 }
             }
         }
     }
 }
예제 #3
0
 /**
  * Listing the contents.
  * @param string $name content name
  * @return string|\yii\web\Response
  */
 public function actionContents($name = '')
 {
     if (empty(Content::defaultContent($name))) {
         $name = Content::TERMS_AND_CONDS;
     }
     $model = Content::fill($name);
     if ($model->load(Yii::$app->request->post())) {
         if (User::can(Rbac::PERM_CHANGE_SETTINGS)) {
             if ($model->save()) {
                 $this->success(Yii::t('podium/flash', 'Content has been saved.'));
             } else {
                 $this->error(Yii::t('podium/flash', 'Sorry! There was some error while saving the content.'));
             }
         } else {
             $this->error(Yii::t('podium/flash', 'You are not allowed to perform this action.'));
         }
         return $this->refresh();
     }
     return $this->render('contents', ['model' => $model]);
 }
예제 #4
0
 /**
  * Sending the account password reset link.
  * @return string|\yii\web\Response
  */
 public function actionReset()
 {
     if (PodiumModule::getInstance()->userComponent == PodiumModule::USER_INHERIT) {
         $this->info(Yii::t('podium/flash', 'Please contact the administrator to reset your account password.'));
         return $this->module->goPodium();
     }
     $model = new ReForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->reset()) {
             if (!empty($model->email)) {
                 $forum = Config::getInstance()->get('name');
                 $email = Content::fill(Content::EMAIL_PASSWORD);
                 if ($email !== false && Email::queue($model->user->email, str_replace('{forum}', $forum, $email->topic), str_replace('{forum}', $forum, str_replace('{link}', Html::a(Url::to(['account/password', 'token' => $model->user->password_reset_token], true), Url::to(['account/password', 'token' => $model->user->password_reset_token], true)), $email->content)), !empty($model->user->id) ? $model->user->id : null)) {
                     Log::info('Password reset link queued', $model->user->id, __METHOD__);
                     $this->success(Yii::t('podium/flash', 'The password reset link has been sent to your e-mail address.'));
                 } else {
                     Log::error('Error while queuing password reset link', $model->user->id, __METHOD__);
                     $this->error(Yii::t('podium/flash', 'Sorry! There was some error while sending you the password reset link. Contact administrator about this problem.'));
                 }
             } else {
                 Log::error('Error while queuing password reset link - no email set', $model->user->id, __METHOD__);
                 $this->error(Yii::t('podium/flash', 'Sorry! There is no e-mail address saved with your account. Contact administrator about resetting password.'));
             }
             return $this->module->goPodium();
         }
         $this->error(Yii::t('podium/flash', 'Sorry! We can not find the account with that user name or e-mail address.'));
     }
     return $this->render('reset', ['model' => $model]);
 }