示例#1
0
 public function runInformacnyList(Trace $trace, Request $request)
 {
     $searchCode = $request->getParameter('code');
     $format = $request->getParameter('format');
     Preconditions::check(!empty($searchCode), "Nezadaný kód predmetu!");
     // Zistime aktualny akad rok.
     $akadRok = FajrUtils::getAcademicYear();
     $content = $this->registerPredmetovScreen->getInformacnyList($trace, $searchCode, $akadRok);
     // Docasny fix, vrati PDF s informacnym listom
     $response = new \Symfony\Component\HttpFoundation\Response($content, 200);
     $response->headers->set('Content-Type', 'application/pdf');
     return $response;
     $ip = new InformacnyListParser();
     $list = $ip->parse($trace, $content);
     $params = array();
     $params['list'] = $list->getAllAttributes();
     $params['code'] = $searchCode;
     $name = $list->getAttribute('nazov');
     $code = $list->getAttribute('kod');
     if ($code === false) {
         $code = $searchCode;
     } else {
         $code = $code['values'][0];
     }
     if ($name === false) {
         $name = 'Predmet ' . $code;
     } else {
         $name = $name['values'][0];
     }
     $params['subjectName'] = $name;
     return $this->renderResponse('predmety/informacnyList', $params, $format == 'json' ? 'json' : 'html');
 }
 public function runSkin(Trace $trace, Request $request)
 {
     // set skin
     if ($request->getParameter('skinSelect')) {
         $this->skinSettings->setUserSkinName($request->getParameter('skinSelect'));
         // apply the skin for current request(user skin may be applied before this function)
         $this->displayManager->setSkin($this->skinSettings->getUserSkin());
     }
     $params = array('availableSkins' => $this->skinSettings->getAvailableSkins(), 'currentSkin' => $this->skinSettings->getUserSkinName());
     return $this->renderResponse('settings/skin', $params);
 }
示例#3
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new ServerManager(SessionStorageProvider::getInstance(), Request::getInstance(), FajrConfigLoader::getConfiguration());
     }
     return self::$instance;
 }
示例#4
0
 /**
  * Provides login object created from POST-data
  * or null if login info is not (fully) present in the request.
  *
  * This function should be called only once (it will
  * return null on subsequent calls).
  *
  * @returns Login login instance recognized
  */
 private function provideLogin(ServerConfig $serverConfig, LoginFactory $factory, Request $request)
 {
     $loginType = $request->getParameter("loginType");
     $login = $request->getParameter('login');
     $password = $request->getParameter('password');
     $cosignCookie = $request->getParameter('cosignCookie');
     // we don't need this info in the global scope anymore
     $request->clearParameter('login');
     $request->clearParameter('password');
     $request->clearParameter('cosignCookie');
     if (empty($loginType)) {
         return null;
     }
     switch ($serverConfig->getLoginType()) {
         case 'password':
             $this->assertSecurity($loginType === 'password', "Wrong login type {$loginType}");
             $this->assertSecurity($login !== null, 'Login field missing');
             $this->assertSecurity($password !== null, 'Password field missing');
             if ($login === '' || $password === '') {
                 return null;
             }
             return $factory->newLoginUsingPassword($login, $password);
             break;
         case 'cosign':
             if ($loginType === 'cosigncookie') {
                 if ($cosignCookie === '') {
                     return null;
                 }
                 $cosignCookie = CosignServiceCookie::fixCookieValue($cosignCookie);
                 return $factory->newLoginUsingCosignCookie(new CosignServiceCookie($serverConfig->getCosignCookieName(), $cosignCookie, $serverConfig->getServerName()));
             } else {
                 if ($loginType == 'cosignpassword') {
                     if ($login === null || $password === null) {
                         return null;
                     }
                     return $factory->newLoginUsingCosignPassword($login, $password);
                 } else {
                     $this->assertSecurity(false, "Wrong loginType {$loginType}");
                 }
             }
             break;
         case 'cosignproxy':
             $this->assertSecurity($loginType === 'cosignproxy', "Wrong loginType {$loginType}");
             return $factory->newLoginUsingCosignProxy($serverConfig->getCosignProxyDB(), $serverConfig->getCosignCookieName());
         case 'nologin':
             $this->assertSecurity($loginType === 'nologin', "Wrong loginType {$loginType}");
             return $factory->newNoLogin();
         default:
             // TODO(ppershing): throw ConfigError
             assert(false);
     }
 }
示例#5
0
 /**
  * Akcia ktora zobrazi terminy, na ktore je mozne potencialne sa prihlasit.
  *
  * @param Trace $trace trace object
  * @param Request $request
  */
 public function runZoznamTerminov(Trace $trace, Request $request)
 {
     $this->templateParams['currentTab'] = 'ZapisSkusok';
     $schovajUznane = $request->getParameter('displayFilter', 'uznane') === 'uznane';
     if ($this->terminyHodnoteniaScreen == null) {
         return $this->renderResponse('studium/terminyHodnoteniaNedostupne', $this->templateParams);
     }
     $predmetyZapisnehoListu = $this->terminyHodnoteniaScreen->getPredmetyZapisnehoListu($trace);
     $this->warnings->warnWrongTableStructure($trace, 'terminy hodnotenia - predmety', regression\ZapisanePredmetyRegression::get(), $predmetyZapisnehoListu->getTableDefinition());
     $hodnotenia = $this->hodnoteniaScreen->getHodnotenia($trace);
     $this->warnings->warnWrongTableStructure($trace, 'hodnotenia', regression\HodnoteniaRegression::get(), $hodnotenia->getTableDefinition());
     $hodnoteniaData = array();
     foreach ($hodnotenia->getData() as $row) {
         $hodnoteniaData[$row[HodnoteniaFields::PREDMET_SKRATKA]] = $row;
     }
     $mozePrihlasitHelper = new MozePrihlasitNaTerminHelper($hodnoteniaData);
     $terminyData = array();
     $pocetSchovanychPredmetov = 0;
     foreach ($predmetyZapisnehoListu->getData() as $predmetRow) {
         $predmetSkratka = $predmetRow[PredmetyFields::SKRATKA];
         $predmetId = $predmetRow[PredmetyFields::INDEX];
         $predmet = $predmetRow[PredmetyFields::NAZOV];
         if ($schovajUznane && $hodnoteniaData[$predmetSkratka][HodnoteniaFields::UZNANE] == 'TRUE') {
             $pocetSchovanychPredmetov++;
             continue;
         }
         $childTrace = $trace->addChild('Zoznam terminov k predmetu ' . $predmet);
         $dialog = $this->terminyHodnoteniaScreen->getZoznamTerminovDialog($childTrace, $predmetId);
         $terminy = $dialog->getZoznamTerminov($childTrace);
         $this->warnings->warnWrongTableStructure($trace, 'zoznam terminov k predmetu ' . $predmet, regression\TerminyKPredmetuRegression::get(), $terminy->getTableDefinition());
         // explicitly close this dialog otherwise we will be blocked for next iteration!
         $dialog->closeWindow();
         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, $this->serverTime);
             $terminyData[] = $prihlasTerminyRow;
         }
     }
     $this->templateParams['prihlaseni'] = null;
     if ($request->getParameter('termin') !== '' && $request->getParameter('predmet') !== '') {
         $prihlaseni = $this->terminyHodnoteniaScreen->getZoznamTerminovDialog($trace, $request->getParameter('predmet'))->getZoznamPrihlasenychDialog($trace, $request->getParameter('termin'))->getZoznamPrihlasenych($trace);
         $this->warnings->warnWrongTableStructure($trace, 'zoznam prihlasenych k terminu', regression\PrihlaseniNaTerminRegression::get(), $prihlaseni->getTableDefinition());
         $this->templateParams['prihlaseni'] = $prihlaseni->getData();
     }
     $this->templateParams['predmetyZapisnehoListu'] = $predmetyZapisnehoListu;
     $this->templateParams['terminy'] = $terminyData;
     $this->templateParams['termin'] = $request->getParameter('termin');
     $this->templateParams['predmet'] = $request->getParameter('predmet');
     $this->templateParams['pocetSchovanychPredmetov'] = $pocetSchovanychPredmetov;
     return $this->renderResponse('studium/zoznamTerminov', $this->templateParams);
 }
示例#6
0
文件: Fajr.php 项目: BGCX067/fajr-git
 /**
  * Sets dafault template fields.
  * TODO: set as twig globals?
  */
 private function setResponseFields(Request $request)
 {
     $skinSettings = SkinSettings::getInstance();
     if ($request->isMobileBrowser()) {
         $skinSettings->setDefaultSkinName('mobile');
     }
     $this->displayManager->setSkin($skinSettings->getUserSkin());
     $params = array();
     $referrer = $request->getHeader('Referer');
     $pageMovedCookie = isset($_COOKIE['FajrPageMoved']);
     $pageMovedReferer = preg_match('#^https?://fajr.dcs.fmph.uniba.sk#', $referrer) === 1;
     if ($pageMovedCookie || $pageMovedReferer) {
         Warnings::getInstance()->addWarning(array('type' => 'pageMoved'));
     }
     $params['version'] = new Version();
     $params['banner_debug'] = $this->config->get(FajrConfigOptions::DEBUG_BANNER);
     if ($request->isDoNotTrack()) {
         $params['google_analytics'] = null;
     } else {
         $params['google_analytics'] = $this->config->get(FajrConfigOptions::GOOGLE_ANALYTICS_ACCOUNT);
     }
     $params['base'] = FajrUtils::basePath();
     $params['language'] = 'sk';
     $params['availableServers'] = array();
     $params['currentServer'] = array('isBeta' => false, 'instanceName' => 'Chyba');
     $server = $this->serverManager->getActiveServer();
     $serverList = $this->config->get(FajrConfigOptions::AIS_SERVERLIST);
     $params['availableServers'] = $serverList;
     $params['currentServer'] = $server;
     $params['backendType'] = $server->getBackendType();
     $params['aisVersion'] = null;
     $params['aisVersionIncompatible'] = false;
     $params['loggedIn'] = false;
     $params['developmentVersion'] = $this->config->get(FajrConfigOptions::IS_DEVEL);
     $params['statistics'] = Statistics::getInstance();
     $params['warnings'] = Warnings::getInstance();
     $this->displayManager->setDefaultParams($params);
 }