/** * * @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 AJXP_Node $node */ public function checkFileLock($node) { AJXP_Logger::debug("SHOULD CHECK LOCK METADATA FOR ", $node->getLabel()); $lock = $this->metaStore->retrieveMetadata($node, SimpleLockManager::METADATA_LOCK_NAMESPACE, false, AJXP_METADATA_SCOPE_GLOBAL); if (is_array($lock) && array_key_exists("lock_user", $lock) && $lock["lock_user"] != AuthService::getLoggedUser()->getId()) { $mess = ConfService::getMessages(); throw new Exception($mess["meta.simple_lock.5"]); } }
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 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); } } }
function createSharedRepository($httpVars, $repository, $accessDriver) { // ERRORS // 100 : missing args // 101 : repository label already exists // 102 : user already exists // 103 : current user is not allowed to share // SUCCESS // 200 if (!isset($httpVars["repo_label"]) || $httpVars["repo_label"] == "" || !isset($httpVars["repo_rights"]) || $httpVars["repo_rights"] == "") { return 100; } $loggedUser = AuthService::getLoggedUser(); $actRights = $loggedUser->getSpecificActionsRights($repository->id); if (isset($actRights["share"]) && $actRights["share"] === false) { return 103; } $users = array(); if (isset($httpVars["shared_user"]) && !empty($httpVars["shared_user"])) { $users = array_filter(array_map("trim", explode(",", str_replace("\n", ",", $httpVars["shared_user"]))), array("AuthService", "userExists")); } if (isset($httpVars["new_shared_user"]) && !empty($httpVars["new_shared_user"])) { $newshareduser = AJXP_Utils::decodeSecureMagic($httpVars["new_shared_user"], AJXP_SANITIZE_ALPHANUM); if (!empty($this->pluginConf["SHARED_USERS_TMP_PREFIX"]) && strpos($newshareduser, $this->pluginConf["SHARED_USERS_TMP_PREFIX"]) !== 0) { $newshareduser = $this->pluginConf["SHARED_USERS_TMP_PREFIX"] . $newshareduser; } if (!AuthService::userExists($newshareduser)) { array_push($users, $newshareduser); } else { throw new Exception("User already exists, please choose another name."); } } //$userName = AJXP_Utils::decodeSecureMagic($httpVars["shared_user"], AJXP_SANITIZE_ALPHANUM); $label = AJXP_Utils::decodeSecureMagic($httpVars["repo_label"]); $rights = $httpVars["repo_rights"]; if ($rights != "r" && $rights != "w" && $rights != "rw") { return 100; } if (isset($httpVars["repository_id"])) { $editingRepo = ConfService::getRepositoryById($httpVars["repository_id"]); } // CHECK USER & REPO DOES NOT ALREADY EXISTS $repos = ConfService::getRepositoriesList(); foreach ($repos as $obj) { if ($obj->getDisplay() == $label && (!isset($editingRepo) || $editingRepo != $obj)) { return 101; } } $confDriver = ConfService::getConfStorageImpl(); foreach ($users as $userName) { if (AuthService::userExists($userName)) { // check that it's a child user $userObject = $confDriver->createUserObject($userName); if (ConfService::getCoreConf("ALLOW_CROSSUSERS_SHARING") != true && (!$userObject->hasParent() || $userObject->getParent() != $loggedUser->id)) { return 102; } } else { if (AuthService::isReservedUserId($userName)) { return 102; } if (!isset($httpVars["shared_pass"]) || $httpVars["shared_pass"] == "") { return 100; } } } // CREATE SHARED OPTIONS $options = $accessDriver->makeSharedRepositoryOptions($httpVars, $repository); $customData = array(); foreach ($httpVars as $key => $value) { if (substr($key, 0, strlen("PLUGINS_DATA_")) == "PLUGINS_DATA_") { $customData[substr($key, strlen("PLUGINS_DATA_"))] = $value; } } if (count($customData)) { $options["PLUGINS_DATA"] = $customData; } if (isset($editingRepo)) { $newRepo = $editingRepo; $newRepo->setDisplay($label); $newRepo->options = array_merge($newRepo->options, $options); ConfService::replaceRepository($httpVars["repository_id"], $newRepo); } else { if ($repository->getOption("META_SOURCES")) { $options["META_SOURCES"] = $repository->getOption("META_SOURCES"); foreach ($options["META_SOURCES"] as $index => $data) { if (isset($data["USE_SESSION_CREDENTIALS"]) && $data["USE_SESSION_CREDENTIALS"] === true) { $options["META_SOURCES"][$index]["ENCODED_CREDENTIALS"] = AJXP_Safe::getEncodedCredentialString(); } } } $newRepo = $repository->createSharedChild($label, $options, $repository->id, $loggedUser->id, null); ConfService::addRepository($newRepo); } if (isset($httpVars["original_users"])) { $originalUsers = explode(",", $httpVars["original_users"]); $removeUsers = array_diff($originalUsers, $users); if (count($removeUsers)) { foreach ($removeUsers as $user) { if (AuthService::userExists($user)) { $userObject = $confDriver->createUserObject($user); $userObject->removeRights($newRepo->getUniqueId()); $userObject->save("superuser"); } } } } foreach ($users as $userName) { if (AuthService::userExists($userName)) { // check that it's a child user $userObject = $confDriver->createUserObject($userName); } else { if (ConfService::getAuthDriverImpl()->getOption("TRANSMIT_CLEAR_PASS")) { $pass = $httpVars["shared_pass"]; } else { $pass = md5($httpVars["shared_pass"]); } AuthService::createUser($userName, $pass); $userObject = $confDriver->createUserObject($userName); $userObject->clearRights(); $userObject->setParent($loggedUser->id); } // CREATE USER WITH NEW REPO RIGHTS $userObject->setRight($newRepo->getUniqueId(), $rights); $userObject->setSpecificActionRight($newRepo->getUniqueId(), "share", false); $userObject->save("superuser"); } // METADATA if (!isset($editingRepo) && $this->metaStore != null) { $file = AJXP_Utils::decodeSecureMagic($httpVars["file"]); $this->metaStore->setMetadata(new AJXP_Node($this->urlBase . $file), "ajxp_shared", array("element" => $newRepo->getUniqueId()), true, AJXP_METADATA_SCOPE_REPOSITORY); } return 200; }