/** * * @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"]); } }
/** * * @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) { } } }
/** * @param AJXP_Node $node */ public function getFileHash($node) { if ($node->isLeaf()) { $md5 = null; if ($this->metaStore != false) { $hashMeta = $this->metaStore->retrieveMetadata($node, FileHasher::METADATA_HASH_NAMESPACE, false, AJXP_METADATA_SCOPE_GLOBAL); $mtime = filemtime($node->getUrl()); if (is_array($hashMeta) && array_key_exists("md5", $hashMeta) && array_key_exists("md5_mtime", $hashMeta) && $hashMeta["md5_mtime"] >= $mtime) { $md5 = $hashMeta["md5"]; } if ($md5 == null) { $md5 = md5_file($node->getUrl()); $hashMeta = array("md5" => $md5, "md5_mtime" => $mtime); $this->metaStore->setMetadata($node, FileHasher::METADATA_HASH_NAMESPACE, $hashMeta, false, AJXP_METADATA_SCOPE_GLOBAL); } } else { $md5 = md5_file($node->getUrl()); } $node->mergeMetadata(array("md5" => $md5)); } }