Example #1
0
File: Mail.php Project: vincium/lot
 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);
 }
Example #2
0
 public function __construct(\Rebond\App $app)
 {
     if ($app->site()->getStatus() == \Rebond\Core\StatusType::INACTIVE) {
         if ($app->ajax()) {
             return ['result' => ResultType::ERROR, 'message' => Lang::lang('error.maintenance')];
         } else {
             Util\Session::redirect('/error/maintenance');
         }
     }
     parent::__construct($app);
     if ($this->signedUser->getId() != 0) {
         $options = ['where' => [['id = ?', $this->signedUser->getId()]]];
         $this->player = \Own\Bus\Player\Data::load($options);
         if ($this->player == null) {
             $this->player = \Own\Bus\Player\Service::create($this->signedUser);
         }
     } else {
         $this->player = new \Own\Bus\Player\Model();
     }
 }