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

Commit

Permalink
Fix clearing shares
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Feb 26, 2016
1 parent 64b1871 commit 164d3a3
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions core/src/plugins/action.share/class.ShareCenter.php
Expand Up @@ -671,29 +671,29 @@ public function switchAction($action, $httpVars, $fileVars)
$ajxpNode = $userSelection->getUniqueNode();
$shares = array();
$this->getShareStore()->getMetaManager()->getSharesFromMeta($ajxpNode, $shares, false);
if(count($shares)){
if(isSet($httpVars["element_id"]) && isSet($shares[$httpVars["element_id"]])){
$elementId = $httpVars["element_id"];
}else{
$sKeys = array_keys($shares);
$elementId = $sKeys[0];
}
if(isSet($shares[$elementId]) && isSet($shares[$elementId]["type"])){
$t = $shares[$elementId]["type"];
}else{
$t = "file";
if(isSet($httpVars["element_id"]) && isSet($shares[$httpVars["element_id"]])){
$elementId = $httpVars["element_id"];
if(isSet($shares[$elementId])){
$shares = array($elementId => $shares[$elementId]);
}
try{
$result = $this->getShareStore()->deleteShare($t, $elementId);
}catch(Exception $e){
if($e->getMessage() == "repo-not-found"){
$result = true;
}else{
throw $e;
}
if(count($shares)){
$res = true;
foreach($shares as $shareId => $share){
$t = isSet($share["type"]) ? $share["type"] : "file";
try{
$result = $this->getShareStore()->deleteShare($t, $shareId);
}catch(Exception $e){
if($e->getMessage() == "repo-not-found"){
$result = true;
}else{
throw $e;
}
}
$this->getShareStore()->getMetaManager()->removeShareFromMeta($ajxpNode, $shareId);
$res = $result && $res;
}
if($result !== false){
$this->getShareStore()->getMetaManager()->removeShareFromMeta($ajxpNode, $elementId);
if($res !== false){
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage("Successfully unshared element", null);
AJXP_XMLWriter::close();
Expand Down Expand Up @@ -1434,7 +1434,6 @@ protected function shareObjectFromParameters($linkData, &$hiddenUserEntries, &$s
public function shareNode($httpVars, &$update){

$hiddenUserEntries = array();
$downloadDisabled = false;
$originalHttpVars = $httpVars;
$ocsStore = new Pydio\OCS\Model\SQLStore();
$ocsClient = new Pydio\OCS\Client\OCSClient();
Expand Down Expand Up @@ -1479,6 +1478,7 @@ public function shareNode($httpVars, &$update){
}
if(!count($users) && !count($groups)){
ob_start();
unset($originalHttpVars["hash"]);
$this->switchAction("unshare", $originalHttpVars, array());
ob_end_clean();
return null;
Expand Down

0 comments on commit 164d3a3

Please sign in to comment.