public function renderInfo() { $html = ''; $info = json_decode($this->info); foreach ($info as $line) { switch ($line[0]) { case 'surface': $html .= '+' . $line[1] . ' ' . \Own\Bus\Surface::value($line[2]) . '<br>'; break; case 'endOfTheMonth': case 'endOfTheYear': case 'scheduledMatch': $html .= Lang::lang($line[0]) . ': ' . $line[1]->format('smart') . '<br>'; break; case 'leagueUp': case 'leagueDown': $html .= Lang::lang($line[0]) . ': ' . \Own\Bus\Classification::value($line[1]) . '<br>'; break; case 'endRanking': $html .= Lang::lang($line[0]) . ': ' . $line[1] . ' (' . $line[2] . ' pts)<br>'; break; case 'oldMatch': $html .= Lang::lang('youHaveOldMatches', [$line[1]]) . ' (<a href="/match/history">' . Lang::lang('view') . '</a>)'; break; default: $html .= \Own\Bus\Engine::plusMinus($line[1]) . ' ' . Lang::lang($line[0]) . '<br>'; } } return $html; }
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 isAuthorized(\Rebond\Core\User\Model $user, $permission = null, $show = true, $redirect = null) { if (!isset($permission) || $permission == '') { return true; } if (!self::isAuth($user)) { if (isset($redirect)) { header('Location: ' . $redirect); exit; } return false; } $auth = \Rebond\Core\User\Data::hasAccess($user->getId(), $permission, false); if ($auth != 0) { return true; } if ($show) { Session::add('siteError', Lang::lang('errorAccess', [$permission])); } Log::log(Error::NOT_ENOUGH_PRIVILEGE, Lang::lang('errorAccess', [$permission]), __FILE__, __LINE__); if (isset($redirect)) { header('Location: ' . $redirect); exit; } return false; }
public function index() { // main $newsGadget = new \Own\App\Standard\Gadget($this->app); $userGadget = new \Own\App\User\Gadget($this->app); $column1 = []; $column2 = []; $column1[] = $userGadget->status($this->player); if ($this->signedUser->getId() == 0) { $column1[] = $newsGadget->filteredList(3); } else { $tplBook = new Util\Template(Util\Template::MODULE, ['bus', 'book']); $column1[] = $tplBook->render('own-bookings-placeholder'); $column1[] = $newsGadget->filteredList(2); if ($this->signedUser->getIsAdmin()) { $tplAdminBook = new Util\Template(Util\Template::MODULE, ['bus', 'book']); $options = []; $options['where'][] = 'status = 1'; $courts = \Own\Bus\Court\Data::loadAll($options); $tplAdminBook->set('courts', $courts); $tplAdminBook->set('days', [1 => Util\Lang::lang('monday'), 2 => Util\Lang::lang('tuesday'), 3 => Util\Lang::lang('wednesday'), 4 => Util\Lang::lang('thursday'), 5 => Util\Lang::lang('friday'), 6 => Util\Lang::lang('saturday'), 0 => Util\Lang::lang('sunday')]); $column2[] = $tplAdminBook->render('admin-book'); } } $column2[] = \Own\Bus\Book\Service::renderCalendar($this->player); return $this->response('tpl-default', ['title' => Util\Lang::lang('home')], 'layout-home', ['column1' => $column1, 'column2' => $column2]); }
public static function getCurrentMatch($id, array $redirect = []) { $options = []; $options['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'], '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_player_match.player_id = ?', $id]; $options['where'][] = 'match.status IN (1,2,3)'; $options['order'][] = 'match.scheduled'; $match = \Own\Bus\Match\Data::load($options); if (isset($match)) { if (in_array($match->getStatus(), $redirect)) { // match ready/playing and in less than half Engine::DAY if (in_array($match->getStatus(), [MatchStatus::READY, MatchStatus::PLAYING])) { // cannot play if other match in less than 1/10 Day if ($match->getScheduled() < time() + Engine::DAY * 360) { Util\Session::siteError('matchPlaying', null, '/match/schedule'); } else { Util\Session::set('siteSuccess', Util\Lang::lang('nextMatch', [$match->getScheduled()->format()])); } } } return $match; } else { if (in_array(0, $redirect)) { Util\Session::siteError('noMatch', null, '/match'); } } return null; }
public function buildParent() { if ($this->getModel()->getId() == 1) { return '<span class="input">' . Util\Lang::lang('home') . '</span>'; } $items = Service::renderList(); $disabled = []; $disabled[] = $this->getModel()->getId(); return Util\Form::buildDropdown('parentId' . $this->unique, $items, $this->getModel()->getParentId(), true, $disabled); }
public static function validateToken($unique, $class, $value, $tokenPost) { $vrf = new \Rebond\Core\Field('token'); if (self::encrypt($class . $value) != $tokenPost) { $log = '[field: token ' . $unique . ', value: ' . $value . ', tokenPost: ' . $tokenPost . ']'; Log::log(Error::TOKEN, 'Invalid token ' . $log, __FILE__, __LINE__); $vrf->setResult(ResultType::ERROR); $vrf->setMessage(Lang::lang('errorInvalidToken')); return $vrf; } return $vrf; }
public function edit() { // auth Auth::isAdminAuthorized($this->signedUser, 'admin.content', true, '/content/'); // check $moduleName = Converter::string('module'); $id = Converter::int('id'); $module = $this->findModule($moduleName); // action $appModel = '\\Rebond\\App\\' . $module->getTitle() . '\\Model'; $appData = '\\Rebond\\App\\' . $module->getTitle() . '\\Data'; $appForm = '\\Rebond\\App\\' . $module->getTitle() . '\\Form'; $model = $appData::loadById($id); if (isset($model)) { $title = $model->getTitle(); } else { $title = \Rebond\Util\Lang::lang('new', [$moduleName]); $model = new $appModel(); } $model->loadModule(); $form = new $appForm($model); // action if (isset($_POST['save'])) { Auth::isAdminAuthorized($this->signedUser, 'admin.content.edit', true, '/content/edit'); $model->setAuthorId($this->signedUser->getId()); if ($form->setFromPost()->validate()->isValid()) { $model->save(); $status = $module->getWorkflow() == 0 ? 'published' : 'pending'; Session::adminSuccess('saved', '/content/#!/' . $moduleName . '/' . $status); } else { Session::set('adminError', $form->getValidation()->getMessage()); } } // view $this->setTpl(); $tplMain = new Template(Template::MODULE, ['app', $moduleName]); // main $tplMain->set('item', $form); $tplMain->set('title', $title); $tplMain->set('filter', $module->getHasFilter()); // layout if (Auth::isAdminAuthorized($this->signedUser, 'admin.content.edit', false)) { $this->tplLayout->set('column1', $tplMain->render('admin-editor')); } else { $this->tplLayout->set('column1', $tplMain->render('admin-view')); } // master $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col')); $this->tplMaster->set('jsLauncher', 'contentEditor'); $this->tplMaster->addJs('/js/tinymce/tinymce.min.js'); return $this->tplMaster->render('tpl-default'); }
public function detail() { $this->setBaseTpl(); $gadget = new \Rebond\App\Error\Gadget($this->app); $detail = $gadget->detail(); // layout $this->tplLayout->set('column1', $detail); // master $this->tplMaster->set('site', $this->app->site()->getTitle()); $this->tplMaster->set('title', Lang::lang('error')); $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col')); return $this->tplMaster->render('tpl-default'); }
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 function generic() { $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; $error = Util\Converter::toString('404', 'get'); $tpl = new Util\Template(Util\Template::MODULE, ['app', 'error']); if ($error != '') { header('HTTP/1.1 404 Not Found'); $tpl->set('title', Util\Lang::lang('pageNotFound')); $tpl->set('error', $error); } else { $tpl->set('title', Util\Lang::lang('error')); $tpl->set('error', Util\Lang::lang('error.unknown')); } $tpl->set('referer', $referer); return $tpl->render('generic'); }
public function module() { // auth Auth::isAdminAuthorized($this->signedUser, 'admin.cms.module', true, '/cms'); // action $add = Converter::string('add', 'post'); if (isset($add)) { Auth::isAdminAuthorized($this->signedUser, 'admin.cms.module.edit', true, '/cms/module'); $moduleId = Converter::int('moduleId', 'post'); $module = \Rebond\Cms\Module\Data::loadById($moduleId); if (isset($module)) { $module->setStatus(\Rebond\Core\StatusType::ACTIVE); $module->save(); Session::adminSuccess('added', '/cms/module'); } else { Session::set('adminError', Lang::lang('mustSelectModule')); } } $options = []; $options['where'][] = 'module.status IN (0,1)'; $activeModules = \Rebond\Cms\Module\Data::loadAll($options); // view $this->setTpl(); // filter $tplFilter = new Template(Template::MODULE, ['cms', 'module']); $tplFilter->set('count', count($activeModules)); if (Auth::isAdminAuthorized($this->signedUser, 'admin.cms.module.edit', false)) { $options = []; $options['where'][] = 'module.status = 2'; $newModules = \Rebond\Cms\Module\Data::loadAll($options); $tplFilter->set('items', $newModules); } // main $tplMain = new Template(Template::MODULE, ['cms', 'module']); $tplMain->set('items', $activeModules); // layout if (Auth::isAdminAuthorized($this->signedUser, 'admin.cms.module.edit', false)) { $this->tplLayout->set('column1', $tplFilter->render('filter')); $this->tplLayout->set('column2', $tplMain->render('listing')); } else { $this->tplLayout->set('column1', $tplFilter->render('filter-config')); $this->tplLayout->set('column2', $tplMain->render('listing-config')); } // master $this->tplMaster->set('layout', $this->tplLayout->render('layout-2-row')); return $this->tplMaster->render('tpl-default'); }
public function isValid() { if ($this->isClean) { return $this->result == ResultType::SUCCESS ? true : false; } $this->result = ResultType::SUCCESS; $this->message = ''; foreach ($this->fields as $field) { if ($field->getResult() == ResultType::ERROR) { $this->result = ResultType::ERROR; $this->message = Lang::lang('errorInvalidForm'); break; } } $this->isClean = true; return $this->result == ResultType::SUCCESS ? true : false; }
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 bookings_add() { Util\Auth::isAdminAuthorized($this->signedUser, null, false, '/'); $today = new Util\DateTime(); $this->date = Util\Converter::toDate('date'); if (!isset($this->date)) { $this->date = new Util\DateTime(); } /* header('Content-Type: application/json'); echo(json_encode($this->getBookings()));exit(); */ $message = []; $message[] = $this->clearBookings(); $message[] = $this->addBookings($this->getBookings()); // main $tpl = new Util\Template(Util\Template::SITE, ['admin']); $tpl->set('today', $today->format('Y-m-d')); $tpl->set('message', implode($message, '<br>')); return $this->response('tpl-default', ['title' => Util\Lang::lang('own'), 'jsLauncher' => 'integration'], 'layout-1-col', ['column1' => $tpl->render('integration')]); }
public function generic() { $this->setBaseTpl(); // auth Auth::isAdminAuthorized($this->signedUser, null, true, '/profile/sign-in'); $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; $error = Converter::string('404', 'get'); // main if ($error != '') { header('HTTP/1.1 404 Not Found'); $this->tplMain->set('title', Lang::lang('pageNotFound')); $this->tplMain->set('error', $error); } else { $this->tplMain->set('error', Lang::lang('errorUnknown')); } $this->tplMain->set('referer', $referer); // layout $this->tplLayout->set('column1', $this->tplMain->render('generic')); // master $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col')); return $this->tplMaster->render('tpl-error'); }
public function index() { // auth if (!\Rebond\Util\Auth::isAdminAuthorized($this->signedUser, null, false)) { header('Location: /profile/sign-in'); exit; } // view $this->setTpl(); // main $tplMain = new Template(Template::SITE, ['admin']); $tplMain->set('title', $this->app->site()->getTitle()); // right $tplRight = new Template(Template::SITE, ['admin']); $pendingItems = []; if ($this->app->site()->getIsCms()) { $options = []; $options['where'][] = 'module.status = 1'; $options['where'][] = 'module.has_content = 1'; $modules = \Rebond\Cms\Module\Data::loadAll($options); if ($modules) { foreach ($modules as $module) { $appData = '\\Rebond\\App\\' . $module->getTitle() . '\\Data'; $items = $appData::loadByVersion('pending'); if (count($items) > 0) { $pendingItems[] = $items; } } } } $tplRight->set('items', $pendingItems); $tplRight->set('title', \Rebond\Util\Lang::lang('pendingItems')); // layout $this->tplLayout->set('column1', $tplMain->render('index')); $this->tplLayout->set('column2', $tplRight->render('pending')); // master $this->tplMaster->set('layout', $this->tplLayout->render('layout-2-col')); return $this->tplMaster->render('tpl-default'); }
public static function getStadeReach($tournamentId, $points, $size, $classification) { $list = ['winner', 'finalist', 'semiFinal', 'quarterFinal', 'fourthRound', 'thirdRound', 'secondRound', 'firstRound']; if ($size <= 64) { unset($list[4]); } if ($size <= 32) { unset($list[5]); } if ($size <= 16) { unset($list[6]); } $list = array_values($list); $i = 0; $maxPoints = pow(2, 11 - $classification); while ($maxPoints != $points && $maxPoints > 1) { $i++; $maxPoints /= 2; } if (!isset($list[$i])) { Util\Log::log(\Rebond\Util\Code::DEBUG, 'getStadeReach id:' . $tournamentId . ', i:' . $i . ', count:' . count($list) . ', points:' . $points, __FILE__, __LINE__); return Lang::lang($list[count($list) - 1]); } return Lang::lang($list[$i]); }
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'); }
public static function toArray() { return [1 => Lang::lang('firstServe'), 2 => Lang::lang('secondServe'), 3 => Lang::lang('return_'), 4 => Lang::lang('return_') . ' ' . Lang::lang('passing'), 5 => Lang::lang('return_') . ' ' . Lang::lang('lob'), 6 => Lang::lang('return_') . ' ' . Lang::lang('dropshot'), 7 => Lang::lang('baseline'), 8 => Lang::lang('forehand'), 9 => Lang::lang('backhand'), 10 => Lang::lang('volley'), 11 => Lang::lang('volley') . ' ' . Lang::lang('dropshot'), 12 => Lang::lang('volley') . ' ' . Lang::lang('lob'), 13 => Lang::lang('smash'), 14 => Lang::lang('smashRun'), 15 => Lang::lang('passing'), 16 => Lang::lang('lob'), 17 => Lang::lang('dropshot'), 18 => Lang::lang('dropshotRun')]; }
public static function toArray() { return [0 => Lang::lang('inactive'), 1 => Lang::lang('active'), 2 => Lang::lang('deleted')]; }
public static function toArray() { return [1 => Lang::lang('practice'), 2 => Lang::lang('league'), 3 => Lang::lang('tour')]; }
public static function toArray() { return [1 => Lang::lang('masters'), 2 => Lang::lang('grandSlam'), 3 => 'ATP 1000', 4 => 'ATP 500', 5 => 'ATP 250', 6 => Lang::lang('challenger'), 7 => Lang::lang('future'), 8 => Lang::lang('amateur')]; }
public static function toArray() { return [1 => Lang::lang('right'), 2 => Lang::lang('left')]; }
public static function toArray() { return [0 => Lang::lang('none'), 1 => Lang::lang('home'), 2 => Lang::lang('children'), 3 => Lang::lang('parent'), 4 => Lang::lang('parent2'), 5 => Lang::lang('parent3')]; }
public static function toArray() { return [0 => Lang::lang('singleItem'), 1 => Lang::lang('listing'), 2 => Lang::lang('filteredListing'), 3 => Lang::lang('customListing'), 4 => Lang::lang('generic')]; }
public function sign_in() { // auth if (Auth::isAdminAuthorized($this->signedUser)) { Session::redirect('/'); } // action $form = new \Rebond\Core\User\Form($this->signedUser); $form->signIn(); if (Auth::isAdmin($form->getModel())) { Session::redirect('/'); } if (Auth::isAuth($form->getModel())) { Session::setAndRedirect('siteError', Lang::lang('accessNonAuthorized'), 'http://' . \Rebond\Config::getPath('siteUrl')); } // view $this->setTpl(); // main $tplMain = new Template(Template::MODULE, ['core', 'user']); $tplMain->set('item', $form); // master $this->tplMaster->set('column1', $tplMain->render('sign-in')); $this->tplMaster->set('jsLauncher', 'profile'); return $this->tplMaster->render('tpl-signin'); }
public static function toArray() { return [1 => Lang::lang('leftAlways'), 2 => Lang::lang('leftOften'), 3 => Lang::lang('alternate'), 4 => Lang::lang('rightOften'), 5 => Lang::lang('rightAlways')]; }
public static function toArray() { return [0 => Lang::lang('none'), 1 => Lang::lang('surfaceClay'), 2 => Lang::lang('surfaceGrass'), 3 => Lang::lang('surfaceHard')]; }
public function forgot_password() { $userGadget = new \Own\App\User\Gadget($this->app); $forgot = $userGadget->forgotPassword(); return $this->response('tpl-default', ['title' => Util\Lang::lang('profile')], 'layout-home', ['column1' => $forgot]); }