OC.dialogs.alert(result.data.message, 'Error');
}
});
-
+
});
};
-
+
+ FileActions.register('all', 'Delete', OC.PERMISSION_READ, function () {
+ return OC.imagePath('core', 'actions/delete');
+ }, function (filename) {
+ $('.tipsy').remove();
+
+ var tr=$('tr').filterAttr('data-file', filename);
+ 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>';
+ deleteAction[0].outerHTML = newHTML;
+
+ $.post(OC.filePath('files_trashbin','ajax','delete.php'),
+ {file:tr.attr('data-file') },
+ function(result){
+ if ( result.status == 'success' ) {
+ var row = document.getElementById(result.data.filename);
+ row.parentNode.removeChild(row);
+ } else {
+ deleteAction[0].outerHTML = oldHTML;
+ OC.dialogs.alert(result.data.message, 'Error');
+ }
+ });
+
+ });
+
// Sets the select_all checkbox behaviour :
$('#select_all').click(function() {
if($(this).attr('checked')){
}
}
processSelection();
- });
-
+ });
+
$('.undelete').click('click',function(event) {
- var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'perform undelete 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 fileslist=files.join(';');
var dirlisting=getSelectedFiles('dirlisting')[0];
<?php
-/**\r
- * ownCloud - trash bin\r
- *\r
- * @author Bjoern Schiessle\r
- * @copyright 2013 Bjoern Schiessle schiessle@owncloud.com\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.\r
- *\r
- * You should have received a copy of the GNU Affero General Public\r
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.\r
- *\r
- */\r
+/**
+ * ownCloud - trash bin
+ *
+ * @author Bjoern Schiessle
+ * @copyright 2013 Bjoern Schiessle schiessle@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
- namespace OCA_Trash;
++namespace OCA\Files_Trashbin;
-namespace OCA\Files_Trashbin;\r
-\r
class Trashbin {
const DEFAULT_RETENTION_OBLIGATION=180; // how long do we keep files in the trash bin if no other value is defined in the config file (unit: days)
$view->deleteAll('files_trashbin/'.$deleted.'.d'.$timestamp);
\OC_Log::write('files_trashbin', 'trash bin database couldn\'t be updated', \OC_log::ERROR);
return;
- }\r
- \r
- if ( \OCP\App::isEnabled('files_versions') ) {\r
- if ( $view->is_dir('files_versions'.$file_path) ) {\r
- $view->rename('files_versions'.$file_path, 'versions_trashbin/'. $deleted.'.d'.$timestamp);\r
- } else if ( $versions = \OCA\Files_Versions\Storage::getVersions($file_path) ) {\r
- foreach ($versions as $v) {\r
- $view->rename('files_versions'.$v['path'].'.v'.$v['version'], 'versions_trashbin/'. $deleted.'.v'.$v['version'].'.d'.$timestamp);\r
- }\r
- }\r
+ }
+
+ if ( \OCP\App::isEnabled('files_versions') ) {
+ if ( $view->is_dir('files_versions'.$file_path) ) {
+ $view->rename('files_versions'.$file_path, 'versions_trashbin/'. $deleted.'.d'.$timestamp);
- } else if ( $versions = \OCA_Versions\Storage::getVersions($file_path) ) {
++ } else if ( $versions = \OCA\Files_Versions\Storage::getVersions($file_path) ) {
+ foreach ($versions as $v) {
+ $view->rename('files_versions'.$v['path'].'.v'.$v['version'], 'versions_trashbin/'. $deleted.'.v'.$v['version'].'.d'.$timestamp);
+ }
+ }
}
} else {
\OC_Log::write('files_trashbin', 'Couldn\'t move '.$file_path.' to the trash bin' , \OC_log::ERROR);
return false;
}
- /**\r
- * delete file from trash bin permanently\r
++ /**
++ * delete file from trash bin permanently
+ * @param $filename path to the file
- * @param $timestamp of deletion time\r
- * @return true/false\r
- */\r
- public static function delete($filename, $timestamp=null) {\r
- \r
- $user = \OCP\User::getUser();\r
- $view = new \OC_FilesystemView('/'.$user);\r
- \r
- if ( $timestamp ) {\r
- $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND id=? AND timestamp=?');\r
- $query->execute(array($user,$filename,$timestamp));\r
++ * @param $timestamp of deletion time
++ * @return true/false
++ */
++ public static function delete($filename, $timestamp=null) {
++
++ $user = \OCP\User::getUser();
++ $view = new \OC_FilesystemView('/'.$user);
++
++ if ( $timestamp ) {
++ $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND id=? AND timestamp=?');
++ $query->execute(array($user,$filename,$timestamp));
+ $file = $filename.'.d'.$timestamp;
+ } else {
+ $file = $filename;
+ }
+
+ if ( \OCP\App::isEnabled('files_versions') ) {
+ if ($view->is_dir('versions_trashbin/'.$file)) {
+ $view->unlink('versions_trashbin/'.$file);
+ } else if ( $versions = self::getVersionsFromTrash($file, $timestamp) ) {
+ foreach ($versions as $v) {
+ if ($timestamp ) {
+ $view->unlink('versions_trashbin/'.$filename.'.v'.$v.'.d'.$timestamp);
+ } else {
+ $view->unlink('versions_trashbin/'.$file.'.v'.$v);
+ }
+ }
+ }
- }\r
++ }
+
+ $view->unlink('/files_trashbin/'.$file);
- \r
- return true;\r
++
++ return true;
+ }
+
+
- /**\r
- * clean up the trash bin\r
- */\r
+ /**
+ * clean up the trash bin
+ */
private static function expire() {
- $view = new \OC_FilesystemView('/'.\OCP\User::getUser());
+ $view = new \OC\Files\View('/'.\OCP\User::getUser());
$user = \OCP\User::getUser();
- $query = \OC_DB::prepare('SELECT location,type,id,timestamp FROM *PREFIX*files_trash WHERE user=?');\r
+ $query = \OC_DB::prepare('SELECT location,type,id,timestamp FROM *PREFIX*files_trash WHERE user=?');
$result = $query->execute(array($user))->fetchAll();
$retention_obligation = \OC_Config::getValue('trashbin_retention_obligation', self::DEFAULT_RETENTION_OBLIGATION);