/**
  * Sets the current sheet. Default is 'main'.
  * @param string $sheet
  * @return
  */
 public static function ln($sheet)
 {
     if (self::$translator === NULL) {
         self::$translator = Environment::getService('ITranslator');
     }
     return self::$translator->setCurrentSheet($sheet);
 }
Exemplo n.º 2
0
 public function authenticate(array $credentials)
 {
     $login = $credentials['username'];
     $password = $this->phash($credentials['password']);
     $super_admin = Environment::getVariable('admin');
     if ($login == $super_admin['login']) {
         if ($password == $super_admin['password']) {
             $super_admin['roles'] = array('super admin');
             $super_admin['id'] = 0;
             $row = new DibiRow($super_admin);
             MokujiServiceLocator::addService('UserAuthorizator', new Admin_UserModel());
         } else {
             throw new AuthenticationException("Invalid password.", self::INVALID_CREDENTIAL);
         }
     } else {
         try {
             $login_manager = Environment::getService('UserAuthenticator');
             $row = $login_manager->authenticate($credentials);
         } catch (InvalidStateException $e) {
             throw new AuthenticationException("Login and password combination failed.", self::INVALID_CREDENTIAL);
         }
     }
     $identity = new Identity($row->id, $row->roles, $row);
     $identity->id = $row->id;
     return $identity;
 }
Exemplo n.º 3
0
 private function gatherActions()
 {
     $service = Environment::getService('Nette\\Loaders\\RobotLoader');
     $class_list = $service->list;
     $actions = array();
     foreach ($class_list as $class => $file) {
         //zachtime annotation exception lebo nette si generuje nejake annotation claasy do robotloodera
         try {
             $r = new ReflectionClass($class);
             if ($r->isSubclassOf('Admin_SecurePresenter') && $r->getName() != 'BaseModulePresenter') {
                 $methods = $r->getMethods(ReflectionMethod::IS_PUBLIC);
                 foreach ($methods as $method) {
                     if (String::lower($method->class) == $class) {
                         if (strpos($method->getName(), 'action') !== false || strpos($method->getName(), 'handle') !== false) {
                             $actions[$class][] = $method->getName();
                         }
                     }
                 }
             }
         } catch (ReflectionException $e) {
         }
     }
     $actions = array_merge($actions, Environment::getApplication()->getModulesPermissions());
     $model = new UsersModuleModel();
     $model->saveActions($actions);
     return $actions;
 }
Exemplo n.º 4
0
 public function startup()
 {
     parent::startup();
     if (!isset($this->lang)) {
         $this->lang = $this->getHttpRequest()->detectLanguage($this->langs);
         if ($this->lang == null) {
             $this->lang = 'en';
         }
         $this->canonicalize();
     }
     $this->translator = Environment::getService('Mokuji\\Translator\\Admin');
     $this->translator->lang = $this->lang;
     //$this->translator = new Admin_Translator($this->lang);
     $cache = Environment::getCache('langs');
     $langs = $cache->offsetGet('langs');
     if ($langs == NULL) {
         $this->langs = $this->translator->getSupportedLangs();
         //$this->model('lang')->getAll();
         $cache->save('langs', $this->langs);
     } else {
         $this->langs = $langs;
     }
     $this->refreshConfig();
 }
Exemplo n.º 5
0
 /**
  * Returns current authorization handler.
  * @return IAuthorizator
  */
 public final function getAuthorizationHandler()
 {
     if ($this->authorizationHandler === NULL) {
         $this->authorizationHandler = Environment::getService('Nette\\Security\\IAuthorizator');
     }
     return $this->authorizationHandler;
 }
 /**
  * Texyla preview
  */
 public function actionPreview()
 {
     $texy = Environment::getService("Texy");
     $html = $texy->process(Environment::getHttpRequest()->getPost("texy"));
     $this->terminate(new RenderResponse($html));
 }
Exemplo n.º 7
0
 public function getTranslator()
 {
     if (is_null($this->translator)) {
         $this->translator = Environment::getService('Nette\\ITranslator');
     }
     return $this->translator;
 }
Exemplo n.º 8
0
 /**
  * Returns the ICacheJournal
  * @return ICacheJournal
  */
 protected function getJournal()
 {
     if ($this->journal === NULL) {
         $this->journal = Environment::getService('Nette\\Caching\\ICacheJournal');
     }
     return $this->journal;
 }