コード例 #1
0
 /**
  * Overrided Confirm action
  *
  * @param int $id
  * @param string $code
  * @return string
  * @throws NotFoundHttpException
  * @throws \Exception
  */
 public function actionConfirm($id, $code)
 {
     $user = $this->finder->findUserById($id);
     //$mailer = \Yii::$container->get(dektriumMailer::className());
     $mailer = new \common\helpers\Mandrill($user->email, 'Welcome to Razzd!', 'welcome', $sender = null, ['user' => $user, 'mandrill_template_name' => 'welcome']);
     if ($user === null || $this->module->enableConfirmation == false) {
         throw new NotFoundHttpException();
     }
     /** @var Token $token */
     $token = $this->findToken($id, $code, Token::TYPE_CONFIRMATION);
     if ($token === null || $token->isExpired) {
         \Yii::$app->session->setFlash('danger', \Yii::t('user', 'The confirmation link is invalid or expired. Please try requesting a new one.'));
     } else {
         $token->delete();
         $user->confirmed_at = time();
         \Yii::$app->user->login($user);
         \Yii::getLogger()->log('User has been confirmed', Logger::LEVEL_INFO);
         if ($user->save(false)) {
             \Yii::$app->session->setFlash('success', \Yii::t('user', 'Thank you, registration is now complete.'));
             $mailer->sendMessage();
         } else {
             \Yii::$app->session->setFlash('danger', \Yii::t('user', 'Something went wrong and your account has not been confirmed.'));
         }
     }
     return $this->render('/message', ['title' => \Yii::t('user', 'Account confirmation'), 'module' => $this->module]);
 }
コード例 #2
0
ファイル: PagesController.php プロジェクト: babagay/razzd
 /**
  * Contact Us page render
  *
  * @param $page
  * @return string
  * @throws Mandrill_Error
  * @throws \Exception
  */
 private function renderContactUs($page)
 {
     $model = new ContactForm();
     $mess = '';
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $settings = new Settings();
         /** @var string $sendTo - address which collects feedback from customers
          *  @fixme change this emails
          */
         try {
             $support = $settings->getConfigurationParamByKey('support_email');
         } catch (\yii\base\Exception $e) {
             $support = null;
         }
         try {
             $support = $settings->getConfigurationParamByKey('admin_email');
         } catch (\yii\base\Exception $e) {
             $admin = null;
         }
         if (!$support) {
             $sendTo = \Yii::$app->params['supportEmail'];
         } else {
             $sendTo = $support;
         }
         if (!$admin) {
             $replyTo = \Yii::$app->params['adminEmail'];
         } else {
             $replyTo = $admin;
         }
         $name = Yii::$app->request->post("ContactForm")['name'];
         $body = Yii::$app->request->post("ContactForm")['body'];
         $usermail = Yii::$app->request->post("ContactForm")['email'];
         $subject_internal = Yii::$app->request->post("ContactForm")['subject'];
         $subject = "New Feedback from {$name} ({$usermail})";
         $mailer = new \common\helpers\Mandrill($sendTo, $subject, $local_tpl_name = null, $sender = null, ['from_name' => '[Auto-generated]', 'reply_to' => $replyTo, 'mandrill_template_name' => 'contactrazzd', 'vars' => ['header' => $subject_internal, 'body' => $body, 'usermail' => $usermail]]);
         $result = $mailer->sendWithMandrillTemplate();
         $mess = (string) $result;
         if ($result) {
             Yii::$app->session->setFlash('success', 'Your message has been sent.');
         } else {
             Yii::$app->session->setFlash('error', 'Is there something wrong. Contact Support.');
         }
         $model = new ContactForm();
     }
     return $this->render('contact_us', ['page' => $page, 'model' => $model]);
 }
コード例 #3
0
ファイル: SiteController.php プロジェクト: babagay/razzd
 /**
  * @return string
  * @throws \yii\base\InvalidConfigException
  */
 public function actionFogotPassword()
 {
     if (!\Yii::$app->user->isGuest) {
         $this->goHome();
     }
     $sended = $result = false;
     $model = \Yii::createObject(['class' => \frontend\models\RecoveryForm::className(), 'scenario' => 'request']);
     $isLoaded = $model->load(Yii::$app->request->post());
     if (Yii::$app->request->isPost && $isLoaded && $model->validate()) {
         /** @var Token $token */
         $password = \dektrium\user\helpers\Password::generate(6);
         if ($model->user->resetPassword($password)) {
             $sendTo = $model->user->email;
             $subject = "Razzd Password Recovery";
             $replyTo = isset(\Yii::$app->params['supportEmail']) ? \Yii::$app->params['supportEmail'] : "";
             $subject_internal = "Your Password was changed";
             $password = "******";
             $username = $model->user->username;
             $mailer = new \common\helpers\Mandrill($sendTo, $subject, $local_tpl_name = null, $sender = null, ['from_name' => '[Auto-generated]', 'reply_to' => $replyTo, 'mandrill_template_name' => 'forgotpassword', 'vars' => ['header' => $subject_internal, 'username' => $username, 'password' => $password]]);
             $result = $mailer->sendWithMandrillTemplate();
         }
         $mess = (string) $result;
         if ($result) {
             Yii::$app->session->setFlash('success', 'Your password has been changed.');
             $sended = true;
         } else {
             Yii::$app->session->setFlash('error', 'There is something wrong. Contact Support.');
         }
     }
     return $this->renderAjax('fogot', ['model' => $model, 'sended' => $sended]);
 }
コード例 #4
0
ファイル: Razz.php プロジェクト: babagay/razzd
 /**
  * Send message to razzded user
  */
 private function sendNotifiRazzd()
 {
     $userModel = new \frontend\models\User();
     $userName = $userModel->getFullname(Yii::$app->user->id);
     $notifi = \Yii::createObject(['class' => Notification::className(), 'uid' => $this->responder_uid, 'message' => 'YOU HAVE BEEN RAZZD BY ' . $userName, 'link' => '<a href="/razz/respond/' . $this->id . '" class="btn">RESPOND</a>', 'created_at' => time()]);
     $notifi->save();
     $userModel = new \frontend\models\User();
     $razdator = $userModel->getFullname(Yii::$app->user->id);
     $vis_a_vis = \frontend\models\User::findOne(['email' => $this->email]);
     $mailer = new \common\helpers\Mandrill($sendTo = $this->email, $subject = 'YOU HAVE BEEN RAZZD BY ' . ucfirst($razdator), $local_tpl_name = null, $sender = null, ['from_name' => '[Notification generator]', 'mandrill_template_name' => 'you-have-been-razzd', 'vars' => ['razee' => ucfirst($vis_a_vis->username), 'header' => $this->title, 'message' => $this->message, 'description' => $this->description, 'razdator' => ucfirst($razdator), 'link' => '<a href="' . Yii::$app->getUrlManager()->createAbsoluteUrl(["razz/respond/" . $this->id]) . '" class="btn">RESPOND</a>']]);
     $result = $mailer->sendWithMandrillTemplate();
     $mess = (string) $result;
     unset($userModel);
 }