public function index() { Util\Auth::isAdminAuthorized($this->signedUser, 'member', true, '/'); $page = Util\Converter::toInt('page', 'get', 1); // get user settings $userSettings = $this->signedUser->getUserSettings(); $maxByPage = isset($userSettings) ? (int) $userSettings->getPagingValue() : 10; $countItems = \Own\Bus\Player\Data::count(); $page = Util\Nav::getCurrentPage($page, $countItems, $maxByPage); $options = []; $options['clearSelect'] = true; $options['select'][] = \Own\Bus\Player\Data::getList(['id', 'credits', 'level']); $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'firstname', 'lastname', 'status'], 'player_id'); $options['join'][] = 'core_user player_id ON player_id.id = player.id'; $options['order'][] = 'player_id.username'; $options['limit'][] = ($page - 1) * $maxByPage . ', ' . $maxByPage; $items = \Own\Bus\Player\Data::loadAll($options); // main $tplFilter = new Util\Template(Util\Template::SITE, ['admin']); $tplFilter->set('paging', Util\Nav::renderPaging($countItems, '/own/index?page=', $maxByPage, $page)); $tplFilter->set('itemsPerPage', Util\Nav::renderItemsPerPage($maxByPage)); $tplPlayer = new Util\Template(Util\Template::SITE, ['admin']); $tplPlayer->set('items', $items); return $this->response('tpl-default', ['title' => Util\Lang::lang('own'), 'jsLauncher' => 'own'], 'layout-1-col', ['column1' => [$tplFilter->render('players-filter'), $tplPlayer->render('players')]]); }
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 function loadOwnBookings() { $isAllowed = Util\Auth::isAuthorized($this->signedUser, 'member', false); $json = []; $json['result'] = \Rebond\Core\ResultType::ERROR; if (!$isAllowed) { $json['message'] = Util\Lang::lang('accessNonAuthorized'); return json_encode($json); } $weekAgo = new \DateTime(); $weekAgo = $weekAgo->sub(new \DateInterval('P7D')); $weekAgo = $weekAgo->format('Y-m-d'); $options = []; $options['select'][] = \Own\Bus\Player\Data::getList(['id'], 'book_player1'); $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'username', 'firstname', 'lastname'], 'book_player1_id'); $options['select'][] = \Own\Bus\Player\Data::getList(['id'], 'book_player2'); $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'username', 'firstname', 'lastname'], 'book_player2_id'); $options['join'][] = 'bus_player book_player1 ON book_player1.id = book.player1_id'; $options['join'][] = 'core_user book_player1_id ON book_player1_id.id = book_player1.id'; $options['join'][] = 'bus_player book_player2 ON book_player2.id = book.player2_id'; $options['join'][] = 'core_user book_player2_id ON book_player2_id.id = book_player2.id'; $options['where'][] = ['player1_id = ? OR player2_id = ?', $this->player->getId(), $this->player->getId()]; $options['where'][] = ['booking_date > ?', $weekAgo]; $options['limit'][] = 5; $options['order'][] = 'booking_date'; $ownBookings = Book\Data::loadAll($options); $tplBook = new Util\Template(Util\Template::MODULE, ['bus', 'book']); $tplBook->set('items', $ownBookings); $tplBook->set('playerId', $this->player->getId()); $json['html'] = $tplBook->render('own-bookings'); $json['result'] = \Rebond\Core\ResultType::SUCCESS; return json_encode($json); }
public function buildUser() { $options = []; $options['clearSelect'] = true; $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'username']); $models = \Rebond\Core\User\Data::loadAll($options); return Util\Form::buildDropdownList('userId' . $this->unique, $models, 'id', 'username', $this->getModel()->getUserId(), true); }
public function buildId() { $options = []; $options['clearSelect'] = true; $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'username']); $options['where'][] = 'status = 1'; $models = \Rebond\Core\User\Data::loadAll($options); return Util\Form::buildDropdownList('id' . $this->unique, $models, 'id', 'username', $this->getModel()->getId(), $this->idValidator['primaryKey']); }
public static function loadRanking($type, $page) { $options = []; $options['clearSelect'] = true; $options['select'][] = Data::getList(['id', 'user_id', 'country', 'experience', 'username', 'tour_ranking', 'tour_point', 'tour_diff', 'race_ranking', 'race_point', 'race_diff']); $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'avatar_id'], 'player_user'); $options['select'][] = \Rebond\Core\Media\Data::getList([], 'player_user_avatar'); $options['leftJoin'][] = 'core_user player_user ON player_user.id = player.user_id'; $options['leftJoin'][] = 'core_media player_user_avatar ON player_user_avatar.id = player_user.avatar_id'; $options['where'][] = 'player.active = 1'; $options['order'][] = 'player.' . $type . '_ranking, player.created_date'; $options['limit'][] = $page * 20 . ', 20'; return \Own\Bus\Player\Data::loadAll($options); }
public function ranking() { $id = Converter::toInt('id', 'get', $this->player->getLeagueId()); $league = \Own\Bus\League\Data::loadById($id); if (!isset($league)) { $league = $this->player->getLeague(); } // player not logged in if (!isset($league)) { Session::redirect('/league'); } // view $this->setTpl(); $cacheTime = $this->app->site()->getCacheTime(); $cache = \Rebond\Util\Cache::getCache('league-ranking', $league->getId(), $cacheTime); if (isset($cache)) { // layout $this->tplLayout->set('column1', $cache); } else { $options = []; $options['clearSelect'] = true; $options['select'][] = \Own\Bus\Player\Data::getList(['id', 'user_id', 'country', 'experience', 'username', 'league_ranking', 'league_point', 'league_diff']); $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'avatar_id'], 'player_user'); $options['select'][] = \Rebond\Core\Media\Data::getList([], 'player_user_avatar'); $options['leftJoin'][] = 'core_user player_user ON player_user.id = player.user_id'; $options['leftJoin'][] = 'core_media player_user_avatar ON player_user_avatar.id = player_user.avatar_id'; $options['where'][] = 'player.active = 1'; $options['where'][] = 'player.league_id = ' . $league->getId(); $options['order'][] = 'player.league_ranking, player.created_date'; $players = \Own\Bus\Player\Data::loadAll($options); // main $tplMain = new Template(Template::SITE, ['www']); $tplMain->set('league', $league); $tplMain->set('player', $this->player); $tplMain->set('players', $players); // layout $cache = $tplMain->render('league-ranking'); $this->tplLayout->set('column1', $cache); // cache \Rebond\Util\Cache::saveCache('league-ranking', $league->getId(), $cacheTime, $cache); } // template $this->tplMaster->set('layout', $this->tplLayout->render('layout-center')); return $this->tplMaster->render('tpl-default'); }
private static function link($linkTournament = false, $linkLeague = false, $players = false, $needBothPlayers = true) { $join = 'join'; if (!$needBothPlayers) { $join = 'leftJoin'; } $option = []; $option['clearSelect'] = true; $options['select'][] = self::getList(['id', 'player_match1_id', 'player_match2_id', 'surface', 'current_set', 'best_of_sets', 'type', 'winner_id', 'position', 'tournament_id', 'league_id', 'status', 'scheduled']); $options['select'][] = \Own\Bus\PlayerMatch\Data::getList(['id', 'player_id', 'seed', 'has_viewed', 'set1', 'set2', 'set3', 'set4', 'set5', 'points', 'level'], 'match_player_match1'); $options['select'][] = \Own\Bus\PlayerMatch\Data::getList(['id', 'player_id', 'seed', 'has_viewed', 'set1', 'set2', 'set3', 'set4', 'set5', 'points', 'level'], 'match_player_match2'); $options['select'][] = \Own\Bus\Player\Data::getList(['id', 'username', 'user_id', 'country', 'experience'], 'match_player_match1_player'); if ($players) { $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'avatar_id'], 'match_player_match1_player_user'); $options['select'][] = \Rebond\Core\Media\Data::getList([], 'match_player_match1_player_user_avatar'); } $options['select'][] = \Own\Bus\Player\Data::getList(['id', 'username', 'user_id', 'country', 'experience'], 'match_player_match2_player'); if ($players) { $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'avatar_id'], 'match_player_match2_player_user'); $options['select'][] = \Rebond\Core\Media\Data::getList([], 'match_player_match2_player_user_avatar'); } if ($linkTournament) { $options['select'][] = \Own\Bus\Tournament\Data::getList(['id', 'title', 'size', 'classification'], 'match_tournament'); } if ($linkLeague) { $options['select'][] = \Own\Bus\League\Data::getList(['id', 'title'], 'match_league'); } $options[$join][] = 'bus_player_match match_player_match1 ON match_player_match1.id = match.player_match1_id'; $options[$join][] = 'bus_player_match match_player_match2 ON match_player_match2.id = match.player_match2_id'; $options[$join][] = 'bus_player match_player_match1_player ON match_player_match1_player.id = match_player_match1.player_id'; if ($players) { $options['leftJoin'][] = 'core_user match_player_match1_player_user ON match_player_match1_player_user.id = match_player_match1_player.user_id'; $options['leftJoin'][] = 'core_media match_player_match1_player_user_avatar ON match_player_match1_player_user_avatar.id = match_player_match1_player_user.avatar_id'; } $options[$join][] = 'bus_player match_player_match2_player ON match_player_match2_player.id = match_player_match2.player_id'; if ($players) { $options['leftJoin'][] = 'core_user match_player_match2_player_user ON match_player_match2_player_user.id = match_player_match2_player.user_id'; $options['leftJoin'][] = 'core_media match_player_match2_player_user_avatar ON match_player_match2_player_user_avatar.id = match_player_match2_player_user.avatar_id'; } if ($linkTournament) { $options['leftJoin'][] = 'bus_tournament match_tournament ON match_tournament.id = match.tournament_id'; } if ($linkLeague) { $options['leftJoin'][] = 'bus_league match_league ON match_league.id = match.league_id'; } return $options; }
public function buildPublisher() { $options = []; $options['clearSelect'] = true; $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'title']); $models = \Rebond\Core\User\Data::loadAll($options); return Util\Form::buildDropdownList('publisherId' . $this->unique, $models, 'id', 'title', $this->getModel()->getPublisherId(), $this->publisherValidator['foreignKey']); }
public function past() { $page = Converter::toInt('page', 'get', 1); $options = []; $options['where'][] = 'tournament.status IN (3,4)'; $options['where'][] = 'tournament.start_date < NOW()'; $count = \Own\Bus\Tournament\Data::count($options); $options['clearSelect'] = true; $options['select'][] = \Own\Bus\Tournament\Data::getList(['id', 'title', 'size', 'classification', 'start_date', 'end_date', 'surface', 'winner_id']); $options['select'][] = \Own\Bus\Player\Data::getList(['id', 'username', 'user_id', 'country', 'experience'], 'tournament_winner'); $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'avatar_id'], 'tournament_winner_user'); $options['select'][] = \Rebond\Core\Media\Data::getList([], 'tournament_winner_user_avatar'); $options['join'][] = 'bus_player tournament_winner ON tournament_winner.id = tournament.winner_id'; $options['leftJoin'][] = 'core_user tournament_winner_user ON tournament_winner_user.id = tournament_winner.user_id'; $options['leftJoin'][] = 'core_media tournament_winner_user_avatar ON tournament_winner_user_avatar.id = tournament_winner_user.avatar_id'; $options['order'][] = 'tournament.start_date DESC'; $options['limit'][] = ($page - 1) * 20 . ', 20'; $past = \Own\Bus\Tournament\Data::loadAll($options); $registeredIds = \Own\Bus\TournamentPlayer\Data::loadRegistered($this->player->getId()); // view $this->setTpl(); // filter $tplFilter = new Template(Template::SITE, ['www']); $tplFilter->set('current', $page); $tplFilter->set('count', $count); $tplFilter->set('url', '/tournament/past?page='); // main $tplMain = new Template(Template::SITE, ['www']); $tplMain->set('past', $past); $tplMain->set('registeredIds', $registeredIds); // layout $this->tplLayout->set('column1', $tplFilter->render('tour-past-filter')); $this->tplLayout->add('column1', $tplMain->render('tour-past')); // template $this->tplMaster->set('layout', $this->tplLayout->render('layout-center')); return $this->tplMaster->render('tpl-default'); }