/** * @param string $action * @param array $httpVars * @param array $fileVars */ public function applyChangeLock($actionName, $httpVars, $fileVars) { if (!isset($this->actions[$actionName])) { return; } if (is_a($this->accessDriver, "demoAccessDriver")) { throw new Exception("Write actions are disabled in demo mode!"); } $repo = $this->accessDriver->repository; $user = AuthService::getLoggedUser(); if (!AuthService::usersEnabled() && $user != null && !$user->canWrite($repo->getId())) { throw new Exception("You have no right on this action."); } $selection = new UserSelection(); $selection->initFromHttpVars(); $currentFile = $selection->getUniqueFile(); $wrapperData = $this->accessDriver->detectStreamWrapper(false); $urlBase = $wrapperData["protocol"] . "://" . $this->accessDriver->repository->getId(); $unlock = isset($httpVars["unlock"]) ? true : false; $ajxpNode = new AJXP_Node($urlBase . $currentFile); if ($unlock) { $this->metaStore->removeMetadata($ajxpNode, self::METADATA_LOCK_NAMESPACE, false, AJXP_METADATA_SCOPE_GLOBAL); } else { $this->metaStore->setMetadata($ajxpNode, SimpleLockManager::METADATA_LOCK_NAMESPACE, array("lock_user" => AuthService::getLoggedUser()->getId()), false, AJXP_METADATA_SCOPE_GLOBAL); } AJXP_XMLWriter::header(); AJXP_XMLWriter::reloadDataNode(); AJXP_XMLWriter::close(); }
function init($options) { parent::init($options); $pServ = AJXP_PluginsService::getInstance(); $aPlugs = $pServ->getActivePlugins(); $accessPlugs = $pServ->getPluginsByType("access"); $this->repository = ConfService::getRepository(); foreach ($accessPlugs as $pId => $plug) { if (array_key_exists("access." . $pId, $aPlugs) && $aPlugs["access." . $pId] === true) { $this->accessDriver = $plug; if (!isset($this->accessDriver->repository)) { $this->accessDriver->init($this->repository); $this->accessDriver->initRepository(); $wrapperData = $this->accessDriver->detectStreamWrapper(true); } else { $wrapperData = $this->accessDriver->detectStreamWrapper(false); } $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId(); } } $this->metaStore = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("metastore"); if ($this->metaStore !== false) { $this->metaStore->initMeta($this->accessDriver); } }
public function editMeta($actionName, $httpVars, $fileVars) { if (!isset($this->actions[$actionName])) { return; } if (is_a($this->accessDriver, "demoAccessDriver")) { throw new Exception("Write actions are disabled in demo mode!"); } $repo = $this->accessDriver->repository; $user = AuthService::getLoggedUser(); if (!AuthService::usersEnabled() && $user != null && !$user->canWrite($repo->getId())) { throw new Exception("You have no right on this action."); } $selection = new UserSelection(); $selection->initFromHttpVars(); $currentFile = $selection->getUniqueFile(); $wrapperData = $this->accessDriver->detectStreamWrapper(false); $urlBase = $wrapperData["protocol"] . "://" . $this->accessDriver->repository->getId(); $newValues = array(); $def = $this->getMetaDefinition(); $ajxpNode = new AJXP_Node($urlBase . $currentFile); AJXP_Controller::applyHook("node.before_change", array(&$ajxpNode)); foreach ($def as $key => $label) { if (isset($httpVars[$key])) { $newValues[$key] = AJXP_Utils::decodeSecureMagic($httpVars[$key]); } else { if (!isset($original)) { $original = $this->metaStore->retrieveMetadata($ajxpNode, "users_meta", false, AJXP_METADATA_SCOPE_GLOBAL); } if (isset($original) && isset($original[$key])) { $newValues[$key] = $original[$key]; } } } $this->metaStore->setMetadata($ajxpNode, "users_meta", $newValues, false, AJXP_METADATA_SCOPE_GLOBAL); AJXP_Controller::applyHook("node.change", array(null, &$ajxpNode)); AJXP_XMLWriter::header(); AJXP_XMLWriter::reloadDataNode("", SystemTextEncoding::toUTF8($currentFile), true); AJXP_XMLWriter::close(); }
/** * @param AbstractAccessDriver $accessDriver * @return AJXP_Node[] * @throws Exception */ public function buildNodes(AbstractAccessDriver $accessDriver) { if (isset($this->nodes)) { return $this->nodes; } $wrapperData = $accessDriver->detectStreamWrapper(false); $urlBase = $wrapperData["protocol"] . "://" . $accessDriver->repository->getId(); $nodes = array(); foreach ($this->files as $file) { $nodes[] = new AJXP_Node($urlBase . $file); } return $nodes; }