public function runInformacnyList(Trace $trace, Context $context)
 {
     $request = $context->getRequest();
     $response = $context->getResponse();
     $code = $request->getParameter('code');
     Preconditions::check(!empty($code), "Nezadaný kód predmetu!");
     $content = $this->registerPredmetovScreen->getInformacnyList($trace, $code);
     $content = iconv("Windows-1250", "UTF-8", $content);
     $response->setTemplate('predmety/informacnyList');
     $response->set('content', $content);
 }
 public function runSkin(Trace $trace, Context $context)
 {
     $request = $context->getRequest();
     $response = $context->getResponse();
     $skinSettings = new SkinSettings($this->config, $this->settingsStorage);
     // set skin
     if ($request->getParameter('skinSelect')) {
         $skinSettings->setUserSkinName($request->getParameter('skinSelect'));
         // apply the skin for current request(user skin may be applied before this function)
         $response->setSkin($skinSettings->getUserSkin());
     }
     $response->set('availableSkins', $skinSettings->getAvailableSkins());
     $response->set('currentSkin', $skinSettings->getUserSkinName());
     $response->setTemplate('settings/skin');
 }
Exemplo n.º 3
0
 public function runLogic(Trace $trace, HttpConnection $connection)
 {
     $session = $this->injector->getInstance('Session.Storage.class');
     $loginManager = new LoginManager($session, $this->context->getRequest());
     $server = $this->getServer();
     $serverConnection = new AIS2ServerConnection($connection, new AIS2ServerUrlMap($server->getServerName()));
     $this->context->setAisConnection($serverConnection);
     $action = $this->context->getRequest()->getParameter('action', 'studium.MojeTerminyHodnotenia');
     $response = $this->context->getResponse();
     if ($action == 'logout') {
         $loginManager->logout($serverConnection);
         // unless there is an error, logout redirects and ends script execution
     } else {
         if ($action == 'termsOfUse') {
             // TODO(anty): refactor this
             $response->setTemplate('termsOfUse');
             return;
         }
     }
     if ($loginManager->shouldLogin()) {
         $factory = $this->injector->getInstance('LoginFactory.class');
         $session->write('server', $server);
         $loginManager->login($trace->addChild("Logging in..."), $server, $factory, $serverConnection);
         $loggedIn = false;
         // login makes redirect on success
         $session->remove('server');
     } else {
         $loggedIn = $loginManager->isLoggedIn($serverConnection);
     }
     if ($loggedIn) {
         $controller = $this->injector->getInstance('Controller.class');
         $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;
             default:
                 throw new Exception("Invalid type of login");
         }
     }
 }
Exemplo n.º 4
0
 public function runLogic(Trace $trace, HttpConnection $connection)
 {
     $response = $this->context->getResponse();
     $response->set('version', new Version());
     $response->set('banner_debug', FajrConfig::get('Debug.Banner'));
     // TODO(anty): toto by chcelo nastavovat nejako lepsie
     $response->set('banner_beta', FajrConfig::get('AIS2.ServerName') == 'ais2-beta.uniba.sk');
     $response->set('google_analytics', FajrConfig::get('GoogleAnalytics.Account'));
     $response->set('serverName', FajrConfig::get('AIS2.ServerName'));
     $response->set('cosignCookieName', FajrConfig::get('Login.Cosign.CookieName'));
     $response->set('instanceName', FajrConfig::get('AIS2.InstanceName'));
     $serverConnection = new AIS2ServerConnection($connection, new AIS2ServerUrlMap(FajrConfig::get('AIS2.ServerName')));
     $this->context->setAisConnection($serverConnection);
     $action = $this->context->getRequest()->getParameter('action', 'studium.MojeTerminyHodnotenia');
     if ($action == 'logout') {
         FajrUtils::logout($serverConnection);
         // TODO(anty): fix this in a better way
         if (FajrConfig::get('Login.Type') == 'cosign') {
             // location header set in CosignProxyLogin
             // but we can't exit there because
             // the session wouldn't get dropped
             exit;
         }
         FajrUtils::redirect(array(), 'index.php');
     } else {
         if ($action == 'termsOfUse') {
             $response->setTemplate('termsOfUse');
             return;
         }
     }
     $loggedIn = FajrUtils::isLoggedIn($serverConnection);
     $cosignLogin = $this->provideLogin();
     if (!$loggedIn && $cosignLogin != null) {
         FajrUtils::login($trace->addChild("logging in"), $cosignLogin, $serverConnection);
         $loggedIn = true;
     }
     if ($loggedIn) {
         $controller = $this->injector->getInstance('Controller.class');
         $response->set("action", $action);
         $controller->invokeAction($trace, $action, $this->context);
         $response->set('statistics', $this->statistics);
     } else {
         if (FajrConfig::get('Login.Type') == 'password') {
             $response->setTemplate('welcome');
         } else {
             $response->setTemplate('welcomeCosign');
         }
     }
 }
Exemplo n.º 5
0
 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");
         }
     }
 }
Exemplo n.º 6
0
 public function runZoznamTerminov(Trace $trace, Context $context)
 {
     $request = $context->getRequest();
     $response = $context->getResponse();
     $this->predmetyZapisnehoListu = $this->terminyHodnoteniaScreen->getPredmetyZapisnehoListu($trace);
     $hodnoteniaData = array();
     foreach ($this->hodnoteniaScreen->getHodnotenia($trace)->getData() as $row) {
         $hodnoteniaData[$row['nazov']] = $row;
     }
     $this->hodnoteniaData = $hodnoteniaData;
     $this->terminyData = array();
     foreach ($this->predmetyZapisnehoListu->getData() as $predmetRow) {
         $dialog = $this->terminyHodnoteniaScreen->getZoznamTerminovDialog($trace->addChild('Get zoznam terminov'), $predmetRow['index']);
         $terminy = $dialog->getZoznamTerminov($trace->addChild('Get zoznam terminov'));
         unset($dialog);
         foreach ($terminy->getData() as $row) {
             $row['predmet'] = $predmetRow['nazov'];
             $row['predmetIndex'] = $predmetRow['index'];
             $row['znamka'] = $hodnoteniaData[$row['predmet']]['znamka'];
             $row['hashNaPrihlasenie'] = $this->hashNaPrihlasenie($predmetRow['nazov'], $row);
             $row['mozeSaPrihlasit'] = $this->mozeSaPrihlasit($row);
             $this->terminyData[] = $row;
         }
     }
     $this->prihlaseni = null;
     $response->set('prihlaseni', null);
     if ($request->getParameter('termin') != null && $request->getParameter('predmet') != null) {
         $this->prihlaseni = $this->terminyHodnoteniaScreen->getZoznamTerminovDialog($trace, $request->getParameter('predmet'))->getZoznamPrihlasenychDialog($trace, $request->getParameter('termin'))->getZoznamPrihlasenych($trace);
         $response->set('prihlaseni', $this->prihlaseni->getData());
     }
     $response->set('predmetyZapisnehoListu', $this->predmetyZapisnehoListu);
     $response->set('terminy', $this->terminyData);
     $response->set('termin', $request->getParameter('termin'));
     $response->set('predmet', $request->getParameter('predmet'));
     $response->setTemplate('studium/zoznamTerminov');
 }
Exemplo n.º 7
0
 /**
  * Akcia ktora zobrazi terminy, na ktore je mozne potencialne sa prihlasit.
  *
  * @param Trace $trace trace object
  * @param Context $context
  */
 public function runZoznamTerminov(Trace $trace, Context $context)
 {
     $request = $context->getRequest();
     $response = $context->getResponse();
     $predmetyZapisnehoListu = $this->terminyHodnoteniaScreen->getPredmetyZapisnehoListu($trace);
     $hodnoteniaData = array();
     foreach ($this->hodnoteniaScreen->getHodnotenia($trace)->getData() as $row) {
         $hodnoteniaData[$row[HodnoteniaFields::PREDMET_SKRATKA]] = $row;
     }
     $mozePrihlasitHelper = new MozePrihlasitNaTerminHelper($hodnoteniaData);
     $terminyData = array();
     foreach ($predmetyZapisnehoListu->getData() as $predmetRow) {
         $predmetSkratka = $predmetRow[PredmetyFields::SKRATKA];
         $predmetId = $predmetRow[PredmetyFields::INDEX];
         $predmet = $predmetRow[PredmetyFields::NAZOV];
         $childTrace = $trace->addChild('Get zoznam terminov');
         $dialog = $this->terminyHodnoteniaScreen->getZoznamTerminovDialog($childTrace, $predmetId);
         $terminy = $dialog->getZoznamTerminov($childTrace);
         // explicitly close this dialog otherwise we will be blocked for next iteration!
         $dialog->closeIfNeeded($childTrace);
         foreach ($terminy->getData() as $row) {
             $prihlasTerminyRow = $row;
             $prihlasTerminyRow[PrihlasTerminyFields::PREDMET] = $predmet;
             $prihlasTerminyRow[PrihlasTerminyFields::PREDMET_INDEX] = $predmetId;
             $prihlasTerminyRow[PrihlasTerminyFields::PREDMET_SKRATKA] = $predmetSkratka;
             $prihlasTerminyRow[PrihlasTerminyFields::ZNAMKA] = $hodnoteniaData[$predmetSkratka][HodnoteniaFields::ZNAMKA];
             $prihlasTerminyRow[PrihlasTerminyFields::HASH_PRIHLASENIE] = StudiumUtils::hashNaPrihlasenie($predmetSkratka, $row);
             // PrihlasTerminyFields::ZNAMKA, PREDMET_SKRATKA must be set before!
             $prihlasTerminyRow[PrihlasTerminyFields::FAJR_MOZE_PRIHLASIT] = $mozePrihlasitHelper->mozeSaPrihlasit($prihlasTerminyRow, time());
             $terminyData[] = $prihlasTerminyRow;
         }
     }
     $response->set('prihlaseni', null);
     if ($request->getParameter('termin') !== '' && $request->getParameter('predmet') !== '') {
         $prihlaseni = $this->terminyHodnoteniaScreen->getZoznamTerminovDialog($trace, $request->getParameter('predmet'))->getZoznamPrihlasenychDialog($trace, $request->getParameter('termin'))->getZoznamPrihlasenych($trace);
         $response->set('prihlaseni', $prihlaseni->getData());
     }
     $response->set('predmetyZapisnehoListu', $predmetyZapisnehoListu);
     $response->set('terminy', $terminyData);
     $response->set('termin', $request->getParameter('termin'));
     $response->set('predmet', $request->getParameter('predmet'));
     $response->setTemplate('studium/zoznamTerminov');
 }
Exemplo n.º 8
0
 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");
                     }
                 }
             }
         }
     }
 }