Merge pull request #1773 from owncloud/trash_bin_delete_selected
Trash bin delete selected
This commit is contained in:
commit
eb3769e6d6
|
@ -3,24 +3,43 @@
|
||||||
OCP\JSON::checkLoggedIn();
|
OCP\JSON::checkLoggedIn();
|
||||||
OCP\JSON::callCheck();
|
OCP\JSON::callCheck();
|
||||||
|
|
||||||
$file = $_REQUEST['file'];
|
$files = $_POST['files'];
|
||||||
|
$dirlisting = $_POST['dirlisting'];
|
||||||
|
$list = json_decode($files);
|
||||||
|
|
||||||
$path_parts = pathinfo($file);
|
$error = array();
|
||||||
if ($path_parts['dirname'] == '.') {
|
$success = array();
|
||||||
$delimiter = strrpos($file, '.d');
|
|
||||||
$filename = substr($file, 0, $delimiter);
|
$i = 0;
|
||||||
$timestamp = substr($file, $delimiter+2);
|
foreach ($list as $file) {
|
||||||
} else {
|
if ( $dirlisting=='0') {
|
||||||
$filename = $file;
|
$delimiter = strrpos($file, '.d');
|
||||||
$timestamp = null;
|
$filename = substr($file, 0, $delimiter);
|
||||||
|
$timestamp = substr($file, $delimiter+2);
|
||||||
|
} else {
|
||||||
|
$filename = $file;
|
||||||
|
$timestamp = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp);
|
||||||
|
if (!OCA\Files_Trashbin\Trashbin::file_exists($filename, $timestamp)) {
|
||||||
|
$success[$i]['filename'] = $file;
|
||||||
|
$success[$i]['timestamp'] = $timestamp;
|
||||||
|
$i++;
|
||||||
|
} else {
|
||||||
|
$error[] = $filename;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp);
|
if ( $error ) {
|
||||||
|
$filelist = '';
|
||||||
if (!OCA\Files_Trashbin\Trashbin::file_exists($filename)) {
|
foreach ( $error as $e ) {
|
||||||
OCP\JSON::success(array("data" => array("filename" => $file)));
|
$filelist .= $e.', ';
|
||||||
} else {
|
}
|
||||||
$l = OC_L10N::get('files_trashbin');
|
$l = OC_L10N::get('files_trashbin');
|
||||||
OCP\JSON::error(array("data" => array("message" => $l->t("Couldn't delete %s permanently", array($file)))));
|
$message = $l->t("Couldn't delete %s permanently", array(rtrim($filelist, ', ')));
|
||||||
|
OCP\JSON::error(array("data" => array("message" => $message,
|
||||||
|
"success" => $success, "error" => $error)));
|
||||||
|
} else {
|
||||||
|
OCP\JSON::success(array("data" => array("success" => $success)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
OCP\JSON::checkLoggedIn();
|
OCP\JSON::checkLoggedIn();
|
||||||
OCP\JSON::callCheck();
|
OCP\JSON::callCheck();
|
||||||
|
|
||||||
$files = $_REQUEST['files'];
|
$files = $_POST['files'];
|
||||||
$dirlisting = $_REQUEST['dirlisting'];
|
$dirlisting = $_POST['dirlisting'];
|
||||||
$list = explode(';', $files);
|
$list = json_decode($files);
|
||||||
|
|
||||||
$error = array();
|
$error = array();
|
||||||
$success = array();
|
$success = array();
|
||||||
|
|
|
@ -16,6 +16,7 @@ OCP\Util::addScript('files', 'filelist');
|
||||||
|
|
||||||
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
|
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
|
||||||
|
|
||||||
|
$result = array();
|
||||||
if ($dir) {
|
if ($dir) {
|
||||||
$dirlisting = true;
|
$dirlisting = true;
|
||||||
$view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_trashbin');
|
$view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_trashbin');
|
||||||
|
@ -37,7 +38,7 @@ if ($dir) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir($fullpath);
|
closedir($dirContent);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$dirlisting = false;
|
$dirlisting = false;
|
||||||
|
|
|
@ -6,9 +6,10 @@ $(document).ready(function() {
|
||||||
var tr=$('tr').filterAttr('data-file', filename);
|
var tr=$('tr').filterAttr('data-file', filename);
|
||||||
var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'perform restore operation')+'" src="'+ OC.imagePath('core', 'loader.gif') +'"></a>';
|
var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'perform restore operation')+'" src="'+ OC.imagePath('core', 'loader.gif') +'"></a>';
|
||||||
var undeleteAction = $('tr').filterAttr('data-file',filename).children("td.date");
|
var undeleteAction = $('tr').filterAttr('data-file',filename).children("td.date");
|
||||||
|
var files = tr.attr('data-file');
|
||||||
undeleteAction[0].innerHTML = undeleteAction[0].innerHTML+spinner;
|
undeleteAction[0].innerHTML = undeleteAction[0].innerHTML+spinner;
|
||||||
$.post(OC.filePath('files_trashbin','ajax','undelete.php'),
|
$.post(OC.filePath('files_trashbin','ajax','undelete.php'),
|
||||||
{files:tr.attr('data-file'), dirlisting:tr.attr('data-dirlisting') },
|
{files:JSON.stringify([files]), dirlisting:tr.attr('data-dirlisting') },
|
||||||
function(result){
|
function(result){
|
||||||
for (var i = 0; i < result.data.success.length; i++) {
|
for (var i = 0; i < result.data.success.length; i++) {
|
||||||
var row = document.getElementById(result.data.success[i].filename);
|
var row = document.getElementById(result.data.success[i].filename);
|
||||||
|
@ -31,16 +32,17 @@ $(document).ready(function() {
|
||||||
var deleteAction = $('tr').filterAttr('data-file',filename).children("td.date").children(".action.delete");
|
var deleteAction = $('tr').filterAttr('data-file',filename).children("td.date").children(".action.delete");
|
||||||
var oldHTML = deleteAction[0].outerHTML;
|
var oldHTML = deleteAction[0].outerHTML;
|
||||||
var newHTML = '<img class="move2trash" data-action="Delete" title="'+t('files', 'delete file permanently')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>';
|
var newHTML = '<img class="move2trash" data-action="Delete" title="'+t('files', 'delete file permanently')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>';
|
||||||
|
var files = tr.attr('data-file');
|
||||||
deleteAction[0].outerHTML = newHTML;
|
deleteAction[0].outerHTML = newHTML;
|
||||||
|
|
||||||
$.post(OC.filePath('files_trashbin','ajax','delete.php'),
|
$.post(OC.filePath('files_trashbin','ajax','delete.php'),
|
||||||
{file:tr.attr('data-file') },
|
{files:JSON.stringify([files]), dirlisting:tr.attr('data-dirlisting') },
|
||||||
function(result){
|
function(result){
|
||||||
if ( result.status == 'success' ) {
|
for (var i = 0; i < result.data.success.length; i++) {
|
||||||
var row = document.getElementById(result.data.filename);
|
var row = document.getElementById(result.data.success[i].filename);
|
||||||
row.parentNode.removeChild(row);
|
row.parentNode.removeChild(row);
|
||||||
} else {
|
}
|
||||||
deleteAction[0].outerHTML = oldHTML;
|
if (result.status != 'success') {
|
||||||
OC.dialogs.alert(result.data.message, 'Error');
|
OC.dialogs.alert(result.data.message, 'Error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -93,7 +95,7 @@ $(document).ready(function() {
|
||||||
$('.undelete').click('click',function(event) {
|
$('.undelete').click('click',function(event) {
|
||||||
var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'perform restore operation')+'" src="'+ OC.imagePath('core', 'loader.gif') +'"></a>';
|
var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'perform restore operation')+'" src="'+ OC.imagePath('core', 'loader.gif') +'"></a>';
|
||||||
var files=getSelectedFiles('file');
|
var files=getSelectedFiles('file');
|
||||||
var fileslist=files.join(';');
|
var fileslist = JSON.stringify(files);
|
||||||
var dirlisting=getSelectedFiles('dirlisting')[0];
|
var dirlisting=getSelectedFiles('dirlisting')[0];
|
||||||
|
|
||||||
for (var i=0; i<files.length; i++) {
|
for (var i=0; i<files.length; i++) {
|
||||||
|
@ -113,7 +115,31 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('.delete').click('click',function(event) {
|
||||||
|
console.log("delete selected");
|
||||||
|
var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'Delete permanently')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>';
|
||||||
|
var files=getSelectedFiles('file');
|
||||||
|
var fileslist = JSON.stringify(files);
|
||||||
|
var dirlisting=getSelectedFiles('dirlisting')[0];
|
||||||
|
|
||||||
|
for (var i=0; i<files.length; i++) {
|
||||||
|
var deleteAction = $('tr').filterAttr('data-file',files[i]).children("td.date");
|
||||||
|
deleteAction[0].innerHTML = deleteAction[0].innerHTML+spinner;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.post(OC.filePath('files_trashbin','ajax','delete.php'),
|
||||||
|
{files:fileslist, dirlisting:dirlisting},
|
||||||
|
function(result){
|
||||||
|
for (var i = 0; i < result.data.success.length; i++) {
|
||||||
|
var row = document.getElementById(result.data.success[i].filename);
|
||||||
|
row.parentNode.removeChild(row);
|
||||||
|
}
|
||||||
|
if (result.status != 'success') {
|
||||||
|
OC.dialogs.alert(result.data.message, 'Error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,13 @@
|
||||||
</th>
|
</th>
|
||||||
<th id="headerDate">
|
<th id="headerDate">
|
||||||
<span id="modified"><?php echo $l->t( 'Deleted' ); ?></span>
|
<span id="modified"><?php echo $l->t( 'Deleted' ); ?></span>
|
||||||
|
<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>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
<input type="hidden" id="disableSharing" data-status="<?php echo $_['disableSharing']; ?>">
|
<input type="hidden" id="disableSharing" data-status="<?php echo $_['disableSharing']; ?>">
|
||||||
<?php foreach($_['files'] as $file):
|
<?php foreach($_['files'] as $file):
|
||||||
$simple_file_size = OCP\simple_file_size($file['size']);
|
|
||||||
// the bigger the file, the darker the shade of grey; megabytes*2
|
|
||||||
$simple_size_color = intval(200-$file['size']/(1024*1024)*2);
|
|
||||||
if($simple_size_color<0) $simple_size_color = 0;
|
|
||||||
$relative_deleted_date = OCP\relative_modified_date($file['timestamp']);
|
$relative_deleted_date = OCP\relative_modified_date($file['timestamp']);
|
||||||
// the older the file, the brighter the shade of grey; days*14
|
// the older the file, the brighter the shade of grey; days*14
|
||||||
$relative_date_color = round((time()-$file['mtime'])/60/60/24*14);
|
$relative_date_color = round((time()-$file['date'])/60/60/24*14);
|
||||||
if($relative_date_color>200) $relative_date_color = 200;
|
if($relative_date_color>200) $relative_date_color = 200;
|
||||||
$name = str_replace('+', '%20', urlencode($file['name']));
|
$name = str_replace('+', '%20', urlencode($file['name']));
|
||||||
$name = str_replace('%2F', '/', $name);
|
$name = str_replace('%2F', '/', $name);
|
||||||
|
|
Loading…
Reference in New Issue