示例#1
0
 /**
  * Vraci instanci objektu Messanger, ktera je ulozena v session.
  *
  * @return Messanger
  */
 public static function getInstance()
 {
     if (Bobr_Session::getNamespace('Messanger') instanceof Lib_Messanger) {
         return Bobr_Session::getNamespace('Messanger');
     } else {
         Bobr_Session::setNamesapce('Messanger', new Lib_Messanger());
         self::$instance = Bobr_Session::getNamespace('Messanger');
         return self::$instance;
     }
 }
示例#2
0
 protected function logoutAction()
 {
     try {
         $userLogin = new Bobr_User_UserLogin();
         $userLogin->logOut();
         Lib_Messanger::addNote('Uzivatel byl odhlasen.');
         Bobr_Request_HttpRequest::redirect(Link::build('login/login'));
     } catch (UserLoginException $e) {
         echo $e->getMessage();
     }
     return '';
 }
示例#3
0
 /**
  * Pokud se jedna o dynamickou routu nastavi ji a vrati TRUE.
  *
  * @return boolean
  */
 private function checkDynamicRoute()
 {
     $dynamicRoute = new Bobr_Request_DynamicRoute($this->lang);
     $uri = Bobr_Request_HttpRequest::uri();
     foreach ($dynamicRoute->items as $route) {
         // Pokud se to projde regularem mame lokalizovanou dinamickou routu.
         // Routa se ale jeste musi projet command validatorem. Jestli na ni ma user pravo.
         if (0 < preg_match('@' . $route->command . '@', $uri, $matches)) {
             $commandValidator = new Bobr_CommandValidator();
             $command = $commandValidator->getCommand($route->moduleFunctionId);
             // Pokud by byl command null znamenalo by to, ze uzivatel nema pravo na dany command.
             if (NULL !== $command) {
                 // Zjistime jestli jsme na spravne webInstanci
                 $webInstanceValidator = new Bobr_WebInstanceValidator();
                 if (FALSE === $webInstanceValidator->isCurrent($route->getWebInstanceId())) {
                     var_dump($webInstanceValidator->isCurrent($route->getWebInstanceId()));
                     Lib_Messanger::addNote('Url byla zadana chybne, presvedcte se zda-li jste na spravne strance.');
                     Bobr_Request_HttpRequest::redirect($this->webRoot);
                 }
                 // Pokud se uri neshoduje je v ni neco navic
                 if ($uri !== $matches[0]) {
                     Lib_Messanger::addNote('Url byla zadana chybne, presvedcte se zda-li jste na spravne strance.');
                     Bobr_Request_HttpRequest::redirect($this->webRoot . $matches[0]);
                 }
                 // Odstranime prvni polozku z pole, ta nas nezajima.
                 array_shift($matches);
                 // Mergneme lokalizovany command za vychozi.
                 $command = Lib_Tools::mergeCommand($command, $matches);
                 // A nastavime hodnoty pro dalsi praci.
                 $this->setCommand($command);
                 $this->setPageId($route->pageId);
                 return TRUE;
             } else {
                 Lib_Messanger::addNote('Nemate pravo na pristup na tuto stranku.');
                 Bobr_Request_HttpRequest::redirect($this->webRoot);
                 return FALSE;
             }
         }
     }
     return FALSE;
 }
示例#4
0
 /**
  * Zvaliduje session a nastavi uzivatele.
  *
  * @return Bobr
  */
 private function setUser()
 {
     // Zvalidujem platnost Session
     new Bobr_SessionValidator();
     $validator = new Bobr_User_UserValidator();
     // Zvalidujem uzivatele v session
     if (FALSE === $validator->validate()) {
         // Uzivatel nebyl validni nastavime anonymouse
         $user = Bobr_Session::getInstance()->user = new Bobr_User_User(2);
         echo '<p>Nastavil jsem <b>' . $user->nick . '</b>.</p>';
     } else {
         $user = Bobr_Session::getInstance()->user;
         echo '<p>Uzivatel <b>' . $user->nick . '</b> mel j*z vytvorenou session.</p>';
     }
     $user = Bobr_Session::getInstance()->user;
     $webInstanceValidatdor = new Bobr_WebInstanceValidator();
     if (TRUE === $webInstanceValidatdor->validate(Lib_Tools::getWebInstance())) {
         echo '<p>Uzivatel ma pristup na tuto web instanci</p>';
     } else {
         Lib_Messanger::addError('Nemate pristup na tuto stranku.');
         //@todo tato hlaska se pri presmerovani vymaze!!
         Bobr_Request_HttpRequest::redirect('/');
     }
     return $this;
 }