diff options
Diffstat (limited to 'apps/files_trashbin/lib/trash.php')
-rw-r--r-- | apps/files_trashbin/lib/trash.php | 43 |
1 files changed, 41 insertions, 2 deletions
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() { |