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::callCheck();
|
||||
|
||||
$file = $_REQUEST['file'];
|
||||
$files = $_POST['files'];
|
||||
$dirlisting = $_POST['dirlisting'];
|
||||
$list = json_decode($files);
|
||||
|
||||
$path_parts = pathinfo($file);
|
||||
if ($path_parts['dirname'] == '.') {
|
||||
$delimiter = strrpos($file, '.d');
|
||||
$filename = substr($file, 0, $delimiter);
|
||||
$timestamp = substr($file, $delimiter+2);
|
||||
} else {
|
||||
$filename = $file;
|
||||
$timestamp = null;
|
||||
$error = array();
|
||||
$success = array();
|
||||
|
||||
$i = 0;
|
||||
foreach ($list as $file) {
|
||||
if ( $dirlisting=='0') {
|
||||
$delimiter = strrpos($file, '.d');
|
||||
$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 (!OCA\Files_Trashbin\Trashbin::file_exists($filename)) {
|
||||
OCP\JSON::success(array("data" => array("filename" => $file)));
|
||||
} else {
|
||||
if ( $error ) {
|
||||
$filelist = '';
|
||||
foreach ( $error as $e ) {
|
||||
$filelist .= $e.', ';
|
||||
}
|
||||
$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::callCheck();
|
||||
|
||||
$files = $_REQUEST['files'];
|
||||
$dirlisting = $_REQUEST['dirlisting'];
|
||||
$list = explode(';', $files);
|
||||
$files = $_POST['files'];
|
||||
$dirlisting = $_POST['dirlisting'];
|
||||
$list = json_decode($files);
|
||||
|
||||
$error = array();
|
||||
$success = array();
|
||||
|
|
|
@ -16,6 +16,7 @@ OCP\Util::addScript('files', 'filelist');
|
|||
|
||||
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
|
||||
|
||||
$result = array();
|
||||
if ($dir) {
|
||||
$dirlisting = true;
|
||||
$view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_trashbin');
|
||||
|
@ -37,7 +38,7 @@ if ($dir) {
|
|||
);
|
||||
}
|
||||
}
|
||||
closedir($fullpath);
|
||||
closedir($dirContent);
|
||||
|
||||
} else {
|
||||
$dirlisting = false;
|
||||
|
|
|
@ -6,9 +6,10 @@ $(document).ready(function() {
|
|||
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 undeleteAction = $('tr').filterAttr('data-file',filename).children("td.date");
|
||||
var files = tr.attr('data-file');
|
||||
undeleteAction[0].innerHTML = undeleteAction[0].innerHTML+spinner;
|
||||
$.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){
|
||||
for (var i = 0; i < result.data.success.length; i++) {
|
||||
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 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 files = tr.attr('data-file');
|
||||
deleteAction[0].outerHTML = newHTML;
|
||||
|
||||
$.post(OC.filePath('files_trashbin','ajax','delete.php'),
|
||||
{file:tr.attr('data-file') },
|
||||
{files:JSON.stringify([files]), dirlisting:tr.attr('data-dirlisting') },
|
||||
function(result){
|
||||
if ( result.status == 'success' ) {
|
||||
var row = document.getElementById(result.data.filename);
|
||||
for (var i = 0; i < result.data.success.length; i++) {
|
||||
var row = document.getElementById(result.data.success[i].filename);
|
||||
row.parentNode.removeChild(row);
|
||||
} else {
|
||||
deleteAction[0].outerHTML = oldHTML;
|
||||
}
|
||||
if (result.status != 'success') {
|
||||
OC.dialogs.alert(result.data.message, 'Error');
|
||||
}
|
||||
});
|
||||
|
@ -93,7 +95,7 @@ $(document).ready(function() {
|
|||
$('.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 files=getSelectedFiles('file');
|
||||
var fileslist=files.join(';');
|
||||
var fileslist = JSON.stringify(files);
|
||||
var dirlisting=getSelectedFiles('dirlisting')[0];
|
||||
|
||||
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 id="headerDate">
|
||||
<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>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
<input type="hidden" id="disableSharing" data-status="<?php echo $_['disableSharing']; ?>">
|
||||
<?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']);
|
||||
// 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;
|
||||
$name = str_replace('+', '%20', urlencode($file['name']));
|
||||
$name = str_replace('%2F', '/', $name);
|
||||
|
|
Loading…
Reference in New Issue