Exemplo n.º 1
0
 public function authorize(Controller $controller)
 {
     if (!$controller->isAjax()) {
         throw new UserError('This action is only accessible through AJAX requests');
     }
     $controller->disableDecorator();
     return true;
 }
Exemplo n.º 2
0
 public function authorize(Controller $controller)
 {
     if (isset($this->login) === false) {
         throw new ConstraintArgumentException(get_class($this), 'login');
     }
     $user = $controller->user();
     return $user->login() === $this->login;
 }
Exemplo n.º 3
0
 public function authorize(Controller $controller)
 {
     if (isset($this->name) === false) {
         throw new ConstraintArgumentException(get_class($this), 'name');
     }
     if (isset($this->inherit) === false) {
         $this->inherit = true;
     }
     $user = $controller->user();
     return $user->hasGroup($this->name, $this->inherit) === false;
 }
Exemplo n.º 4
0
 public function authorize(Controller $controller)
 {
     if (isset($this->name) === false) {
         throw new ConstraintArgumentException(get_class($this), 'name');
     }
     if (self::$authorized) {
         return true;
     }
     $user = $controller->user();
     return self::$authorized = $user->hasRole($this->name);
 }
Exemplo n.º 5
0
 /**
  * Main function
  * Launches core classes of the framework
  * @static
  */
 public static function run()
 {
     date_default_timezone_set('UTC');
     Autoloader::register(ROOT, LIB, DOCTRINE);
     // Register contraint classes to use in the annotations of controllers
     Addendum::registerNamespaces('Cognosys\\Constraints');
     Config::load(CONFIG . 'main.yml');
     if (Config::get('development')) {
         error_reporting(E_ALL | E_STRICT);
     }
     Mail::configure(Config::get('mail'));
     $request = null;
     $response = null;
     try {
         $request = new Request(Config::get('root'));
         // redirects the execution to a controller
         // according to the request parameters
         $response = new Response($request, Config::get('routes'), Config::get('cogs'));
         $controller = Controller::factory($request, $response, Config::get('database'));
         Widget::controller($controller);
         // allow widgets to access controller
         $controller->setDecorator(Config::get('templates/default'));
         $controller->run();
     } catch (Error $e) {
         $e->handle($request, $response, Config::get('templates/error'));
     } catch (Exception $e) {
         //TODO: handle everything else
         echo "An unexpected error occured!<br><br>";
         echo "{$e->getMessage()}<br>";
         var_dump(nl2br($e->getTraceAsString()));
     }
 }
Exemplo n.º 6
0
 public function authorize(Controller $controller)
 {
     return $controller->isPost();
 }