diff options
Diffstat (limited to 'apps/files_encryption/lib/helper.php')
-rwxr-xr-x | apps/files_encryption/lib/helper.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php index b09c584c0b8..0209a5d18b7 100755 --- a/apps/files_encryption/lib/helper.php +++ b/apps/files_encryption/lib/helper.php @@ -199,6 +199,12 @@ class Helper { public static function stripUserFilesPath($path) { $trimmed = ltrim($path, '/'); $split = explode('/', $trimmed); + + // it is not a file relative to data/user/files + if (count($split) < 3 || $split[1] !== 'files') { + return false; + } + $sliced = array_slice($split, 2); $relPath = implode('/', $sliced); @@ -206,6 +212,27 @@ class Helper { } /** + * @brief get path to the correspondig file in data/user/files + * @param string $path path to a version or a file in the trash + * @return string path to correspondig file relative to data/user/files + */ + public static function getPathToRealFile($path) { + $trimmed = ltrim($path, '/'); + $split = explode('/', $trimmed); + + if (count($split) < 3 || $split[1] !== "files_versions") { + return false; + } + + $sliced = array_slice($split, 2); + $realPath = implode('/', $sliced); + //remove the last .v + $realPath = substr($realPath, 0, strrpos($realPath, '.v')); + + return $realPath; + } + + /** * @brief redirect to a error page */ public static function redirectToErrorPage() { |