Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix events forwarding for one-doc minisite (use ContentFilter instead…
Browse files Browse the repository at this point in the history
… of relative path re-compute).

Zoho send a create event instead of a content event.
  • Loading branch information
cdujeu committed Jan 19, 2017
1 parent 6c74f3a commit 39784b7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
14 changes: 10 additions & 4 deletions core/src/plugins/action.share/src/ShareCenter.php
Expand Up @@ -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");
Expand Down
19 changes: 8 additions & 11 deletions core/src/plugins/editor.zoho/ZohoEditor.php
Expand Up @@ -266,31 +266,28 @@ 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 ;

$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));
}
}
}

Expand Down

0 comments on commit 39784b7

Please sign in to comment.