/** * */ public function __invoke() { $loggedIn = $this->loginContext->currentUser(); if (!$loggedIn) { $this->redirector->redirect(303, '/'); return false; } return true; }
public function render() { error_reporting(E_ALL); ini_set('display_errors', 1); Application::loadLibrary('olmi/request'); Application::loadLibrary('core/router'); $url = ltrim($_SERVER['REQUEST_URI'], '/'); $user_session = Application::getUserSession(); $user_logged = $user_session->getUserAccount(); Router::setDefaultModuleName($user_logged ? 'profile' : 'login'); Router::route($url); $page = Application::getPage(); $page = Application::getPage(); $page->setTitle('OCS'); $page->addMeta(array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1')); $page->addMeta(array('charset' => 'utf-8')); $page->addStylesheet(coreResourceLibrary::getStaticPath('/bootstrap/css/bootstrap.min.css')); $page->addStylesheet(coreResourceLibrary::getStaticPath('/bootstrap/css/bootstrap-theme.min.css')); $page->addStylesheet(coreResourceLibrary::getStaticPath('jquery-ui/jquery-ui-bootstrap.css')); $page->addStylesheet(coreResourceLibrary::getStaticPath('/css/admin.css')); $page->addScript(coreResourceLibrary::getStaticPath('/js/jquery-1.11.3.min.js')); $page->addScript(coreResourceLibrary::getStaticPath('/jquery-ui/jquery-ui.min.js')); $page->addScript(coreResourceLibrary::getStaticPath('/bootstrap/js/bootstrap.min.js')); $page->addScript(coreResourceLibrary::getStaticPath('/js/application.js')); $page->addLiteral(' <script type="text/javascript"> jQuery(document).ready(function(){ App.init(); }); </script> '); $smarty = Application::getSmarty(); $module_name = Router::getModuleName(); $module_params = Router::getModuleParams(); if ($module_name) { $module = Application::getResourceInstance('module', $module_name); if (coreAccessControlLibrary::accessAllowed($user_logged, $module)) { $content = call_user_func(array($module, 'run'), $module_params); } else { Application::stackError(Application::gettext('You have no permission to login')); $user_session->logout(); Redirector::redirect(Application::getSeoUrl('/login?back=' . Router::getSourceUrl())); } } else { $content = Application::runModule('page404'); } $smarty->assign('content', $content); $html_head = $page->getHtmlHead(); $smarty->assign('html_head', $html_head); /*$smarty->assign('header', Application::getBlock('header')); $smarty->assign('footer', Application::getBlock('footer'));*/ $template_path = coreResourceLibrary::getTemplatePath('index'); $smarty->display($template_path); }
/** * Do everything required for the scaffold, including processing actions and * creating/displaying the page. * * @param array $schema The schema for the database. * @param \PDO $db The database connection to use. * @param string $table The table to be used. * * @return string The generated page to be displayed. */ public static function doScaffold(array $schema, \PDO $db, $table = null) { $scaffold = new Scaffold($schema, $db); if ($scaffold->processActions() === true) { $url = self::cleanUrl(); Redirector::redirect($url); } $action = isset($_GET[self::FORM_PREFIX . '_method']) ? $_GET[self::FORM_PREFIX . '_method'] : 'list'; if (is_null($table) && isset($_GET[self::FORM_PREFIX . '_table'])) { $table = $_GET[self::FORM_PREFIX . '_table']; } return $scaffold->generatePage($table, $action); }
protected function onSuccessLogin() { Redirector::redirect($this->back_url ? $this->back_url : Application::getSeoUrl("/")); }