public function buy_credit() { // auth Util\Auth::isAuthorized($this->signedUser, 'member', true, '/'); $playerForm = new \Own\Bus\Player\Form($this->player, 'player'); $credits = $this->player->getCredits(); $this->player->setCredits(0); // action $add = Util\Converter::toString('add', 'post'); if (isset($add)) { $creditValidation = ['required' => true, 'integer' => true, 'minValue' => 1, 'maxValue' => 20]; $playerForm->setFromPost(['credits']); $fieldCredits = Util\Validate::validate('credits', $playerForm->getModel()->getCredits(), $creditValidation); $validation = new \Rebond\Core\Form(); $validation->addField($fieldCredits); $playerForm->setValidation($validation); if ($playerForm->getValidation()->isValid()) { $this->player->addCredits($credits); $this->player->save(); Util\Session::siteSuccess('creditsBought', '/profile'); } else { Util\Session::set('siteError', $playerForm->getValidation()->getMessage()); } } // layout $tplPlayer = new Util\Template(Util\Template::MODULE, ['bus', 'player']); $tplPlayer->set('credits', $credits); $tplPlayer->set('player', $playerForm); return $this->response('tpl-default', ['title' => Util\Lang::lang('profile')], 'layout-home', ['column1' => $tplPlayer->render('buy-credit')]); }
public static function checkMatchToView($playerId) { $match = self::loadRecentByPlayerId($playerId); if (isset($match)) { Util\Session::siteSuccess('matchView', '/'); } }
public function vs() { // auth Util\Auth::isAuthorized($this->signedUser, 'member', false, '/profile/sign-in'); $matchId = Util\Converter::toInt('matchId', 'get', 0); $options = []; $options['clearSelect'] = true; $options['select'][] = \Own\Bus\Match\Data::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'], 'match_player_match'); $options['join'][] = 'bus_player_match match_player_match'; $options['where'][] = 'match_player_match.id = match.player_match1_id OR match_player_match.id = match.player_match2_id'; $options['where'][] = ['match.id = ?', $matchId]; $options['where'][] = ['match.status IN (?)', [1, 2, 3, 4]]; $match = \Own\Bus\Match\Data::load($options); if (!isset($match)) { Util\Session::siteError('noMatch', null, '/match/schedule'); } if (in_array($match->getStatus(), [MatchStatus::PLAYING, MatchStatus::FINISHED])) { Util\Session::siteSuccess('matchStarted', '/match/view?id=' . $match->getId() . '&live=true'); } $stats1 = \Own\Bus\Match\Data::loadStatsByPlayerId($this->player->getId()); $stats2 = \Own\Bus\Match\Data::loadStatsByPlayerId($match->getPlayerMatch2()->getPlayerId(), false); // view $this->setTpl(); // main $tplMain = new Util\Template(Util\Template::SITE, ['www']); $tplMain->set('match', $match); $tplMain->set('stats1', $stats1); $tplMain->set('stats2', $stats2); // layout $this->tplLayout->set('column1', $tplMain->render('match-vs')); // template $this->tplMaster->set('layout', $this->tplLayout->render('layout-center')); return $this->tplMaster->render('tpl-default'); }