public static function send($playerId, $notification) { $options = []; $options['clearSelect'] = true; $options['select'][] = \Own\Bus\Player\Data::getList(['id', 'user_id', 'username']); $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'email'], 'player_user'); $options['join'][] = 'core_user player_user ON player_user.id = player.user_id'; $options['where'][] = 'send_notification_email = 1'; $options['where'][] = ['player.id = ?', $playerId]; $player = \Own\Bus\Player\Data::load($options); if (!isset($player)) { return false; } // send email $app = \Rebond\App::instance(); $tpl = new Util\Template(Util\Template::MODULE, ['bus', 'notification']); $tpl->set('url', 'http://' . \Rebond\Config::getPath('siteUrl')); $tpl->set('player', $player); $tpl->set('notification', $notification); $tplMail = new Util\Template(Util\Template::SITE, ['mail']); $tplMail->set('title', Util\Lang::lang('notification')); $tplMail->set('site', $app->site()->getTitle()); $tplMail->set('url', 'http://' . \Rebond\Config::getPath('siteUrl')); $tplMail->set('layout', $tpl->render('notification')); $message = \Swift_Message::newInstance()->setContentType('text/html')->setSubject($app->site()->getTitle() . ' - ' . Util\Lang::lang('notification'))->setFrom(\Rebond\Config::getMail('email'))->setTo($player->getUser()->getEmail())->setBody($tplMail->render('tpl-default')); return Util\Mail::send($message); }
public static function resetPassword($siteTitle, \Rebond\Core\User\Model $user) { $userSecure = \Rebond\Core\UserSecurity\Service::saveSecure($user->getId(), \Rebond\Core\UserSecurity\Model::RESET); $tpl = new Util\Template(Util\Template::SITE, ['mail']); $tpl->set('url', \Rebond\Config::getPath('siteUrl')); $tpl->set('site', $siteTitle); $tpl->set('item', $user); $tpl->set('reset', $userSecure->getSecure()); $tplMail = new Util\Template(Util\Template::SITE, ['mail']); $tplMail->set('title', Util\Lang::lang('resetPassword')); $tplMail->set('site', $siteTitle); $tplMail->set('url', \Rebond\Config::getPath('siteUrl')); $tplMail->set('layout', $tpl->render('reset-password')); $message = \Swift_Message::newInstance()->setContentType('text/html')->setSubject($siteTitle . ' - ' . Util\Lang::lang('resetPassword'))->setFrom(\Rebond\Config::getMail('email'))->setTo($user->getEmail())->setBody($tplMail->render('tpl-default')); return Util\Mail::send($message); }
public static function error($siteTitle, $emails, $code, $message, $file, $line) { $tpl = new Util\Template(Util\Template::MODULE, ['app', 'error']); $tpl->set('url', \Rebond\Config::getPath('siteUrl')); $tpl->set('site', $siteTitle); $tpl->set('code', Util\Code::value($code)); $tpl->set('message', $message); $tpl->set('file', $file); $tpl->set('line', $line); $tplMail = new Util\Template(Util\Template::SITE, ['mail']); $tplMail->set('title', Util\Lang::lang('log')); $tplMail->set('site', $siteTitle); $tplMail->set('url', \Rebond\Config::getPath('siteUrl')); $tplMail->set('layout', $tpl->render('mail')); $message = \Swift_Message::newInstance()->setContentType('text/html')->setSubject($siteTitle . ' - ' . Util\Lang::lang('log'))->setFrom(\Rebond\Config::getMail('email'))->setTo($emails)->setBody($tplMail->render('tpl-default')); return Util\Mail::send($message); }
public function forgotPassword() { $signedUser = $this->app->user(); // auth if (Util\Auth::isAuth($signedUser)) { header('Location: /profile'); exit; } $form = new \Rebond\Core\User\Form($signedUser); $tpl = new Util\Template(Util\Template::MODULE, ['app', 'User']); // action // request $requestForgotPassword = Util\Converter::toString('requestForgotPassword', 'post'); if (isset($requestForgotPassword)) { $email = Util\Converter::toString('email', 'post'); if ($email == '') { Util\Session::set(Util\Lang::lang('siteError', 'emptyEmailAddress')); } else { $user = \Rebond\Core\User\Data::loadByEmail($email); if (isset($user)) { Util\Mail::resetPassword($this->app->site()->getTitle(), $user); return $tpl->render('forgot-password-send'); } else { Util\Session::set('siteError', Util\Lang::lang('emailAddressNotFound')); } } } // reset password form $reset = Util\Converter::toString('reset'); if (isset($reset)) { $user = \Rebond\Core\UserSecurity\Service::getUserBySecure($reset, \Rebond\Core\UserSecurity\Model::RESET); if (isset($user)) { $form = new \Rebond\Core\User\Form($user); // reset password $resetPassword = Util\Converter::toString('resetPassword', 'post'); if (isset($resetPassword)) { $form->changePassword('/profile', false); } $tpl = new Util\Template(Util\Template::MODULE, ['app', 'User']); $tpl->set('item', $form); $tpl->set('checkCurrentPassword', false); return $tpl->render('password-change'); } } $tpl = new Util\Template(Util\Template::MODULE, ['app', 'User']); $tpl->set('item', $form); return $tpl->render('forgot-password'); }