public static function findActionAndApply($actionName, $httpVars, $fileVars)
 {
     if ($actionName == "cross_copy") {
         $pService = AJXP_PluginsService::getInstance();
         $actives = $pService->getActivePlugins();
         $accessPlug = $pService->getPluginsByType("access");
         if (count($accessPlug)) {
             foreach ($accessPlug as $key => $objbect) {
                 if ($actives[$objbect->getId()] === true) {
                     call_user_func(array($pService->getPluginById($objbect->getId()), "crossRepositoryCopy"), $httpVars);
                     break;
                 }
             }
         }
         return;
     }
     $xPath = self::initXPath();
     $actions = $xPath->query("actions/action[@name='{$actionName}']");
     if (!$actions->length) {
         return false;
     }
     $action = $actions->item(0);
     //Check Rights
     $mess = ConfService::getMessages();
     if (AuthService::usersEnabled()) {
         $loggedUser = AuthService::getLoggedUser();
         if (AJXP_Controller::actionNeedsRight($action, $xPath, "adminOnly") && ($loggedUser == null || !$loggedUser->isAdmin())) {
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage(null, $mess[207]);
             AJXP_XMLWriter::requireAuth();
             AJXP_XMLWriter::close();
             exit(1);
         }
         if (AJXP_Controller::actionNeedsRight($action, $xPath, "read") && ($loggedUser == null || !$loggedUser->canRead(ConfService::getCurrentRootDirIndex() . ""))) {
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage(null, $mess[208]);
             AJXP_XMLWriter::requireAuth();
             AJXP_XMLWriter::close();
             exit(1);
         }
         if (AJXP_Controller::actionNeedsRight($action, $xPath, "write") && ($loggedUser == null || !$loggedUser->canWrite(ConfService::getCurrentRootDirIndex() . ""))) {
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage(null, $mess[207]);
             AJXP_XMLWriter::requireAuth();
             AJXP_XMLWriter::close();
             exit(1);
         }
     }
     $preCalls = self::getCallbackNode($xPath, $action, 'pre_processing/serverCallback', $actionName, $httpVars, $fileVars, true);
     $postCalls = self::getCallbackNode($xPath, $action, 'post_processing/serverCallback[not(@capture="true")]', $actionName, $httpVars, $fileVars, true);
     $captureCalls = self::getCallbackNode($xPath, $action, 'post_processing/serverCallback[@capture="true"]', $actionName, $httpVars, $fileVars, true);
     $mainCall = self::getCallbackNode($xPath, $action, "processing/serverCallback", $actionName, $httpVars, $fileVars, false);
     if ($captureCalls !== false) {
         ob_start();
         $params = array("pre_processor_results" => array(), "post_processor_results" => array());
     }
     if ($preCalls !== false) {
         foreach ($preCalls as $preCall) {
             // A Preprocessing callback can modify its input arguments (passed by ref)
             $preResult = self::applyCallback($xPath, $preCall, $actionName, $httpVars, $fileVars);
             if (isset($params)) {
                 $params["pre_processor_results"][$preCall->getAttribute("pluginId")] = $preResult;
             }
         }
     }
     if ($mainCall) {
         $result = self::applyCallback($xPath, $mainCall, $actionName, $httpVars, $fileVars);
         if (isset($params)) {
             $params["processor_result"] = $result;
         }
     }
     if ($postCalls !== false) {
         foreach ($postCalls as $postCall) {
             // A Preprocessing callback can modify its input arguments (passed by ref)
             $postResult = self::applyCallback($xPath, $postCall, $actionName, $httpVars, $fileVars);
             if (isset($params)) {
                 $params["post_processor_results"][$postCall->getAttribute("pluginId")] = $postResult;
             }
         }
     }
     if ($captureCalls !== false) {
         $params["ob_output"] = ob_get_contents();
         ob_end_clean();
         foreach ($captureCalls as $captureCall) {
             self::applyCallback($xPath, $captureCall, $actionName, $httpVars, $params);
         }
     } else {
         if (isset($result)) {
             return $result;
         }
     }
 }
 /**
  * Main method for querying the XML registry, find an action and all its associated processors,
  * and apply all the callbacks.
  * @static
  * @param String $actionName
  * @param array $httpVars
  * @param array $fileVars
  * @param DOMNode $action
  * @return mixed
  */
 public static function findActionAndApply($actionName, $httpVars, $fileVars, &$action = null)
 {
     $actionName = AJXP_Utils::sanitize($actionName, AJXP_SANITIZE_EMAILCHARS);
     if ($actionName == "cross_copy") {
         $pService = AJXP_PluginsService::getInstance();
         $actives = $pService->getActivePlugins();
         $accessPlug = $pService->getPluginsByType("access");
         if (count($accessPlug)) {
             foreach ($accessPlug as $key => $objbect) {
                 if ($actives[$objbect->getId()] === true) {
                     call_user_func(array($pService->getPluginById($objbect->getId()), "crossRepositoryCopy"), $httpVars);
                     break;
                 }
             }
         }
         self::$lastActionNeedsAuth = true;
         return null;
     }
     $xPath = self::initXPath();
     if ($action == null) {
         $actions = $xPath->query("actions/action[@name='{$actionName}']");
         if (!$actions->length) {
             self::$lastActionNeedsAuth = true;
             return false;
         }
         $action = $actions->item(0);
     }
     //Check Rights
     if (AuthService::usersEnabled()) {
         $loggedUser = AuthService::getLoggedUser();
         if (AJXP_Controller::actionNeedsRight($action, $xPath, "adminOnly") && ($loggedUser == null || !$loggedUser->isAdmin())) {
             $mess = ConfService::getMessages();
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage(null, $mess[207]);
             AJXP_XMLWriter::requireAuth();
             AJXP_XMLWriter::close();
             exit(1);
         }
         if (AJXP_Controller::actionNeedsRight($action, $xPath, "read") && ($loggedUser == null || !$loggedUser->canRead(ConfService::getCurrentRepositoryId() . ""))) {
             AJXP_XMLWriter::header();
             if ($actionName == "ls" & $loggedUser != null && $loggedUser->canWrite(ConfService::getCurrentRepositoryId() . "")) {
                 // Special case of "write only" right : return empty listing, no auth error.
                 AJXP_XMLWriter::close();
                 exit(1);
             }
             $mess = ConfService::getMessages();
             AJXP_XMLWriter::sendMessage(null, $mess[208]);
             AJXP_XMLWriter::requireAuth();
             AJXP_XMLWriter::close();
             exit(1);
         }
         if (AJXP_Controller::actionNeedsRight($action, $xPath, "write") && ($loggedUser == null || !$loggedUser->canWrite(ConfService::getCurrentRepositoryId() . ""))) {
             $mess = ConfService::getMessages();
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage(null, $mess[207]);
             AJXP_XMLWriter::requireAuth();
             AJXP_XMLWriter::close();
             exit(1);
         }
     }
     $preCalls = self::getCallbackNode($xPath, $action, 'pre_processing/serverCallback', $actionName, $httpVars, $fileVars, true);
     $postCalls = self::getCallbackNode($xPath, $action, 'post_processing/serverCallback[not(@capture="true")]', $actionName, $httpVars, $fileVars, true);
     $captureCalls = self::getCallbackNode($xPath, $action, 'post_processing/serverCallback[@capture="true"]', $actionName, $httpVars, $fileVars, true);
     $mainCall = self::getCallbackNode($xPath, $action, "processing/serverCallback", $actionName, $httpVars, $fileVars, false);
     if ($mainCall != null) {
         self::checkParams($httpVars, $mainCall, $xPath);
     }
     if ($captureCalls !== false) {
         // Make sure the ShutdownScheduler has its own OB started BEFORE, as it will presumabily be
         // executed AFTER the end of this one.
         AJXP_ShutdownScheduler::getInstance();
         ob_start();
         $params = array("pre_processor_results" => array(), "post_processor_results" => array());
     }
     if ($preCalls !== false) {
         foreach ($preCalls as $preCall) {
             // A Preprocessing callback can modify its input arguments (passed by ref)
             $preResult = self::applyCallback($preCall, $actionName, $httpVars, $fileVars);
             if (isset($params)) {
                 $params["pre_processor_results"][$preCall->getAttribute("pluginId")] = $preResult;
             }
         }
     }
     if ($mainCall) {
         $result = self::applyCallback($mainCall, $actionName, $httpVars, $fileVars);
         if (isset($params)) {
             $params["processor_result"] = $result;
         }
     }
     if ($postCalls !== false) {
         foreach ($postCalls as $postCall) {
             // A Preprocessing callback can modify its input arguments (passed by ref)
             $postResult = self::applyCallback($postCall, $actionName, $httpVars, $fileVars);
             if (isset($params)) {
                 $params["post_processor_results"][$postCall->getAttribute("pluginId")] = $postResult;
             }
         }
     }
     if ($captureCalls !== false) {
         $params["ob_output"] = ob_get_contents();
         ob_end_clean();
         foreach ($captureCalls as $captureCall) {
             self::applyCallback($captureCall, $actionName, $httpVars, $params);
         }
     } else {
         if (isset($result)) {
             return $result;
         }
     }
     return null;
 }