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

Commit

Permalink
Fix #370 (5.1.0 regression)
Browse files Browse the repository at this point in the history
Avoid checking MetaWatch on parent if node is already root
Avoid unnecessary DB calls to get repository by Id
  • Loading branch information
cdujeu committed Dec 13, 2013
1 parent 0ff0f6d commit 7d04154
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 41 deletions.
4 changes: 4 additions & 0 deletions core/src/core/classes/class.AJXP_Node.php
Expand Up @@ -306,6 +306,10 @@ public function getPath()
return $this->urlParts["path"];
}

public function isRoot(){
return !isset($this->urlParts["path"]) || $this->urlParts["path"] == "/";
}

/**
* @return string The scheme part of the url
*/
Expand Down
3 changes: 3 additions & 0 deletions core/src/core/classes/class.ConfService.php
Expand Up @@ -650,6 +650,9 @@ public function getRepositoryByIdInst($repoId)
if (isSet($this->configs["REPOSITORIES"]) && isSet($this->configs["REPOSITORIES"][$repoId])) {
return $this->configs["REPOSITORIES"][$repoId];
}
if (iSset($this->configs["REPOSITORY"]) && $this->configs["REPOSITORY"]->getId()."" == $repoId){
return $this->configs["REPOSITORY"];
}
return $this->getConfStorageImpl()->getRepositoryById($repoId);
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/action.share/class.ShareCenter.js
Expand Up @@ -474,7 +474,7 @@ Class.create("ShareCenter", {
return false;
},
null,
true);
'close');

},

Expand Down
36 changes: 30 additions & 6 deletions core/src/plugins/action.share/class.ShareCenter.php
Expand Up @@ -347,7 +347,18 @@ public function switchAction($action, $httpVars, $fileVars)
}
$repo = ConfService::getRepositoryById($repoId);
if ($repo == null || $repo->getOwner() != AuthService::getLoggedUser()->getId()) {
throw new Exception($messages["share_center.48"]);
//throw new Exception($messages["share_center.48"]);
$jsonData = array(
"repositoryId" => $repoId,
"label" => "Error - Cannot find shared data",
"description" => "Cannot find repository",
"entries" => array(),
"element_watch" => false,
"repository_url"=> ""
);
echo json_encode($jsonData);
break;

}
if ($this->watcher != false) {
$elementWatch = $this->watcher->hasWatchOnNode(
Expand Down Expand Up @@ -526,11 +537,21 @@ public function updateNodeSharedData($oldNode/*, $newNode = null, $copy = false*
// Maybe could be directly embedded in metadata, to avoid having to load here.
$oldNode->loadNodeInfo();
try {
self::deleteSharedElement(
($oldNode->isLeaf()?"file":"repository"),
$metadata["element"],
AuthService::getLoggedUser()
);
$type = $oldNode->isLeaf() ? "file":"repository";
$elementIds = array();
if($type == "file"){
if(!is_array($metadata["element"])) $elementIds[] = $metadata["element"];
else $elementIds = array_keys($metadata["element"]);
}else{
$elementIds[]= $metadata["element"];
}
foreach($elementIds as $elementId){
self::deleteSharedElement(
$type,
$elementId,
AuthService::getLoggedUser()
);
}
$oldNode->removeMetadata("ajxp_shared", true, AJXP_METADATA_SCOPE_REPOSITORY, true);
} catch (Exception $e) {
$this->logError("Exception", $e->getMessage(), $e->getTrace() );
Expand Down Expand Up @@ -1380,6 +1401,9 @@ public static function deleteSharedElement($type, $element, $loggedUser)
$minisiteData = self::loadPublicletData($element);
$repoId = $minisiteData["REPOSITORY"];
$repo = ConfService::getRepositoryById($repoId);
if($repo == null){
return false;
}
if (!$repo->hasOwner() || $repo->getOwner() != $loggedUser->getId()) {
throw new Exception($mess["ajxp_shared.12"]);
} else {
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/action.share/manifest.xml
Expand Up @@ -254,7 +254,7 @@
<input type="password" name="password" value="" placeholder="AJXP_MESSAGE[share_center.23]" autocomplete="off" class="SF_input" style="width:130px !important;">
<input type="text" name="expiration" value="0" placeholder="AJXP_MESSAGE[share_center.21]" class="SF_input SF_number" style="width:100px !important;">
<input type="text" name="downloadlimit" value="0" placeholder="AJXP_MESSAGE[share_center.22]" class="SF_input SF_number" style="width:100px !important;">
<div class="SF_horizontal_actions"><span id="generate_publiclet" class="SF_horizontal_action icon-plus-sign"></span></div>
<div class="SF_horizontal_actions"><span id="generate_publiclet" class="SF_horizontal_action icon-plus-sign dialogFocus"></span></div>
</div>
<div class="SF_element" id="public_pass_container" style="display:none;height:20px;"></div>
</div>
Expand Down
72 changes: 39 additions & 33 deletions core/src/plugins/meta.watch/class.MetaWatchRegister.php
Expand Up @@ -353,17 +353,19 @@ public function processChangeHook(AJXP_Node $oldNode=null, AJXP_Node $newNode=nu
if (count($ids)) {
foreach($ids as $id) $this->notificationCenter->postNotification($newNotif, $id);
}
$parentNode = new AJXP_Node(dirname($newNode->getUrl()));
$parentNode->setLeaf(false);
$ids = $this->getWatchesOnNode($parentNode, self::$META_WATCH_CHANGE);
if (count($ids)) {
// POST NOW : PARENT FOLDER IS AFFECTED
$parentNotif = new AJXP_Notification();
$parentNotif->setNode($parentNode);
$parentNotif->setAction(AJXP_NOTIF_NODE_CHANGE);
$this->notificationCenter->prepareNotification($newNotif);
$parentNotif->addRelatedNotification($newNotif);
foreach($ids as $id) $this->notificationCenter->postNotification($parentNotif, $id);
if(!$newNode->isRoot()){
$parentNode = new AJXP_Node(dirname($newNode->getUrl()));
$parentNode->setLeaf(false);
$ids = $this->getWatchesOnNode($parentNode, self::$META_WATCH_CHANGE);
if (count($ids)) {
// POST NOW : PARENT FOLDER IS AFFECTED
$parentNotif = new AJXP_Notification();
$parentNotif->setNode($parentNode);
$parentNotif->setAction(AJXP_NOTIF_NODE_CHANGE);
$this->notificationCenter->prepareNotification($newNotif);
$parentNotif->addRelatedNotification($newNotif);
foreach($ids as $id) $this->notificationCenter->postNotification($parentNotif, $id);
}
}
}
if($oldNode != null && $newNode != null && $oldNode->getUrl() == $newNode->getUrl()) return;
Expand All @@ -373,17 +375,19 @@ public function processChangeHook(AJXP_Node $oldNode=null, AJXP_Node $newNode=nu
if (count($ids)) {
foreach($ids as $id) $this->notificationCenter->postNotification($oldNotif, $id);
}
$parentNode = new AJXP_Node(dirname($oldNode->getUrl()));
$parentNode->setLeaf(false);
$ids = $this->getWatchesOnNode($parentNode, self::$META_WATCH_CHANGE);
if (count($ids)) {
// POST NOW : PARENT FOLDER IS AFFECTED
$parentNotif = new AJXP_Notification();
$parentNotif->setNode($parentNode);
$parentNotif->setAction(AJXP_NOTIF_NODE_CHANGE);
$this->notificationCenter->prepareNotification($oldNotif);
$parentNotif->addRelatedNotification($oldNotif);
foreach($ids as $id) $this->notificationCenter->postNotification($parentNotif, $id);
if(!$oldNode->isRoot()){
$parentNode = new AJXP_Node(dirname($oldNode->getUrl()));
$parentNode->setLeaf(false);
$ids = $this->getWatchesOnNode($parentNode, self::$META_WATCH_CHANGE);
if (count($ids)) {
// POST NOW : PARENT FOLDER IS AFFECTED
$parentNotif = new AJXP_Notification();
$parentNotif->setNode($parentNode);
$parentNotif->setAction(AJXP_NOTIF_NODE_CHANGE);
$this->notificationCenter->prepareNotification($oldNotif);
$parentNotif->addRelatedNotification($oldNotif);
foreach($ids as $id) $this->notificationCenter->postNotification($parentNotif, $id);
}
}
}

Expand All @@ -400,17 +404,19 @@ public function processReadHook(AJXP_Node $node)
if (count($ids)) {
foreach($ids as $id) $this->notificationCenter->postNotification($notif, $id);
}
$parentNode = new AJXP_Node(dirname($node->getUrl()));
$parentNode->setLeaf(false);
$ids = $this->getWatchesOnNode($parentNode, self::$META_WATCH_READ);
if (count($ids)) {
// POST NOW : PARENT FOLDER IS AFFECTED
$parentNotif = new AJXP_Notification();
$parentNotif->setNode($parentNode);
$parentNotif->setAction(AJXP_NOTIF_NODE_VIEW);
$this->notificationCenter->prepareNotification($notif);
$parentNotif->addRelatedNotification($notif);
foreach($ids as $id) $this->notificationCenter->postNotification($parentNotif, $id);
if(!$node->isRoot()){
$parentNode = new AJXP_Node(dirname($node->getUrl()));
$parentNode->setLeaf(false);
$ids = $this->getWatchesOnNode($parentNode, self::$META_WATCH_READ);
if (count($ids)) {
// POST NOW : PARENT FOLDER IS AFFECTED
$parentNotif = new AJXP_Notification();
$parentNotif->setNode($parentNode);
$parentNotif->setAction(AJXP_NOTIF_NODE_VIEW);
$this->notificationCenter->prepareNotification($notif);
$parentNotif->addRelatedNotification($notif);
foreach($ids as $id) $this->notificationCenter->postNotification($parentNotif, $id);
}
}

}
Expand Down

0 comments on commit 7d04154

Please sign in to comment.