summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-02-08 00:11:54 +0100
committerRobin Appelman <icewind@owncloud.com>2013-02-08 00:11:54 +0100
commitf93f9dd50cce6b6e2ed4eeca2d34b2bac82e0350 (patch)
treec76b2eabb63ed308eb882468cb2a74042e6f9d53 /apps/files_trashbin/lib
parent697536cf6ad1c9a862c32605b807172dfa680d22 (diff)
parent3bd33b69a1c37cee5c3d180ec8952a611aabb4d1 (diff)
downloadnextcloud-server-f93f9dd50cce6b6e2ed4eeca2d34b2bac82e0350.tar.gz
nextcloud-server-f93f9dd50cce6b6e2ed4eeca2d34b2bac82e0350.zip
merge master into trash_fileactions
Diffstat (limited to 'apps/files_trashbin/lib')
-rw-r--r--apps/files_trashbin/lib/hooks.php2
-rw-r--r--apps/files_trashbin/lib/trash.php43
2 files changed, 42 insertions, 3 deletions
diff --git a/apps/files_trashbin/lib/hooks.php b/apps/files_trashbin/lib/hooks.php
index d3bee105b51..d6a62d447b8 100644
--- a/apps/files_trashbin/lib/hooks.php
+++ b/apps/files_trashbin/lib/hooks.php
@@ -24,7 +24,7 @@
* This class contains all hooks.
*/
-namespace OCA_Trash;
+namespace OCA\Files_Trashbin;
class Hooks {
diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php
index 1c66fac8903..abc7fbb7383 100644
--- a/apps/files_trashbin/lib/trash.php
+++ b/apps/files_trashbin/lib/trash.php
@@ -20,7 +20,7 @@
*
*/
-namespace OCA_Trash;
+namespace OCA\Files_Trashbin;
class Trashbin {
@@ -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);
}
@@ -151,6 +151,45 @@ class Trashbin {
}
/**
+ * 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));
+ $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
*/
private static function expire() {