/** * * @param AJXP_Node $oldFile * @param AJXP_Node $newFile * @param Boolean $copy */ public function moveMeta($oldFile, $newFile = null, $copy = false) { if ($oldFile == null) { return; } $feedStore = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("feed"); if ($feedStore !== false) { $feedStore->updateMetaObject($oldFile->getRepositoryId(), $oldFile->getPath(), $newFile != null ? $newFile->getPath() : null, $copy); return; } if (!$copy && $this->metaStore->inherentMetaMove()) { return; } $oldMeta = $this->metaStore->retrieveMetadata($oldFile, AJXP_META_SPACE_COMMENTS); if (!count($oldMeta)) { return; } // If it's a move or a delete, delete old data if (!$copy) { $this->metaStore->removeMetadata($oldFile, AJXP_META_SPACE_COMMENTS); } // If copy or move, copy data. if ($newFile != null) { $this->metaStore->setMetadata($newFile, AJXP_META_SPACE_COMMENTS, $oldMeta); } }
/** * @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(); }
public function invalidateHash($oldNode = null, $newNode = null, $copy = false) { if ($this->metaStore == false) { return; } if ($oldNode == null) { return; } $this->metaStore->removeMetadata($oldNode, FileHasher::METADATA_HASH_NAMESPACE, false, AJXP_METADATA_SCOPE_GLOBAL); }
/** * @param AJXP_Node $oldNode * @param AJXP_Node $newNode * @param bool $copy */ public function invalidateHash($oldNode = null, $newNode = null, $copy = false) { if ($this->metaStore == false) { return; } if ($oldNode != null) { $this->metaStore->removeMetadata($oldNode, FileHasher::METADATA_HASH_NAMESPACE, false, AJXP_METADATA_SCOPE_GLOBAL); } if ($this->getFilteredOption("CACHE_XML_TREE") === true && is_file($this->getTreeName())) { @unlink($this->getTreeName()); } }
/** * @param string $action * @param array $httpVars * @param array $fileVars */ public function applyChangeLock($actionName, $httpVars, $fileVars) { 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($repo, $httpVars); $unlock = isset($httpVars["unlock"]) ? true : false; if ($unlock) { $this->metaStore->removeMetadata($selection->getUniqueNode(), self::METADATA_LOCK_NAMESPACE, false, AJXP_METADATA_SCOPE_GLOBAL); } else { $this->metaStore->setMetadata($selection->getUniqueNode(), SimpleLockManager::METADATA_LOCK_NAMESPACE, array("lock_user" => AuthService::getLoggedUser()->getId()), false, AJXP_METADATA_SCOPE_GLOBAL); } AJXP_XMLWriter::header(); AJXP_XMLWriter::reloadDataNode(); AJXP_XMLWriter::close(); }
/** * * @param AJXP_Node $oldNode * @param AJXP_Node $newNode * @param Boolean $copy */ public function updateMetaLocation($oldNode, $newNode = null, $copy = false) { $defs = $this->getMetaDefinition(); $updateField = $createField = null; foreach ($defs as $f => $data) { if ($data["type"] == "updater") { $updateField = $f; } else { if ($data["type"] == "creator") { $createField = $f; } } } $valuesUpdate = isset($updateField) || isset($createField); $currentUser = null; if ($valuesUpdate) { $currentUser = AuthService::getLoggedUser()->getId(); } if ($oldNode == null && !$valuesUpdate) { return; } if (!$copy && !$valuesUpdate && $this->metaStore->inherentMetaMove()) { return; } if ($oldNode == null) { $oldMeta = $this->metaStore->retrieveMetadata($newNode, "users_meta", false, AJXP_METADATA_SCOPE_GLOBAL); } else { $oldMeta = $this->metaStore->retrieveMetadata($oldNode, "users_meta", false, AJXP_METADATA_SCOPE_GLOBAL); } if ($valuesUpdate) { if (isset($updateField)) { $oldMeta[$updateField] = $currentUser; } if (isset($createField) && $oldNode == null) { $oldMeta[$createField] = $currentUser; } } if (!count($oldMeta)) { return; } // If it's a move or a delete, delete old data if ($oldNode != null && !$copy) { $this->metaStore->removeMetadata($oldNode, "users_meta", false, AJXP_METADATA_SCOPE_GLOBAL); } // If copy or move, copy data. if ($newNode != null) { $this->metaStore->setMetadata($newNode, "users_meta", $oldMeta, false, AJXP_METADATA_SCOPE_GLOBAL); } }
/** * * @param AJXP_Node $oldFile * @param AJXP_Node $newFile * @param Boolean $copy */ public function updateMetaLocation($oldFile, $newFile = null, $copy = false) { if ($oldFile == null) { return; } $oldMeta = $this->metaStore->retrieveMetadata($oldFile, "users_meta", false, AJXP_METADATA_SCOPE_GLOBAL); if (!count($oldMeta)) { return; } // If it's a move or a delete, delete old data if (!$copy) { $this->metaStore->removeMetadata($oldFile, "users_meta", false, AJXP_METADATA_SCOPE_GLOBAL); } // If copy or move, copy data. if ($newFile != null) { $this->metaStore->setMetadata($newFile, "users_meta", $oldMeta, false, AJXP_METADATA_SCOPE_GLOBAL); } }
/** * * @param AJXP_Node $oldFile * @param AJXP_Node $newFile * @param Boolean $copy */ public function updateMetaLocation($oldFile, $newFile = null, $copy = false) { if ($oldFile == null) { return; } if (!$copy && $this->metaStore->inherentMetaMove()) { return; } $oldMeta = $this->metaStore->retrieveMetadata($oldFile, self::$META_WATCH_NAMESPACE, false, AJXP_METADATA_SCOPE_REPOSITORY); if (count($oldMeta)) { // If it's a move or a delete, delete old data if (!$copy) { $this->metaStore->removeMetadata($oldFile, self::$META_WATCH_NAMESPACE, false, AJXP_METADATA_SCOPE_REPOSITORY); } // If copy or move, copy data. if ($newFile != null) { $this->metaStore->setMetadata($newFile, self::$META_WATCH_NAMESPACE, $oldMeta, false, AJXP_METADATA_SCOPE_REPOSITORY); } } }
/** * * Hooked to node.change, this will update the index * if $oldNode = null => create node $newNode * if $newNode = null => delete node $oldNode * Else copy or move oldNode to newNode. * * @param AJXP_Node $oldNode * @param AJXP_Node $newNode * @param Boolean $copy */ public function updateNodeSharedData($oldNode, $newNode = null, $copy = false) { if ($this->accessDriver->getId() == "access.imap") { return; } if ($this->metaStore == null) { return; } if ($oldNode == null) { return; } $metadata = $this->metaStore->retrieveMetadata($oldNode, "ajxp_shared", true); if (count($metadata)) { try { self::deleteSharedElement($oldNode->isLeaf() ? "file" : "repository", $metadata["element"], AuthService::getLoggedUser()); $this->metaStore->removeMetadata($oldNode, "ajxp_shared", true); } catch (Exception $e) { } } }