From 39784b7e20e4e8229328ee36a89943e65a40f0c9 Mon Sep 17 00:00:00 2001 From: cdujeu Date: Thu, 19 Jan 2017 10:23:07 +0100 Subject: [PATCH] Fix events forwarding for one-doc minisite (use ContentFilter instead of relative path re-compute). Zoho send a create event instead of a content event. --- .../plugins/action.share/src/ShareCenter.php | 14 ++++++++++---- core/src/plugins/editor.zoho/ZohoEditor.php | 19 ++++++++----------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/core/src/plugins/action.share/src/ShareCenter.php b/core/src/plugins/action.share/src/ShareCenter.php index 4fd7ee99b8..8734b9812f 100644 --- a/core/src/plugins/action.share/src/ShareCenter.php +++ b/core/src/plugins/action.share/src/ShareCenter.php @@ -1248,15 +1248,21 @@ private function findMirrorNodesInShares($node, $direction){ $parentRepoId = $node->getRepository()->getParentId(); $parentRepository = RepositoryService::getRepositoryById($parentRepoId); if(!empty($parentRepository) && !$parentRepository->isTemplate()){ - $currentRoot = $node->getRepository()->getContextOption($crtContext, "PATH"); $newContext = $crtContext->withRepositoryId($parentRepoId); $owner = $node->getRepository()->getOwner(); if($owner !== null){ $newContext = $newContext->withUserId($owner); } - $parentRoot = $parentRepository->getContextOption($newContext, "PATH"); - $relative = substr($currentRoot, strlen($parentRoot)); - $parentNodeURL = $newContext->getUrlBase().$relative.$node->getPath(); + if($node->getRepository()->hasContentFilter()){ + $cFilter = $node->getRepository()->getContentFilter(); + $parentNodePath = array_keys($cFilter->filters)[0]; + $parentNodeURL = $newContext->getUrlBase().$parentNodePath; + }else{ + $currentRoot = $node->getRepository()->getContextOption($crtContext, "PATH"); + $parentRoot = $parentRepository->getContextOption($newContext, "PATH"); + $relative = substr($currentRoot, strlen($parentRoot)); + $parentNodeURL = $newContext->getUrlBase().$relative.$node->getPath(); + } $this->logDebug("action.share", "Should trigger on ".$parentNodeURL); $parentNode = new AJXP_Node($parentNodeURL); $result[$parentRepoId] = array($parentNode, "UP"); diff --git a/core/src/plugins/editor.zoho/ZohoEditor.php b/core/src/plugins/editor.zoho/ZohoEditor.php index fa2b817555..4ac73de332 100644 --- a/core/src/plugins/editor.zoho/ZohoEditor.php +++ b/core/src/plugins/editor.zoho/ZohoEditor.php @@ -266,7 +266,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface Controller::applyHook("node.before_change", array(&$node)); $b64Sig = $this->signID($id); - + $nodeChanged = false; if ($this->getContextualOption($ctx, "USE_ZOHO_AGENT") ) { $url = $this->getContextualOption($ctx, "ZOHO_AGENT_URL")."?ajxp_action=get_file&name=".$id."&ext=".$ext."&signature=".$b64Sig ; @@ -274,23 +274,20 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface $data = FileHelper::getRemoteContent($url); if (strlen($data)) { file_put_contents($targetFile, $data); - - $stream->write("MODIFIED"); - - $this->logInfo('Edit', 'Retrieved content of '.$node->getUrl(), array("files" => $node->getUrl())); - Controller::applyHook("node.change", array(null, &$node)); + $nodeChanged = true; } } else { if (is_file(AJXP_INSTALL_PATH."/".AJXP_PLUGINS_FOLDER."/editor.zoho/agent/files/".$id.".".$ext)) { copy(AJXP_INSTALL_PATH."/".AJXP_PLUGINS_FOLDER."/editor.zoho/agent/files/".$id.".".$ext, $targetFile); unlink(AJXP_INSTALL_PATH."/".AJXP_PLUGINS_FOLDER."/editor.zoho/agent/files/".$id.".".$ext); - - $stream->write("MODIFIED"); - - $this->logInfo('Edit', 'Retrieved content of '.$node->getUrl(), array("files" => $node->getUrl())); - Controller::applyHook("node.change", array(null, &$node)); + $nodeChanged = true; } } + if($nodeChanged){ + $stream->write("MODIFIED"); + $this->logInfo('Edit', 'Retrieved content of '.$node->getUrl(), array("files" => $node->getUrl())); + Controller::applyHook("node.change", array(&$node, &$node)); + } } }