public function openDialogAndGetExecutor(Trace $trace, $dialogUid, DialogData $data) { $this->openIfNotAlready($trace->addChild("opening dialog parent")); if ($this->openedDialog != null) { throw new IllegalStateException('V AIS2 screene "' . $this->data->appClassName . '" už existuje otvorený dialog. Pre otvorenie nového treba pôvodný zatvoriť.'); } $this->openedDialog = $dialogUid; return $this->executor->spawnDialogExecutor($data); }
public function openDialogAndGetExecutor(Trace $trace, $dialogUid, array $data) { $this->openIfNotAlready($trace->addChild("opening dialog parent")); if ($this->openedDialog != null) { throw new IllegalStateException('Vo fake screene "' . get_class($this) . '" už existuje otvorený dialóg. Pre otvorenie nového treba pôvodný zatvoriť.'); } $this->openedDialog = $dialogUid; return $this->executor->spawnChild($data); }
/** * Nadviaže spojenie, spustí danú "aplikáciu" v AISe * a natiahne prvotné dáta do atribútu $data. */ public function requestOpen(Trace $trace, ScreenData $data) { $trace->tlog("open screen"); $url = $this->requestBuilder->getAppInitializationUrl($data); $response = $this->connection->request($trace->addChild("get app id"), $url); $this->appId = $this->parseAppIdFromResponse($response); $response = $this->doRequest($trace->addChild("Init command"), array('eventClass' => 'avc.ui.event.AVCComponentEvent', 'command' => 'INIT')); $this->formName = $this->parseFormNameFromResponse($response); }
public static function login(Trace $trace, Login $login, AIS2ServerConnection $connection) { $trace->tlog("Creating AIS2Session"); $session = new AIS2Session($login); $trace->tlog("logging in"); if (!$login->login($connection)) { return false; } $trace->tlog("logged in correctly."); $_SESSION['AISSession'] = $session; self::redirect(); return true; }
public function login(Trace $trace, ServerConfig $serverConfig, LoginFactory $factory, AIS2ServerConnection $connection) { $login = $this->provideLogin($serverConfig, $factory, $this->request); if ($login === null) { return false; } $trace->tlog("logging in"); if (!$login->login($connection)) { return false; } $trace->tlog("logged in correctly."); $this->session->write('login/login.class', $login); FajrUtils::redirect(); assert(false); }
public function login(Trace $trace, ServerConfig $serverConfig, LoginFactory $factory, AIS2ServerConnection $connection) { $login = $this->provideLogin($serverConfig, $factory, $this->request); if ($login === null) { return false; } $trace->tlog("logging in"); if (!$login->login($connection)) { return false; } $trace->tlog("logged in correctly."); $this->session->write('login/login.class', $login); $this->session->write('server', $serverConfig); FajrUtils::redirect(); // it should be safe to end script execution here. exit; }
private function check(Trace $trace, $url, $response) { $matches = array(); if (preg_match(self::INTERNAL_ERROR_PATTERN, $response, $matches)) { $trace->tlog("Expection encountered"); throw $this->newException($matches[1], $url); } if (preg_match(self::APACHE_ERROR_PATTERN, $response, $matches)) { $trace->tlog("Expection encountered"); throw $this->newException($matches[1], $url); } if (preg_match(self::UNAUTHORIZED, $response)) { $trace->tlog("Exception encountered"); throw new LoginException("AIS hlási neautorizovaný prístup - má užívateľ prístup k aplikácii?"); } return $response; }
/** * Invoke an action given its name * * This function lookups the controller to be used in a lookup table, * tries to instantiate it and dispatch the request * * @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); $parts = explode('.', $action, 2); if (count($parts) != 2) { throw new Exception('Action name does not contain "."'); } if (empty($this->classNameTable[$parts[0]])) { throw new Exception('Could not find a mapping for action ' . $action); } $className = $this->classNameTable[$parts[0]]; $instance = new $className(); if (!$instance instanceof Controller) { throw new Exception('Class "' . $className . '" mapped to action "' . $action . '" is not a controller'); } $instance->invokeAction($trace->addChild('Target action ' . $parts[1]), $parts[1], $context); }
/** * Parse a file for cosign proxy cookies * * @param Trace $trace trace object * @param string $filename * @returns array Array of parsed service cookies indexed by name */ public function parseFile(Trace $trace, $filename) { Preconditions::checkIsString($filename, 'filename'); $cookies = array(); $subTrace = $trace->addChild('Parsing cosign proxy file'); $subTrace->tlogVariable('filename', $filename); @($file = file($filename)); if ($file === false) { $subTrace->tlog('failed'); throw new ParseException('Cannot read proxy file'); } foreach ($file as $lineContent) { $parsed = $this->parseString($subTrace, trim($lineContent)); if (isset($cookies[$parsed->getName()])) { throw new ParseException('Duplicate proxy service entry found ' . 'while parsing proxy cookies'); } $cookies[$parsed->getName()] = $parsed; } return $cookies; }
/** * Returns user's full name as reported by ais. * * @returns string */ public function getFullUserName(Trace $trace) { $userNameParser = new AIS2UserNameParser(); $simpleConn = $this->connection->getSimpleConnection(); $urlMap = $this->connection->getUrlMap(); $html = $simpleConn->request($trace->addChild('requesting AIS2 main page'), $urlMap->getStartPageUrl()); $html = $this->convertEncoding($html); $username = $userNameParser->parseUserNameFromMainPage($html); $trace->tlogVariable('username', $username); return $username; }
/** * Parses ais html into DOM. * * @param Trace $trace * @param string $html * * @returns DOMDocument parsed DOM * @throws ParseException on failure */ public static function createDomFromHtml(Trace $trace, $html) { Preconditions::checkIsString($html); $dom = new DOMDocument(); $trace->tlog("Loading html to DOM"); $loaded = @$dom->loadHTML($html); if (!$loaded) { throw new ParseException("Problem parsing html to DOM."); } $trace->tlog('Fixing id attributes in the DOM'); ParserUtils::fixIdAttributes($trace, $dom); return $dom; }
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"); } } }
private function exec(Trace $trace) { // read cookie file $this->_curlSetOption(CURLOPT_COOKIEFILE, $this->cookieFile); $output = curl_exec($this->curl); $child = $trace->addChild("Response"); $child->tlogVariable("Http resonse code", curl_getinfo($this->curl, CURLINFO_HTTP_CODE)); $child->tlogVariable("Http content type", curl_getinfo($this->curl, CURLINFO_CONTENT_TYPE)); $child->tlogVariable("Response", $output); if (curl_errno($this->curl)) { $child->tlog("There was an error receiving data"); throw new Exception("Chyba pri nadväzovaní spojenia:" . curl_error($this->curl)); } // Do not forget to save current file content $this->_curlSetOption(CURLOPT_COOKIEJAR, $this->cookieFile); return $output; }
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, HttpConnection $connection) { $serverConnection = new AIS2ServerConnection($connection, new AIS2ServerUrlMap(FajrConfig::get('AIS2.ServerName'))); $timer = new SystemTimer(); if (Input::get('logout') !== null) { 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'); } $loggedIn = FajrUtils::isLoggedIn($serverConnection); $cosignLogin = $this->provideLogin(); if (!$loggedIn && $cosignLogin != null) { FajrUtils::login($trace->addChild("logging in"), $cosignLogin, $serverConnection); $loggedIn = true; } if ($loggedIn) { DisplayManager::addContent('<div class=\'logout\'><a class="button negative" href="' . FajrUtils::linkUrl(array('logout' => true)) . '"> <img src="images/door_in.png" alt=""/>Odhlásiť</a></div>'); $screenFactory = new VSES017\VSES017_factory($serverConnection); $adminStudia = $screenFactory->newAdministraciaStudiaScreen($trace); if (Input::get('studium') === null) { Input::set('studium', 0); } $zoznamStudii = $adminStudia->getZoznamStudii($trace->addChild("Get Zoznam Studii:")); $zoznamStudiiTable = new Table(TableDefinitions::zoznamStudii(), 'studium', array('tab' => Input::get('tab'))); $zoznamStudiiTable->addRows($zoznamStudii->getData()); $zoznamStudiiTable->setOption('selected_key', Input::get('studium')); $zoznamStudiiTable->setOption('collapsed', true); $zoznamStudiiCollapsible = new Collapsible(new HtmlHeader('Zoznam štúdií'), $zoznamStudiiTable, true); DisplayManager::addContent($zoznamStudiiCollapsible->getHtml()); $zapisneListy = $adminStudia->getZapisneListy($trace->addChild('getZapisneListy'), Input::get('studium')); $zapisneListyTable = new Table(TableDefinitions::zoznamZapisnychListov(), 'list', array('studium' => Input::get('studium'), 'tab' => Input::get('tab'))); if (Input::get('list') === null) { $tmp = $zapisneListy->getData(); $lastList = end($tmp); Input::set('list', $lastList['index']); } $zapisneListyTable->addRows($zapisneListy->getData()); $zapisneListyTable->setOption('selected_key', Input::get('list')); $zapisneListyTable->setOption('collapsed', true); $zapisneListyCollapsible = new Collapsible(new HtmlHeader('Zoznam zápisných listov'), $zapisneListyTable, true); DisplayManager::addContent($zapisneListyCollapsible->getHtml()); $terminyHodnotenia = $screenFactory->newTerminyHodnoteniaScreen($trace, $adminStudia->getZapisnyListIdFromZapisnyListIndex($trace, Input::get('list')), $adminStudia->getStudiumIdFromZapisnyListIndex($trace, Input::get('list'))); if (Input::get('tab') === null) { Input::set('tab', 'TerminyHodnotenia'); } $tabs = new TabManager('tab', array('studium' => Input::get('studium'), 'list' => Input::get('list'))); // FIXME: chceme to nejak refaktorovat, aby sme nevytvarali zbytocne // objekty, ktore v konstruktore robia requesty $hodnoteniaScreen = $screenFactory->newHodnoteniaPriemeryScreen($trace, $adminStudia->getZapisnyListIdFromZapisnyListIndex($trace, Input::get('list'))); $tabs->addTab('TerminyHodnotenia', 'Moje skúšky', new MojeTerminyHodnoteniaCallback($trace, $terminyHodnotenia, $hodnoteniaScreen)); $tabs->addTab('ZapisSkusok', 'Prihlásenie na skúšky', new ZoznamTerminovCallback($trace, $terminyHodnotenia, $hodnoteniaScreen)); $tabs->addTab('ZapisnyList', 'Zápisný list', new ZapisanePredmetyCallback($trace, $terminyHodnotenia)); $tabs->addTab('Hodnotenia', 'Hodnotenia/Priemery', new HodnoteniaCallback($trace, $hodnoteniaScreen)); $tabs->setActive(Input::get('tab')); DisplayManager::addContent($tabs->getHtml()); $version = '<div>Fajr verzia ' . hescape(Version::getVersionString()) . '</div>'; DisplayManager::addContent($version); $statistics = "<div> Fajr made " . $this->statsConnection->getTotalCount() . " requests and downloaded " . $this->rawStatsConnection->getTotalSize() . " bytes (" . $this->statsConnection->getTotalSize() . " bytes uncompressed) of data from AIS2 in " . sprintf("%.3f", $this->statsConnection->getTotalTime()) . " seconds. It took " . sprintf("%.3f", $timer->getElapsedTime()) . " seconds to generate this page.</div>"; DisplayManager::addContent($statistics); } else { if (FajrConfig::get('Login.Type') == 'password') { DisplayManager::addContent('loginBox', true); } else { if (FajrConfig::get('Login.Type') == 'cosign') { DisplayManager::addContent('cosignLoginBox', true); } else { throw new Exception('Nespravna hodnota konfiguracnej volby Login.Type'); } } DisplayManager::addContent('warnings', true); DisplayManager::addContent('terms', true); DisplayManager::addContent('credits', true); $version = "<div class='version prepend-1 span-21 last increase-line-height'>\n<strong>Verzia fajru:</strong> \n"; $version .= hescape(Version::getVersionString()); $version .= '</div>'; DisplayManager::addContent($version); DisplayManager::addContent(Version::getChangelog(), false); } }
/** * Parses div tag. If it contains <b> element, it calls method spracujB, * which parses element <b>. * * @param domNode $final * * @returns array */ public function parseDiv(Trace $trace, $final) { $final2 = $final->childNodes; foreach ($final2 as $key) { if ($key->nodeType != \XML_ELEMENT_NODE) { continue; } if ($key->tagName == 'b') { $trace->tlog("Parsing node with tag name 'b' inside 'div' tag"); $pole = $this->spracujB($trace, $key); } } return $pole; }
/** * Akcia ktora sa pokusi prihlasit cloveka na danu skusku * * @param Trace $trace trace object * @param Context $context */ public function runPrihlasNaSkusku(Trace $trace, Context $context) { $request = $context->getRequest(); $response = $context->getResponse(); $predmetIndex = $request->getParameter("prihlasPredmetIndex"); $terminIndex = $request->getParameter("prihlasTerminIndex"); $predmety = $this->terminyHodnoteniaScreen->getPredmetyZapisnehoListu($trace->addChild('Predmety zapisneho listu'))->getData(); $predmetKey = -1; foreach ($predmety as $key => $row) { if ($row[PredmetyFields::INDEX] == $predmetIndex) { $predmetKey = $key; } } $childTrace = $trace->addChild('Zoznam terminov'); $terminyDialog = $this->terminyHodnoteniaScreen->getZoznamTerminovDialog($childTrace, $predmetIndex); $terminy = $terminyDialog->getZoznamTerminov($childTrace)->getData(); $terminKey = -1; foreach ($terminy as $key => $terminyRow) { if ($terminyRow[TerminyFields::INDEX] == $terminIndex) { $terminKey = $key; } } if ($predmetKey == -1 || $terminKey == -1) { throw new Exception("Ooops, predmet/termín nenájdený. Pravdepodobne\n zmena dát v AISe."); } $hash = StudiumUtils::hashNaPrihlasenie($predmety[$predmetKey][PredmetyFields::SKRATKA], $terminy[$terminIndex]); if ($hash != $request->getParameter('hash')) { throw new Exception("Ooops, nesedia údaje o termíne. Pravdepodobne zmena\n dát v AISe spôsobila posunutie tabuliek."); } if (!$terminyDialog->prihlasNaTermin($trace->addChild('prihlasujem na termin'), $terminIndex)) { throw new Exception('Na skúšku sa nepodarilo prihlásiť.'); } $response->setTemplate('redirect'); FajrUtils::redirect(array('action' => 'studium.MojeTerminyHodnotenia', 'studium' => $this->studium, 'list' => $this->zapisnyList)); }
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'); } } }
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"); } } } } } }
/** * Get the full name of the user. * Note: resulting string is not sanitized and shouldn't be * used by file/other access. * * @returns string */ public function getFullUserName(Trace $trace) { $trace->tlog('getting ais username'); return "Ing. Janko Hraško"; }
/** * Akcia pre zobrazenie mojich terminov hodnotenia * * @param Trace $trace trace object * @param Request $request request from browser * @param Response $response response information */ public function runMojeTerminyHodnotenia(Trace $trace, Context $context) { $request = $context->getRequest(); $response = $context->getResponse(); $termin = $request->getParameter('termin'); $this->terminyHodnotenia = $this->terminyHodnoteniaScreen->getTerminyHodnotenia($trace->addChild("get terminy hodnotenia")); $hodnotenia = $this->hodnoteniaScreen->getHodnotenia($trace->addChild("get hodnotenia")); $hodnoteniePredmetu = array(); foreach ($hodnotenia->getData() as $row) { $hodnoteniePredmetu[$row['nazov']] = $row['znamka']; } $this->terminyHodnoteniaActive = array(); $this->terminyHodnoteniaOld = array(); foreach ($this->terminyHodnotenia->getData() as $row) { $datum = AIS2Utils::parseAISDateTime($row['dat'] . " " . $row['cas']); if ($row['znamka'] == "") { // skusme najst znamku v hodnoteniach if (isset($hodnoteniePredmetu[$row['predmet']]) && $hodnoteniePredmetu[$row['predmet']] != "") { $row['znamka'] = $hodnoteniePredmetu[$row['predmet']] . " (z predmetu)"; } } if ($datum < time()) { if ($row['jePrihlaseny'] == 'A') { $this->terminyHodnoteniaOld[] = $row; } } else { if ($row['mozeOdhlasit'] == 1) { $row['hashNaOdhlasenie'] = $this->hashNaOdhlasenie($row); } $this->terminyHodnoteniaActive[] = $row; } } $this->prihlaseni = null; $response->set('prihlaseni', null); if ($request->getParameter('termin') != null) { $this->prihlaseni = $this->terminyHodnoteniaScreen->getZoznamPrihlasenychDialog($trace, $termin)->getZoznamPrihlasenych($trace); $response->set('prihlaseni', $this->prihlaseni->getData()); } $response->set('terminyActive', $this->terminyHodnoteniaActive); $response->set('terminyOld', $this->terminyHodnoteniaOld); $response->set('termin', $termin); $response->setTemplate('studium/mojeTerminyHodnotenia'); }
public function getTableDefinition(Trace $trace, DOMDocument $dom) { $trace->tlog("finding table definition element"); $trace->tlogVariable("", $dom->saveXML()); $element = $dom->getElementById('dataTabColGroup'); if ($element == null) { throw new ParseException("Can't find table headers"); } $list = $element->getElementsByTagName('col'); $columns = array(); foreach ($list as $node) { assert($node->hasAttribute('shortname')); $columns[] = $node->getAttribute('shortname'); } $trace->tlogVariable("Parsed columns:", $columns); return $columns; }
public static function warnWrongTableStructure(Trace $trace, $response, $tableName, array $expectedDefinition, array $definition) { Preconditions::checkIsString($tableName); if ($expectedDefinition != $definition) { $message = array('type' => 'unexpectedTableStructure', 'tableName' => $tableName); $response->addWarning($message); $child = $trace->addChild("Differences in data table " . $tableName); list($del, $both, $ins) = self::compareArrays($expectedDefinition, $definition); $child->tlogVariable('deleted', $del); $child->tlogVariable('unchanged', $both); $child->tlogVariable('inserted', $ins); $child->tlogVariable('expectedDefinition', $expectedDefinition); $child->tlogVariable('definition', $definition); } }