summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib/trash.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_trashbin/lib/trash.php')
-rw-r--r--apps/files_trashbin/lib/trash.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php
index a7eff3d44e0..e41dcb096c9 100644
--- a/apps/files_trashbin/lib/trash.php
+++ b/apps/files_trashbin/lib/trash.php
@@ -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() {