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

Commit

Permalink
Catch nodes deletion (real or recycle_bin) and delete share. Display …
Browse files Browse the repository at this point in the history
…a message to the user.
  • Loading branch information
cdujeu committed Jul 25, 2014
1 parent 3474e9b commit b829e90
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/src/plugins/access.ajxp_home/home.css
Expand Up @@ -194,7 +194,7 @@ div.legend_visible div#logo_div{
text-align: left;
padding: 32px 0;
margin: 0 30px;
border-bottom: 1px solid #555;
border-bottom: 1px solid #ddd;
font-size: 1.3em;
font-weight: normal;
}
Expand Down
33 changes: 28 additions & 5 deletions core/src/plugins/action.share/class.ShareCenter.js
Expand Up @@ -25,6 +25,29 @@ Class.create("ShareCenter", {
_currentFolderWatchValue:false,
_dataModel:null,

initialize: function(){
document.observe("ajaxplorer:afterApply-delete", function(){
try{
var u = ajaxplorer.getContextHolder().getUniqueNode();
if(u.getMetadata().get("ajxp_shared")){
var leaf = u.isLeaf();
var f = $("generic_dialog_box").down("#delete_message");
if(!f.down("#share_delete_alert")){
var message;
if(u.isLeaf()){
message = MessageHash["share_center.158"];
}else{
message = MessageHash["share_center.157"];
}
f.insert("<div id='share_delete_alert' style='padding-top: 10px;color: rgb(192, 0, 0);'><span style='float: left;display: block;height: 60px;margin: 4px 7px 4px 0;font-size: 2.4em;' class='icon-warning-sign'></span>"+message+"</div>");
}
}
}catch(e){
if(console) console.log(e);
}
});
},

performShareAction : function(dataModel){
var userSelection;
if(dataModel){
Expand All @@ -35,11 +58,7 @@ Class.create("ShareCenter", {
}
this.currentNode = userSelection.getUniqueNode();
this.shareFolderMode = "workspace";
if(this.currentNode.getMetadata().get('share_data')) {
this.readonlyMode = true;
}else{
this.readonlyMode = false;
}
this.readonlyMode = this.currentNode.getMetadata().get('share_data') ? true : false;
if(( userSelection.hasDir() && !userSelection.hasMime($A(['ajxp_browsable_archive'])))
|| userSelection.isMultiple()
|| (this.currentNode.getMetadata().get('share_data') && !this.currentNode.getMetadata().get('share_link'))
Expand Down Expand Up @@ -1146,3 +1165,7 @@ Class.create("ShareCenter", {
}

});

if(ajaxplorer && ajaxplorer.actionBar){
ajaxplorer.actionBar.shareCenter = new ShareCenter();
}
13 changes: 12 additions & 1 deletion core/src/plugins/action.share/class.ShareCenter.php
Expand Up @@ -710,6 +710,17 @@ public function updateNodeSharedData($oldNode=null, $newNode=null, $copy = false
if($oldNode != null && !$copy){
$this->logDebug("Should update node");

$delete = false;
if($newNode == null) {
$delete = true;
}else{
$repo = $newNode->getRepository();
$recycle = $repo->getOption("RECYCLE_BIN");
if(!empty($recycle) && strpos($newNode->getPath(), $recycle) === 1){
$delete = true;
}
}

$this->getSharesFromMeta($oldNode, $shares, true);
if(empty($shares)) {
return;
Expand All @@ -718,7 +729,7 @@ public function updateNodeSharedData($oldNode=null, $newNode=null, $copy = false
$newShares = array();
foreach($shares as $id => $data){
$type = $data["type"];
if($newNode == null){
if($delete){
$this->getShareStore()->deleteShare($type, $id);
continue;
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/plugins/action.share/res/i18n/ca.php
Expand Up @@ -165,4 +165,6 @@
"156" => "Successfully published link %s",
"46_mini" => "Open mini %s1",
"46_file" => "Open file %s1",
"157" => "This folder is currently shared. If you delete it, associated share will be disabled.",
"158" => "This file is currently shared. If you delete it, associated share will be disabled. "
);
2 changes: 2 additions & 0 deletions core/src/plugins/action.share/res/i18n/de.php
Expand Up @@ -164,4 +164,6 @@
"156" => "Successfully published link %s",
"46_mini" => "Open mini %s1",
"46_file" => "Open file %s1",
"157" => "This folder is currently shared. If you delete it, associated share will be disabled.",
"158" => "This file is currently shared. If you delete it, associated share will be disabled. "
);
2 changes: 2 additions & 0 deletions core/src/plugins/action.share/res/i18n/en.php
Expand Up @@ -166,4 +166,6 @@
"154" => "Film Strip (good for image galleries)",
"155" => "Embedded (smaller header, for widgets)",
"156" => "Successfully published link %s",
"157" => "This folder is currently shared. If you delete it, associated share will be disabled.",
"158" => "This file is currently shared. If you delete it, associated share will be disabled. "
);
2 changes: 2 additions & 0 deletions core/src/plugins/action.share/res/i18n/es.php
Expand Up @@ -165,4 +165,6 @@
"156" => "Successfully published link %s",
"46_mini" => "Open mini %s1",
"46_file" => "Open file %s1",
"157" => "This folder is currently shared. If you delete it, associated share will be disabled.",
"158" => "This file is currently shared. If you delete it, associated share will be disabled. "
);
2 changes: 2 additions & 0 deletions core/src/plugins/action.share/res/i18n/fr.php
Expand Up @@ -165,5 +165,7 @@
"154" => "Pellicule (pour galleries de photos)",
"155" => "Minimal (header plus petit, pour un widget)",
"156" => "Le lien %s a été publié",
"157" => "Le répertoire est actuallement partagé. Si vous le supprimez, le partage sera désactivé.",
"158" => "Le fichier est actuallement partagé. Si vous le supprimez, le partage sera désactivé."
// will be replaced by the filename to download
);
2 changes: 2 additions & 0 deletions core/src/plugins/action.share/res/i18n/pt.php
Expand Up @@ -165,5 +165,7 @@
"156" => "Successfully published link %s",
"46_mini" => "Open mini %s1",
"46_file" => "Open file %s1",
"157" => "This folder is currently shared. If you delete it, associated share will be disabled.",
"158" => "This file is currently shared. If you delete it, associated share will be disabled. "
// will be replaced by the filename to download
);
6 changes: 4 additions & 2 deletions core/src/plugins/auth.multi/class.multiAuthDriver.php
Expand Up @@ -128,8 +128,10 @@ protected function parseSpecificContributions(&$contribNode)
$xmlContent = str_replace("AJXP_MULTIAUTH_SOURCES", json_encode($sources), $xmlContent);
$xmlContent = str_replace("AJXP_MULTIAUTH_MASTER", $this->getOption("MASTER_DRIVER"), $xmlContent);
$xmlContent = str_replace("AJXP_USER_ID_SEPARATOR", $this->getOption("USER_ID_SEPARATOR"), $xmlContent);
$callbackNode->removeChild($callbackNode->firstChild);
$callbackNode->appendChild($contribNode->ownerDocument->createCDATASection($xmlContent));
if($callbackNode) {
$callbackNode->removeChild($callbackNode->firstChild);
$callbackNode->appendChild($contribNode->ownerDocument->createCDATASection($xmlContent));
}

}
}
Expand Down

0 comments on commit b829e90

Please sign in to comment.