From e2516a2b65185bd3081361d0b8f25e6eaf7d698f Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Wed, 6 Feb 2013 16:23:22 +0100 Subject: allow to delete single files from the trash bin permanently --- apps/files_trashbin/lib/trash.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'apps/files_trashbin/lib') diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index a7eff3d44e0..bf98b6dfe80 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -150,6 +150,45 @@ class Trashbin { return false; } + /** + * delete file from trash bin permanently + * @param $filename path to the file + * @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))->fetchAll(); + $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); + } + } + } + } + + $view->unlink('/files_trashbin/'.$file); + + return true; + } + + /** * clean up the trash bin */ -- cgit v1.2.3 From fd171a4f3407a4c4c01b7eac256e2b1a9f920f25 Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Wed, 6 Feb 2013 16:50:16 +0100 Subject: copy&paste bug, no fetchAll() needed here --- apps/files_trashbin/lib/trash.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files_trashbin/lib') diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index bf98b6dfe80..e41dcb096c9 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -163,7 +163,7 @@ class Trashbin { if ( $timestamp ) { $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND id=? AND timestamp=?'); - $query->execute(array($user,$filename,$timestamp))->fetchAll(); + $query->execute(array($user,$filename,$timestamp)); $file = $filename.'.d'.$timestamp; } else { $file = $filename; -- cgit v1.2.3 From c81d7b0b903b15e57676ea249ee90707c1d7a3f6 Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Thu, 7 Feb 2013 12:45:27 +0100 Subject: OCA_Versions is now known as OCA\Files_Versions --- apps/files_trashbin/lib/trash.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files_trashbin/lib') diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index e41dcb096c9..10808ca717b 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -65,7 +65,7 @@ class Trashbin { 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); } -- cgit v1.2.3 From 7e874af2c89b5d3c07dae45614693dade74b190e Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Thu, 7 Feb 2013 13:14:45 +0100 Subject: rename OCA_Trash to OCA\Files_Trashbin --- apps/files_trashbin/ajax/delete.php | 2 +- apps/files_trashbin/ajax/undelete.php | 2 +- apps/files_trashbin/appinfo/app.php | 6 +++--- apps/files_trashbin/lib/hooks.php | 2 +- apps/files_trashbin/lib/trash.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'apps/files_trashbin/lib') diff --git a/apps/files_trashbin/ajax/delete.php b/apps/files_trashbin/ajax/delete.php index a166ce55c88..b3d41f1be64 100644 --- a/apps/files_trashbin/ajax/delete.php +++ b/apps/files_trashbin/ajax/delete.php @@ -15,7 +15,7 @@ if ($path_parts['dirname'] == '.') { $timestamp = null; } -if (OCA_Trash\Trashbin::delete($filename, $timestamp)) { +if (OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp)) { error_log("feinifeini"); OCP\JSON::success(array("data" => array("filename" => $file))); } else { diff --git a/apps/files_trashbin/ajax/undelete.php b/apps/files_trashbin/ajax/undelete.php index ee1c64aaaf2..a118d003de7 100644 --- a/apps/files_trashbin/ajax/undelete.php +++ b/apps/files_trashbin/ajax/undelete.php @@ -22,7 +22,7 @@ foreach ($list as $file) { $timestamp = null; } - if ( !OCA_Trash\Trashbin::restore($file, $filename, $timestamp) ) { + if ( !OCA\Files_Trashbin\Trashbin::restore($file, $filename, $timestamp) ) { $error[] = $filename; } else { $success[$i]['filename'] = $file; diff --git a/apps/files_trashbin/appinfo/app.php b/apps/files_trashbin/appinfo/app.php index 3741d42c781..b1a15cd13d1 100644 --- a/apps/files_trashbin/appinfo/app.php +++ b/apps/files_trashbin/appinfo/app.php @@ -1,7 +1,7 @@