/** * Invoke an action given its name * * This function requests information necessary to operate on * VSES017 AIS application * * @param Trace $trace trace object * @param string $action action name * @param Context $context fajr context */ public function invokeAction(Trace $trace, $action, Context $context) { Preconditions::checkIsString($action); $request = $context->getRequest(); $response = $context->getResponse(); $session = $context->getSessionStorage(); // check access to application if (!in_array(AIS2ApplicationEnum::ADMINISTRACIA_STUDIA, $session->read('ais/aisApps'))) { $response->setTemplate('studium/notAvailable'); return; } $screenFactory = $this->factory; $adminStudia = $screenFactory->newAdministraciaStudiaScreen($trace); $this->studium = $request->getParameter('studium', '0'); $this->zoznamStudii = $adminStudia->getZoznamStudii($trace->addChild("Get Zoznam Studii:")); $this->zapisneListy = $adminStudia->getZapisneListy($trace->addChild('getZapisneListy'), $this->studium); FajrUtils::warnWrongTableStructure($response, 'zoznam studii', regression\ZoznamStudiiRegression::get(), $this->zoznamStudii->getTableDefinition()); FajrUtils::warnWrongTableStructure($response, 'zoznam zapisnych listov', regression\ZoznamZapisnychListovRegression::get(), $this->zapisneListy->getTableDefinition()); $this->zapisnyList = $request->getParameter('list'); if ($this->zapisnyList === '') { $tmp = $this->zapisneListy->getData(); $lastList = end($tmp); $this->zapisnyList = $lastList['index']; } $this->terminyHodnoteniaScreen = $screenFactory->newTerminyHodnoteniaScreen($trace, $adminStudia->getZapisnyListIdFromZapisnyListIndex($trace, $this->zapisnyList), $adminStudia->getStudiumIdFromZapisnyListIndex($trace, $this->zapisnyList)); // FIXME: chceme to nejak refaktorovat, aby sme nevytvarali zbytocne // objekty, ktore v konstruktore robia requesty $this->hodnoteniaScreen = $screenFactory->newHodnoteniaPriemeryScreen($trace, $adminStudia->getZapisnyListIdFromZapisnyListIndex($trace, $this->zapisnyList)); $response->set('zoznamStudii', $this->zoznamStudii); $response->set('studium', $this->studium); $response->set('zapisneListy', $this->zapisneListy); $response->set('zapisnyList', $this->zapisnyList); parent::invokeAction($trace, $action, $context); }
/** * Invoke an action given its name * * This function requests information necessary to operate on * VSES017 AIS application * * @param Trace $trace trace object * @param string $action action name * @param Context $context fajr context */ public function invokeAction(Trace $trace, $action, Context $context) { Preconditions::checkIsString($action); $request = $context->getRequest(); $response = $context->getResponse(); $session = $context->getSessionStorage(); Preconditions::checkNotNull($request); Preconditions::checkNotNull($response); Preconditions::checkNotNull($session); // check access to application $apps = $session->read('ais/aisApps'); if (!is_array($apps)) { throw new Exception("Interná chyba - zoznam AIS aplikácii je nekorektný."); } if (!in_array(AIS2ApplicationEnum::ADMINISTRACIA_STUDIA, $apps)) { $response->setTemplate('studium/notAvailable'); return; } $screenFactory = $this->factory; $adminStudia = $screenFactory->newAdministraciaStudiaScreen($trace); $this->administraciaStudiaScreen = $adminStudia; $this->studium = $request->getParameter('studium', '0'); $this->zoznamStudii = $adminStudia->getZoznamStudii($trace->addChild("Get Zoznam Studii:")); $this->zapisneListy = $adminStudia->getZapisneListy($trace->addChild('getZapisneListy'), $this->studium); FajrUtils::warnWrongTableStructure($trace, $response, 'zoznam studii', regression\ZoznamStudiiRegression::get(), $this->zoznamStudii->getTableDefinition()); FajrUtils::warnWrongTableStructure($trace, $response, 'zoznam zapisnych listov', regression\ZoznamZapisnychListovRegression::get(), $this->zapisneListy->getTableDefinition()); $zapisneListyData = $this->zapisneListy->getData(); if (count($zapisneListyData) == 0) { $this->zapisnyList = null; $this->terminyHodnoteniaScreen = null; $this->hodnoteniaScreen = null; } else { $this->zapisnyList = $request->getParameter('list'); if ($this->zapisnyList === '') { $lastList = end($zapisneListyData); $this->zapisnyList = $lastList['index']; } $this->terminyHodnoteniaScreen = $screenFactory->newTerminyHodnoteniaScreen($trace, $adminStudia->getZapisnyListIdFromZapisnyListIndex($trace, $this->zapisnyList, VSES017\AdministraciaStudiaScreen::ACTION_TERMINY_HODNOTENIA), $adminStudia->getStudiumIdFromZapisnyListIndex($trace, $this->zapisnyList, VSES017\AdministraciaStudiaScreen::ACTION_TERMINY_HODNOTENIA)); // FIXME: chceme to nejak refaktorovat, aby sme nevytvarali zbytocne // objekty, ktore v konstruktore robia requesty $this->hodnoteniaScreen = $screenFactory->newHodnoteniaPriemeryScreen($trace, $adminStudia->getZapisnyListIdFromZapisnyListIndex($trace, $this->zapisnyList, VSES017\AdministraciaStudiaScreen::ACTION_HODNOTENIA_PRIEMERY)); } $response->set('zoznamStudii', $this->zoznamStudii); $response->set('studium', $this->studium); $response->set('zapisneListy', $this->zapisneListy); $response->set('zapisnyList', $this->zapisnyList); if (array_key_exists($action, $this->actionInfo)) { $info = $this->actionInfo[$action]; if ($info['requiresZapisnyList'] && $this->zapisnyList == null) { $response->set('activeTab', $info['tabName']); $response->setTemplate('studium/chybaZapisnyList'); return; } } parent::invokeAction($trace, $action, $context); }
/** * Invoke an action given its name * * This function requests information necessary to operate on * VSST060 AIS application * * @param Trace $trace trace object * @param string $action action name * @param Context $context fajr context */ public function invokeAction(Trace $trace, $action, Context $context) { Preconditions::checkIsString($action); $request = $context->getRequest(); $response = $context->getResponse(); $session = $context->getSessionStorage(); Preconditions::checkNotNull($request); Preconditions::checkNotNull($response); Preconditions::checkNotNull($session); // check access to application $apps = $session->read('ais/aisApps'); if (!is_array($apps)) { throw new Exception("Interná chyba - zoznam AIS aplikácii je nekorektný."); } if (!in_array(AIS2ApplicationEnum::REGISTER_PREDMETOV, $apps)) { $response->setTemplate('predmety/notAvailable'); return; } $screenFactory = $this->factory; $register = $screenFactory->newRegisterPredmetovScreen($trace); $this->registerPredmetovScreen = $register; parent::invokeAction($trace, $action, $context); }
public function runLogic(Trace $trace, HttpConnection $connection) { $session = $this->context->getSessionStorage(); $loginManager = new LoginManager($session, $this->context->getRequest()); $server = $this->getServer(); $serverConnection = new AIS2ServerConnection($connection, new AIS2ServerUrlMap($server->getServerName())); $action = $this->context->getRequest()->getParameter('action', 'studium.MojeTerminyHodnotenia'); $response = $this->context->getResponse(); if ($action == 'logout') { $loginManager->logout($serverConnection); FajrUtils::redirect(array(), 'index.php'); exit; } else { if ($action == 'termsOfUse') { // TODO(anty): refactor this $response->setTemplate('termsOfUse'); return; } } if ($loginManager->shouldLogin()) { $factory = $this->injector->getInstance('LoginFactory.class'); $loginManager->login($trace->addChild("Logging in..."), $server, $factory, $serverConnection); $loggedIn = false; // login makes redirect on success } else { $loggedIn = $loginManager->isLoggedIn($serverConnection); } if ($loggedIn) { $controllerInjector = new Injector(array(new ControllerInjectorModule($serverConnection, $server, $session))); $mainScreen = $controllerInjector->getInstance('AIS2MainScreen.class'); if (($aisVersion = $session->read('ais/aisVersion')) == null) { $aisVersion = $mainScreen->getAisVersion($trace->addChild('Get AIS version')); $session->write('ais/aisVersion', $aisVersion); } if (($aisApps = $session->read('ais/aisApps')) == null) { $aisApps = $mainScreen->getAllAvailableApplications($trace->addChild('Get all applications')); $session->write('ais/aisApps', $aisApps); } if (($userName = $session->read('ais/aisUserName')) == null) { $userName = $mainScreen->getFullUserName($trace->addChild('Get user name')); $session->write('ais/aisUserName', $userName); } $response->set('aisVersion', $aisVersion); $response->set('aisVersionIncompatible', !($aisVersion >= regression\VersionRange::getMinVersion() && $aisVersion <= regression\VersionRange::getMaxVersion())); $response->set('aisUserName', $userName); $controller = new DispatchController($controllerInjector, $this->injector->getParameter('controller.dispatchMap')); $response->set("action", $action); $controller->invokeAction($trace, $action, $this->context); $response->set('statistics', $this->statistics); } else { $server = $this->getServer(); switch ($server->getLoginType()) { case 'password': $response->setTemplate('welcome'); break; case 'cosign': $response->setTemplate('welcomeCosign'); break; case 'cosignproxy': $response->setTemplate('welcomeCosignProxy'); break; case 'nologin': $response->setTemplate('welcomeDemo'); break; default: throw new Exception("Invalid type of login"); } } }
public function runLogic(Trace $trace) { $session = $this->context->getSessionStorage(); $loginManager = new LoginManager($session, $this->context->getRequest(), $this->context->getResponse()); // we are going to log in and we need a clean session. // This needs to be done before a connection // is created, because we pass cookie file name // that contains session_id into AIS2CurlConnection if ($loginManager->shouldLogin()) { $session->regenerate(true); } $connection = $this->provideConnection(); $server = $this->getServer(); $serverConnection = new AIS2ServerConnection($connection, new AIS2ServerUrlMap($server->getServerName())); $action = $this->context->getRequest()->getParameter('action', 'studium.MojeTerminyHodnotenia'); $response = $this->context->getResponse(); if ($action == 'logout') { try { $loginManager->logout($serverConnection); } catch (LoginException $e) { $this->setException($e); } } else { if ($action == 'termsOfUse') { // TODO(anty): refactor this $response->setTemplate('termsOfUse'); return; } else { if ($loginManager->shouldLogin()) { $factory = $this->injector->getInstance('LoginFactory.class'); try { $loginManager->login($trace->addChild("Logging in..."), $server, $factory, $serverConnection); } catch (LoginException $e) { $this->setException($e); try { $loginManager->logout($trace, $serverConnection); } catch (LoginException $e) { // do nothing } } } else { if ($loginManager->isLoggedIn($serverConnection)) { $response->set('loggedIn', true); $controllerInjector = new Injector(array(new ControllerInjectorModule($serverConnection, $server, $session, $this->config)), $this->config->get(FajrConfigOptions::DEBUG_EXCEPTION_SHOWSTACKTRACE)); $mainScreen = $controllerInjector->getInstance('AIS2MainScreen.class'); if (($aisVersion = $session->read('ais/aisVersion')) == null) { $aisVersion = $mainScreen->getAisVersion($trace->addChild('Get AIS version')); $session->write('ais/aisVersion', $aisVersion); } if (($aisApps = $session->read('ais/aisApps')) == null) { $aisModules = array('SP', 'LZ', 'ES', 'ST', 'RH', 'UB', 'AS', 'RP'); $aisApps = $mainScreen->getAllAvailableApplications($trace->addChild('Get all applications'), $aisModules); $session->write('ais/aisApps', $aisApps); } if (($userName = $session->read('ais/aisUserName')) == null) { $userName = $mainScreen->getFullUserName($trace->addChild('Get user name')); $session->write('ais/aisUserName', $userName); } $response->set('aisVersion', $aisVersion); $response->set('aisVersionIncompatible', !($aisVersion >= regression\VersionRange::getMinVersion() && $aisVersion <= regression\VersionRange::getMaxVersion())); $response->set('aisUserName', $userName); $controller = new DispatchController($controllerInjector, $this->injector->getParameter('controller.dispatchMap')); $response->set("action", $action); $controller->invokeAction($trace, $action, $this->context); $response->set('statistics', $this->statistics); } else { $server = $this->getServer(); switch ($server->getLoginType()) { case 'password': $response->setTemplate('welcome'); break; case 'cosign': $response->setTemplate('welcomeCosign'); break; case 'cosignproxy': $response->setTemplate('welcomeCosignProxy'); break; case 'nologin': $response->setTemplate('welcomeDemo'); break; default: throw new Exception("Invalid type of login"); } } } } } }