[Pkg-owncloud-commits] [owncloud] 28/59: return relative path
David Prévot
taffit at moszumanska.debian.org
Fri Jul 18 16:19:27 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit eaa5c530def5f35a94ff11e1cd9b8c757c013a37
Author: Jörn Friedrich Dreyer <jfd at butonic.de>
Date: Mon Jul 14 17:10:52 2014 +0200
return relative path
---
lib/private/search/result/file.php | 42 ++++++++++++++------------------------
1 file changed, 15 insertions(+), 27 deletions(-)
diff --git a/lib/private/search/result/file.php b/lib/private/search/result/file.php
index 82c425a..38acac4 100644
--- a/lib/private/search/result/file.php
+++ b/lib/private/search/result/file.php
@@ -65,10 +65,13 @@ class File extends \OCP\Search\Result {
/**
* Create a new file search result
- * @param array $data file data given by provider
+ * @param FileInfo $data file data given by provider
*/
public function __construct(FileInfo $data) {
- $info = pathinfo($data->getPath());
+
+ $path = $this->getRelativePath($data->getPath());
+
+ $info = pathinfo($path);
$this->id = $data->getId();
$this->name = $info['basename'];
$this->link = \OCP\Util::linkTo(
@@ -76,38 +79,23 @@ class File extends \OCP\Search\Result {
'index.php',
array('dir' => $info['dirname'], 'file' => $info['basename'])
);
- $this->permissions = self::get_permissions($data->getPath());
- $this->path = (strpos($data->getPath(), 'files') === 0) ? substr($data->getPath(), 5) : $data->getPath();
+ $this->permissions = $data->getPermissions();
+ $this->path = $path;
$this->size = $data->getSize();
$this->modified = $data->getMtime();
$this->mime_type = $data->getMimetype();
}
/**
- * Determine permissions for a given file path
+ * converts a path relative to the users files folder
+ * eg /user/files/foo.txt -> /foo.txt
* @param string $path
- * @return int
+ * @return string relative path
*/
- function get_permissions($path) {
- // add read permissions
- $permissions = \OCP\PERMISSION_READ;
- // get directory
- $fileinfo = pathinfo($path);
- $dir = $fileinfo['dirname'] . '/';
- // add update permissions
- if (Filesystem::isUpdatable($dir)) {
- $permissions |= \OCP\PERMISSION_UPDATE;
- }
- // add delete permissions
- if (Filesystem::isDeletable($dir)) {
- $permissions |= \OCP\PERMISSION_DELETE;
- }
- // add share permissions
- if (Filesystem::isSharable($dir)) {
- $permissions |= \OCP\PERMISSION_SHARE;
- }
- // return
- return $permissions;
+ function getRelativePath ($path) {
+ $root = \OC::$server->getUserFolder();
+ return $root->getRelativePath($path);
+
}
-
+
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list