public function mozeSaPrihlasit($row)
 {
     $prihlasRange = AIS2Utils::parseAISDateTimeRange($row['prihlasovanie']);
     $predmet = $row['predmet'];
     if (isset($this->hodnoteniaData[$predmet]['znamka'])) {
         $znamka = $this->hodnoteniaData[$predmet]['znamka'];
     } else {
         $znamka = "";
     }
     if (isset($this->hodnoteniaData[$predmet]['mozePrihlasit']) && $this->hodnoteniaData[$predmet]['mozePrihlasit'] == 'N') {
         $mozePredmet = false;
     } else {
         $mozePredmet = true;
     }
     if ($znamka != "" && $znamka != "FX" && !$mozePredmet) {
         return self::PRIHLASIT_NEMOZE_ZNAMKA;
     }
     if (!($prihlasRange['od'] < time() && $prihlasRange['do'] > time())) {
         return self::PRIHLASIT_NEMOZE_CAS;
     }
     if ($row['maxPocet'] != '' && $row['maxPocet'] == $row['pocetPrihlasenych']) {
         return self::PRIHLASIT_NEMOZE_POCET;
     }
     if (!$mozePredmet) {
         return self::PRIHLASIT_NEMOZE_INE;
     }
     if ($znamka != "" && $znamka != "FX" && $mozePredmet) {
         return self::PRIHLASIT_MOZE_ZNAMKA;
     }
     return self::PRIHLASIT_MOZE;
 }
 public function odhlasZTerminu($terminIndex)
 {
     $this->open();
     // Posleme request ze sa chceme odhlasit.
     $data = $this->requestData(array('compName' => 'odstranitTerminAction', 'eventClass' => 'avc.ui.event.AVCActionEvent', 'embObj' => array('objName' => 'terminyTable', 'dataView' => array('activeIndex' => $terminIndex, 'selectedIndexes' => $terminIndex))));
     // Odklikneme konfirmacne okno ze naozaj.
     $data = $this->requestData(array('events' => false, 'app' => false, 'dlgName' => false, 'changedProperties' => array('confirmResult' => 2)));
     if (!preg_match('@dialogManager\\.openDialog\\("PleaseWaitDlg0"@', $data)) {
         throw new Exception('Z termínu sa nepodarilo odhlásiť.<br/>Pravdepodobne termín s daným indexom neexistuje.');
     }
     // Nacitame loading obrazovku.
     $data = AIS2Utils::request('https://ais2.uniba.sk/ais/servlets/WebUIServlet?appId=' . $this->getAppId() . '&form=PleaseWaitDlg0&antiCache=' . random());
     // Zavrieme loading obrazovku. Az po tomto kroku sme naozaj odhlaseni.
     $data = $this->requestData(array('events' => false, 'dlgName' => false, 'appProperties' => array('activeDlgName' => 'PleaseWaitDlg0')));
     $message = match($data, '@webui\\.messageBox\\("([^"]*)"@');
     if ($message !== false && $message != 'Činnosť úspešne dokončená.') {
         throw new Exception("Z termínu sa (pravdepodobne) nepodarilo odhlásiť. Dôvod:<br/><b>" . $message . '</b>');
     }
     return true;
 }
 public function testDateTimeRange()
 {
     $this->assertEquals(AIS2Utils::parseAISDateTimeRange("11.01.2010 08:30 do 12.02.2011 09:40"), array('od' => mktime(8, 30, 0, 1, 11, 2010), 'do' => mktime(9, 40, 0, 2, 12, 2011)));
 }
Beispiel #4
0
 public function run()
 {
     $timer = new SystemTimer();
     $connection = null;
     $statsConnection = null;
     $rawStatsConnection = null;
     $trace = new NullTrace();
     if (FajrConfig::get('Debug.Trace') === true) {
         $trace = new HtmlTrace($timer, "--Trace--");
     }
     try {
         Input::prepare();
         $login = Input::get('login');
         Input::set('login', null);
         $krbpwd = Input::get('krbpwd');
         Input::set('krbpwd', null);
         $cosignCookie = Input::get('cosignCookie');
         Input::set('cosignCookie', null);
         // FIXME this should be refactored
         if ($login !== null && $krbpwd !== null || $cosignCookie !== null) {
             // we are going to log in, so we get 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 we regenerated the session id afterwards,
             // we could not find the cookie file after a redirect
             FajrUtils::dropSession();
         }
         $connection = new connection\CurlConnection(FajrUtils::getCookieFile());
         $rawStatsConnection = new connection\StatsConnection($connection, new SystemTimer());
         $connection = $rawStatsConnection;
         $connection = new connection\GzipDecompressingConnection($connection, FajrConfig::getDirectory('Path.Temporary'));
         $connection = new connection\AIS2ErrorCheckingConnection($connection);
         $statsConnection = new connection\StatsConnection($connection, new SystemTimer());
         $connection = $statsConnection;
         $simpleConnection = new connection\HttpToSimpleConnectionAdapter($connection);
         AIS2Utils::connection($simpleConnection);
         // toto tu je docasne
         if (Input::get('logout') !== null) {
             FajrUtils::logout($connection);
             FajrUtils::redirect();
         }
         if ($login !== null && $krbpwd !== null) {
             $loggedIn = FajrUtils::login(new CosignLogin($login, $krbpwd), $connection);
             $login = null;
             $krbpwd = null;
         } else {
             if ($cosignCookie !== null) {
                 $loggedIn = FajrUtils::login(new AIS2CookieLogin($cosignCookie), $connection);
                 $cosignCookie = null;
             } else {
                 $loggedIn = FajrUtils::isLoggedIn();
             }
         }
         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>');
             $adminStudia = new VSES017\AdministraciaStudiaScreen($trace, $simpleConnection);
             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 = new VSES017\TerminyHodnoteniaScreen($trace, $simpleConnection, $adminStudia->getIdZapisnyList($trace, Input::get('list')), $adminStudia->getIdStudium($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 = new VSES017\HodnoteniaPriemeryScreen($trace, $simpleConnection, $adminStudia->getIdZapisnyList($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 " . $statsConnection->getTotalCount() . " requests and downloaded " . $rawStatsConnection->getTotalSize() . " bytes (" . $statsConnection->getTotalSize() . " bytes uncompressed) of data from AIS2 in " . sprintf("%.3f", $statsConnection->getTotalTime()) . " seconds. It took " . sprintf("%.3f", $timer->getElapsedTime()) . " seconds to generate this page.</div>";
             DisplayManager::addContent($statistics);
         } else {
             DisplayManager::addContent('loginBox', true);
             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);
         }
     } catch (AIS2LoginException $e) {
         if ($connection) {
             FajrUtils::logout($connection);
         }
         DisplayManager::addException($e);
     } catch (Exception $e) {
         DisplayManager::addException($e);
     }
     DisplayManager::setBase(hescape(FajrUtils::basePath()));
     $trace->tlog("everything done, generating html");
     if (FajrConfig::get('Debug.Trace') === true) {
         $traceHtml = $trace->getHtml();
         DisplayManager::addContent('<div class="span-24">' . $traceHtml . '<div> Trace size:' . sprintf("%.2f", strlen($traceHtml) / 1024.0 / 1024.0) . ' MB</div></div>');
     }
     echo DisplayManager::display();
 }
 public function getHtml()
 {
     $trace = $this->trace->addChild("MojeTerminyHodnoteniaCallback");
     $trace->tlog("Executing callback");
     $terminyHodnotenia = $this->terminyHodnoteniaApp->getTerminyHodnotenia($trace->addChild("get terminy hodnotenia"));
     $hodnotenia = $this->hodnoteniaApp->getHodnotenia($trace->addChild("get hodnotenia"));
     if (Input::get('action') !== null) {
         $trace->tlog("odhlasujem zo skusky");
         assert(Input::get("action") == "odhlasZoSkusky");
         if ($this->odhlasZoSkusky(Input::get("odhlasIndex"))) {
             FajrUtils::redirect();
         } else {
             throw new Exception('Z termínu sa nepodarilo odhlásiť.');
         }
     }
     $baseUrlParams = array("studium" => Input::get("studium"), "list" => Input::get("list"), "tab" => Input::get("tab"));
     $terminyHodnoteniaTableActive = new Table(TableDefinitions::mojeTerminyHodnotenia(), 'termin', $baseUrlParams);
     $terminyHodnoteniaCollapsibleActive = new Collapsible(new HtmlHeader('Aktuálne termíny hodnotenia'), $terminyHodnoteniaTableActive);
     $terminyHodnoteniaTableOld = new Table(TableDefinitions::mojeTerminyHodnotenia(), 'termin', $baseUrlParams);
     $terminyHodnoteniaCollapsibleOld = new Collapsible(new HtmlHeader('Staré termíny hodnotenia'), $terminyHodnoteniaTableOld);
     if (Input::get('termin') != null) {
         $terminyHodnoteniaTableActive->setOption('selected_key', Input::get('termin'));
         $terminyHodnoteniaTableOld->setOption('selected_key', Input::get('termin'));
     }
     $actionUrl = FajrUtils::linkUrl($baseUrlParams);
     $hodnoteniePredmetu = array();
     foreach ($hodnotenia->getData() as $row) {
         $hodnoteniePredmetu[$row['nazov']] = $row['znamka'];
     }
     foreach ($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&nbsp;predmetu)";
             }
         }
         if ($datum < time()) {
             $row['odhlas'] = "Skúška už bola.";
             if ($row['jePrihlaseny'] == 'A') {
                 $terminyHodnoteniaTableOld->addRow($row, null);
             }
         } else {
             if ($row['mozeOdhlasit'] == 1) {
                 $class = 'terminmozeodhlasit';
                 $hash = $this->hashNaOdhlasenie($row);
                 $row['odhlas'] = "<form method='post' action='{$actionUrl}'>\n            <div>\n            <input type='hidden' name='action' value='odhlasZoSkusky'/>\n            <input type='hidden' name='odhlasIndex'\n            value='" . $row['index'] . "'/>\n            <input type='hidden' name='hash' value='{$hash}'/>\n            <button name='submit' type='submit' class='tableButton negative'>\n              <img src='images/cross.png' alt=''>Odhlás\n            </button></div></form>";
             } else {
                 $row['odhlas'] = "nedá sa";
                 $class = 'terminnemozeodhlasit';
             }
             if ($row['prihlaseny'] != 'A') {
                 $row['odhlas'] = 'Si odhlásený. Ak chceš, opäť sa prihlás.';
                 $class = 'terminodhlaseny';
             }
             $terminyHodnoteniaTableActive->addRow($row, array('class' => $class));
         }
     }
     $html = $terminyHodnoteniaCollapsibleActive->getHtml();
     $html .= $terminyHodnoteniaCollapsibleOld->getHtml();
     if (Input::get('termin') != null) {
         $prihlaseni = $this->terminyHodnoteniaApp->getZoznamPrihlasenychDialog($trace, Input::get('termin'))->getZoznamPrihlasenych($trace);
         $zoznamPrihlasenychTable = new Table(TableDefinitions::zoznamPrihlasenych(), null, array('studium', 'list'));
         $zoznamPrihlasenychTable->addRows($prihlaseni->getData());
         $zoznamPrihlasenychCollapsible = new Collapsible(new HtmlHeader('Zoznam prihlásených
       na vybratý termín'), $zoznamPrihlasenychTable);
         $html .= $zoznamPrihlasenychCollapsible->getHtml();
     }
     return $html;
 }
 public function requestData($options, $debug = false)
 {
     $data = $this->requestBuilder->buildRequestData($this->formName, $options);
     return AIS2Utils::request($this->getXmlInterfaceLocation(), $data);
 }
Beispiel #7
0
     // If we regenerated the session id afterwards,
     // we could not find the cookie file after a redirect
     FajrUtils::dropSession();
 }
 $connection = new AIS2CurlConnection(FajrUtils::getCookieFile());
 $rawStatsConnection = new AIS2StatsConnection($connection);
 $connection = $rawStatsConnection;
 $connection = new AIS2DecompressingConnection($connection, FajrConfig::getDirectory('Path.Temporary'));
 $connection = new AIS2ErrorCheckingConnection($connection);
 $statsConnection = new AIS2StatsConnection($connection);
 $connection = $statsConnection;
 if (FajrConfig::get('Debug.Connections')) {
     $debugConnection = new AIS2DebugConnection($connection);
     $connection = $debugConnection;
 }
 AIS2Utils::connection($connection);
 // toto tu je docasne
 if (Input::get('logout') !== null) {
     FajrUtils::logout($connection);
     FajrUtils::redirect();
 }
 if ($login !== null && $krbpwd !== null) {
     $loggedIn = FajrUtils::login(new AIS2CosignLogin($login, $krbpwd), $connection);
     $login = null;
     $krbpwd = null;
 } else {
     if ($cosignCookie !== null) {
         $loggedIn = FajrUtils::login(new AIS2CookieLogin($cosignCookie), $connection);
         $cosignCookie = null;
     } else {
         $loggedIn = FajrUtils::isLoggedIn();