mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Support for unshare from self, with a bunch of temporary fixes to overcome configuration problems with file actions
This commit is contained in:
parent
17dadd5c8a
commit
73d726d1b2
6 changed files with 36 additions and 8 deletions
|
|
@ -103,7 +103,12 @@ var FileActions={
|
|||
if(img.call){
|
||||
img=img(file);
|
||||
}
|
||||
var html='<a href="#" original-title="' + t('files', 'Delete') + '" class="action delete" style="display:none" />';
|
||||
// NOTE: Temporary fix to allow unsharing of files in root of Shared folder
|
||||
if ($('#dir').val() == '/Shared') {
|
||||
var html = '<a href="#" original-title="' + t('files', 'Unshare') + '" class="action delete" style="display:none" />';
|
||||
} else {
|
||||
var html='<a href="#" original-title="' + t('files', 'Delete') + '" class="action delete" style="display:none" />';
|
||||
}
|
||||
var element=$(html);
|
||||
if(img){
|
||||
element.append($('<img src="'+img+'"/>'));
|
||||
|
|
|
|||
|
|
@ -263,7 +263,12 @@ var FileList={
|
|||
return;
|
||||
}
|
||||
FileList.prepareDeletion(files);
|
||||
$('#notification').html(t('files', 'deleted')+' '+files+'<span class="undo">'+t('files', 'undo')+'</span>');
|
||||
// NOTE: Temporary fix to change the text to unshared for files in root of Shared folder
|
||||
if ($('#dir').val() == '/Shared') {
|
||||
$('#notification').html(t('files', 'unshared')+' '+files+'<span class="undo">'+t('files', 'undo')+'</span>');
|
||||
} else {
|
||||
$('#notification').html(t('files', 'deleted')+' '+files+'<span class="undo">'+t('files', 'undo')+'</span>');
|
||||
}
|
||||
$('#notification').fadeIn();
|
||||
},
|
||||
finishDelete:function(ready,sync){
|
||||
|
|
|
|||
|
|
@ -57,7 +57,12 @@
|
|||
<th id="headerDate">
|
||||
<span id="modified"><?php echo $l->t( 'Modified' ); ?></span>
|
||||
<?php if ($_['permissions'] & OCP\Share::PERMISSION_DELETE): ?>
|
||||
<span class="selectedActions"><a href="" class="delete"><?php echo $l->t('Delete')?> <img class="svg" alt="<?php echo $l->t('Delete')?>" src="<?php echo OCP\image_path("core", "actions/delete.svg"); ?>" /></a></span>
|
||||
<!-- NOTE: Temporary fix to allow unsharing of files in root of Shared folder -->
|
||||
<?php if ($_['dir'] == '/Shared'): ?>
|
||||
<span class="selectedActions"><a href="" class="delete"><?php echo $l->t('Unshare')?> <img class="svg" alt="<?php echo $l->t('Unshare')?>" src="<?php echo OCP\image_path("core", "actions/delete.svg"); ?>" /></a></span>
|
||||
<?php else: ?>
|
||||
<span class="selectedActions"><a href="" class="delete"><?php echo $l->t('Delete')?> <img class="svg" alt="<?php echo $l->t('Delete')?>" src="<?php echo OCP\image_path("core", "actions/delete.svg"); ?>" /></a></span>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -91,6 +91,8 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
|
|||
// Remove Create permission if type is file
|
||||
$file['permissions'] &= ~OCP\Share::PERMISSION_CREATE;
|
||||
}
|
||||
// NOTE: Temporary fix to allow unsharing of files in root of Shared directory
|
||||
$file['permissions'] |= OCP\Share::PERMISSION_DELETE;
|
||||
$files[] = $file;
|
||||
}
|
||||
return $files;
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
|
|||
|
||||
public function isDeletable($path) {
|
||||
if ($path == '') {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return ($this->getPermissions($path) & OCP\Share::PERMISSION_DELETE);
|
||||
}
|
||||
|
|
@ -306,9 +306,19 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
|
|||
|
||||
public function unlink($path) {
|
||||
// Delete the file if DELETE permission is granted
|
||||
if (($source = $this->getSourcePath($path)) && $this->isDeletable($path)) {
|
||||
$storage = OC_Filesystem::getStorage($source);
|
||||
return $storage->unlink($this->getInternalPath($source));
|
||||
if ($source = $this->getSourcePath($path)) {
|
||||
if ($this->isDeletable($path)) {
|
||||
$storage = OC_Filesystem::getStorage($source);
|
||||
return $storage->unlink($this->getInternalPath($source));
|
||||
} else if (dirname($path) == '/' || dirname($path) == '.') {
|
||||
// Unshare the file from the user if in the root of the Shared folder
|
||||
if ($this->is_dir($path)) {
|
||||
$itemType = 'folder';
|
||||
} else {
|
||||
$itemType = 'file';
|
||||
}
|
||||
return OCP\Share::unshareFromSelf($itemType, $path);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -340,7 +340,7 @@ class Share {
|
|||
// TODO
|
||||
}
|
||||
// Delete
|
||||
return self::delete($item['id'], true);
|
||||
return self::delete($item['id']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -564,6 +564,7 @@ class Share {
|
|||
} else {
|
||||
if ($itemType == 'file' || $itemType == 'folder') {
|
||||
$where .= ' `file_target` = ?';
|
||||
$item = \OC_Filesystem::normalizePath($item);
|
||||
} else {
|
||||
$where .= ' `item_target` = ?';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue