aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/helper.php
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-04-16 16:41:23 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-04-23 12:54:26 +0200
commit93469ca46865d02d33710a2f70f7f6092c8f5c58 (patch)
tree307247653ef5b55f95a00108377f037de6f02a31 /apps/files_sharing/lib/helper.php
parentdd1e47b3b896e2ee59faf5f423bb911c5d2c2548 (diff)
downloadnextcloud-server-93469ca46865d02d33710a2f70f7f6092c8f5c58.tar.gz
nextcloud-server-93469ca46865d02d33710a2f70f7f6092c8f5c58.zip
make it possible to move files out of a shared mount point
Diffstat (limited to 'apps/files_sharing/lib/helper.php')
-rw-r--r--apps/files_sharing/lib/helper.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/helper.php b/apps/files_sharing/lib/helper.php
index e2780e98935..cc1f7d9ffdf 100644
--- a/apps/files_sharing/lib/helper.php
+++ b/apps/files_sharing/lib/helper.php
@@ -145,4 +145,35 @@ class Helper {
return $result;
}
+
+ public static function getUidAndFilename($filename) {
+ $uid = \OC\Files\Filesystem::getOwner($filename);
+ \OC\Files\Filesystem::initMountPoints($uid);
+ if ( $uid != \OCP\User::getUser() ) {
+ $info = \OC\Files\Filesystem::getFileInfo($filename);
+ $ownerView = new \OC\Files\View('/'.$uid.'/files');
+ $filename = $ownerView->getPath($info['fileid']);
+ }
+ return array($uid, $filename);
+ }
+
+ /**
+ * @brief Format a path to be relative to the /user/files/ directory
+ * @param string $path the absolute path
+ * @return string e.g. turns '/admin/files/test.txt' into 'test.txt'
+ */
+ 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);
+
+ return $relPath;
+ }
}