protected function parseSpecificContributions(&$contribNode) { parent::parseSpecificContributions($contribNode); if ($contribNode->nodeName != "actions") { return; } $actionXpath = new DOMXPath($contribNode->ownerDocument); if (!isset($this->options["FTP_LOGIN_SCREEN"]) || $this->options["FTP_LOGIN_SCREEN"] != "TRUE" || $this->options["FTP_LOGIN_SCREEN"] === false) { // Remove "ftp_login" && "ftp_set_data" actions $nodeList = $actionXpath->query('action[@name="dynamic_login"]', $contribNode); if (!$nodeList->length) { return; } unset($this->actions["dynamic_login"]); $contribNode->removeChild($nodeList->item(0)); $nodeList = $actionXpath->query('action[@name="ftp_set_data"]', $contribNode); if (!$nodeList->length) { return; } unset($this->actions["ftp_set_data"]); $contribNode->removeChild($node = $nodeList->item(0)); } else { // Replace "login" by "dynamic_login" $loginList = $actionXpath->query('action[@name="login"]', $contribNode); if ($loginList->length && $loginList->item(0)->getAttribute("auth_ftp_impl") == null) { $contribNode->removeChild($loginList->item(0)); } $dynaLoginList = $actionXpath->query('action[@name="dynamic_login"]', $contribNode); if ($dynaLoginList->length) { $dynaLoginList->item(0)->setAttribute("name", "login"); $dynaLoginList->item(0)->setAttribute("auth_ftp_impl", "true"); } } }
protected function parseSpecificContributions(&$contribNode) { parent::parseSpecificContributions($contribNode); if ($this->masterSlaveMode) { return; } if ($contribNode->nodeName != "actions") { return; } // Replace callback code $actionXpath = new DOMXPath($contribNode->ownerDocument); $loginCallbackNodeList = $actionXpath->query('action[@name="login"]/processing/clientCallback', $contribNode); if (!$loginCallbackNodeList->length) { return; } $xmlContent = file_get_contents(AJXP_INSTALL_PATH . "/plugins/auth.multi/login_patch.xml"); $sources = array(); if (!isset($this->options) || !isset($this->options["DRIVERS"]) || !is_array($this->options["DRIVERS"])) { return; } foreach ($this->getOption("DRIVERS") as $driverDef) { $dName = $driverDef["NAME"]; if (isset($driverDef["LABEL"])) { $dLabel = $driverDef["LABEL"]; } else { $dLabel = $driverDef["NAME"]; } $sources[$dName] = $dLabel; } $xmlContent = str_replace("AJXP_MULTIAUTH_SOURCES", json_encode($sources), $xmlContent); $xmlContent = str_replace("AJXP_MULTIAUTH_MASTER", $this->getOption("MASTER_DRIVER"), $xmlContent); $xmlContent = str_replace("AJXP_USER_ID_SEPARATOR", $this->getOption("USER_ID_SEPARATOR"), $xmlContent); $patchDoc = new DOMDocument(); $patchDoc->loadXML($xmlContent); $patchNode = $patchDoc->documentElement; $imported = $contribNode->ownerDocument->importNode($patchNode, true); $loginCallback = $loginCallbackNodeList->item(0); $loginCallback->parentNode->replaceChild($imported, $loginCallback); //var_dump($contribNode->ownerDocument->saveXML($contribNode)); }