Example #1
0
 /**
  * Method called after the module has been setup, but before the action
  * is executed.
  * @param Context $context
  */
 function controllerStart($context)
 {
     if (!$this->config['enabled']) {
         return;
     }
     #Execute this only when it is a page controller and not when
     #it is a block, layout or some other type of controller
     if ($context->getType() != 'controller') {
         return;
     }
     #Put the action in lowercase to avoid it not being detected due to case
     $action = strtolower($context->getAction());
     #Checks for user credentials and executes in case they are not valid
     if (!$this->isAuthorized($action)) {
         $this->callDenyFunction($action);
         $view_type = $context->getViewType();
         switch ($view_type) {
             case 'html':
             case 'process':
             case 'mail':
                 $this->loginRedirect();
                 break;
             case 'json':
             case 'feed':
             default:
                 exit;
         }
         exit;
     }
     $this->started = true;
 }
 /**
  * Loads a class that belongs to the application,
  * returning its name
  *
  * @param array $path
  * @return mixed
  */
 static function includeApplicationClass(Context $context, $lang = "")
 {
     $base_module_name = $context->getBaseModuleName();
     $type_info = PhaxsiConfig::$type_info[$context->getType()];
     $class_name = $base_module_name . $type_info['suffix'];
     if (class_exists($class_name, false)) {
         if (!$type_info['parent'] || is_subclass_of($class_name, $type_info['parent'])) {
             return $class_name;
         } else {
             return false;
         }
     }
     $file_name = self::getFileName($type_info, $context->getModule(), $base_module_name, $lang);
     if (self::includeClass($file_name, $class_name, $type_info['parent'])) {
         return $class_name;
     }
     return false;
 }