aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2014-03-31 21:38:54 +0200
committerBart Visscher <bartv@thisnet.nl>2014-03-31 21:38:54 +0200
commit6b061c236dd5730837b567f2c39a19af1617d33c (patch)
tree27de0d46deae2987ea398f2f2aee4e26786c6f48 /apps/files_sharing/lib
parent8951328a87c16e5ebfe4d3e5c392347db1e54f92 (diff)
parentab696edba685cd6d2a64c2e48907f03197aae53f (diff)
downloadnextcloud-server-6b061c236dd5730837b567f2c39a19af1617d33c.tar.gz
nextcloud-server-6b061c236dd5730837b567f2c39a19af1617d33c.zip
Merge branch 'master' into type-hinting
Conflicts: lib/private/image.php lib/private/l10n.php lib/private/request.php lib/private/share/mailnotifications.php lib/private/template/base.php
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/api.php43
-rw-r--r--apps/files_sharing/lib/cache.php6
-rw-r--r--apps/files_sharing/lib/share/file.php3
3 files changed, 40 insertions, 12 deletions
diff --git a/apps/files_sharing/lib/api.php b/apps/files_sharing/lib/api.php
index 0ba58aa896a..de3c1cd2630 100644
--- a/apps/files_sharing/lib/api.php
+++ b/apps/files_sharing/lib/api.php
@@ -68,7 +68,7 @@ class Api {
public static function getShare($params) {
$s = self::getShareFromId($params['id']);
- $params['itemSource'] = $s['item_source'];
+ $params['itemSource'] = $s['file_source'];
$params['itemType'] = $s['item_type'];
$params['specificShare'] = true;
@@ -98,8 +98,14 @@ class Api {
break;
}
}
+ } else {
+ $path = $params['path'];
+ foreach ($shares as $key => $share) {
+ $shares[$key]['path'] = $path;
+ }
}
+
// include also reshares in the lists. This means that the result
// will contain every user with access to the file.
if (isset($params['reshares']) && $params['reshares'] === true) {
@@ -107,8 +113,10 @@ class Api {
}
if ($receivedFrom) {
- $shares['received_from'] = $receivedFrom['uid_owner'];
- $shares['received_from_displayname'] = \OCP\User::getDisplayName($receivedFrom['uid_owner']);
+ foreach ($shares as $key => $share) {
+ $shares[$key]['received_from'] = $receivedFrom['uid_owner'];
+ $shares[$key]['received_from_displayname'] = \OCP\User::getDisplayName($receivedFrom['uid_owner']);
+ }
}
} else {
$shares = null;
@@ -174,9 +182,12 @@ class Api {
$share = \OCP\Share::getItemShared($itemType, $file['fileid']);
if($share) {
$receivedFrom = \OCP\Share::getItemSharedWithBySource($itemType, $file['fileid']);
+ reset($share);
+ $key = key($share);
+ $share[$key]['path'] = self::correctPath($share[$key]['path'], $path);
if ($receivedFrom) {
- $share['received_from'] = $receivedFrom['uid_owner'];
- $share['received_from_displayname'] = \OCP\User::getDisplayName($receivedFrom['uid_owner']);
+ $share[$key]['received_from'] = $receivedFrom['uid_owner'];
+ $share[$key]['received_from_displayname'] = \OCP\User::getDisplayName($receivedFrom['uid_owner']);
}
$result = array_merge($result, $share);
}
@@ -281,9 +292,8 @@ class Api {
public static function updateShare($params) {
$share = self::getShareFromId($params['id']);
- $itemSource = isset($share['item_source']) ? $share['item_source'] : null;
- if($itemSource === null) {
+ if(!isset($share['file_source'])) {
return new \OC_OCS_Result(null, 404, "wrong share Id, share doesn't exist.");
}
@@ -431,10 +441,10 @@ class Api {
public static function deleteShare($params) {
$share = self::getShareFromId($params['id']);
- $itemSource = isset($share['item_source']) ? $share['item_source'] : null;
+ $fileSource = isset($share['file_source']) ? $share['file_source'] : null;
$itemType = isset($share['item_type']) ? $share['item_type'] : null;;
- if($itemSource === null) {
+ if($fileSource === null) {
return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist.");
}
@@ -448,7 +458,7 @@ class Api {
try {
$return = \OCP\Share::unshare(
$itemType,
- $itemSource,
+ $fileSource,
$shareType,
$shareWith);
} catch (\Exception $e) {
@@ -504,7 +514,7 @@ class Api {
* @return array with: item_source, share_type, share_with, item_type, permissions
*/
private static function getShareFromId($shareID) {
- $sql = 'SELECT `item_source`, `share_type`, `share_with`, `item_type`, `permissions` FROM `*PREFIX*share` WHERE `id` = ?';
+ $sql = 'SELECT `file_source`, `item_source`, `share_type`, `share_with`, `item_type`, `permissions` FROM `*PREFIX*share` WHERE `id` = ?';
$args = array($shareID);
$query = \OCP\DB::prepare($sql);
$result = $query->execute($args);
@@ -521,4 +531,15 @@ class Api {
}
+ /**
+ * @brief make sure that the path has the correct root
+ *
+ * @param string $path path returned from the share API
+ * @param string $folder current root folder
+ * @return string the correct path
+ */
+ protected static function correctPath($path, $folder) {
+ return \OC_Filesystem::normalizePath('/' . $folder . '/' . basename($path));
+ }
+
}
diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php
index 4b0da0b002d..01db29d72e2 100644
--- a/apps/files_sharing/lib/cache.php
+++ b/apps/files_sharing/lib/cache.php
@@ -137,9 +137,12 @@ class Shared_Cache extends Cache {
} else {
$cache = $this->getSourceCache($folder);
if ($cache) {
+ $parent = $this->storage->getFile($folder);
$sourceFolderContent = $cache->getFolderContents($this->files[$folder]);
foreach ($sourceFolderContent as $key => $c) {
$sourceFolderContent[$key]['usersPath'] = 'files/Shared/' . $folder . '/' . $c['name'];
+ $sourceFolderContent[$key]['uid_owner'] = $parent['uid_owner'];
+ $sourceFolderContent[$key]['displayname_owner'] = $parent['uid_owner'];
}
return $sourceFolderContent;
@@ -354,9 +357,10 @@ class Shared_Cache extends Cache {
* get the size of a folder and set it in the cache
*
* @param string $path
+ * @param array $entry (optional) meta data of the folder
* @return int
*/
- public function calculateFolderSize($path) {
+ public function calculateFolderSize($path, $entry = null) {
if ($cache = $this->getSourceCache($path)) {
return $cache->calculateFolderSize($this->files[$path]);
}
diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/share/file.php
index ec0f368386f..5e00050fe1e 100644
--- a/apps/files_sharing/lib/share/file.php
+++ b/apps/files_sharing/lib/share/file.php
@@ -94,6 +94,9 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
$file['mtime'] = $item['mtime'];
$file['encrypted'] = $item['encrypted'];
$file['etag'] = $item['etag'];
+ $file['uid_owner'] = $item['uid_owner'];
+ $file['displayname_owner'] = $item['displayname_owner'];
+
$storage = \OC\Files\Filesystem::getStorage('/');
$cache = $storage->getCache();
if ($item['encrypted'] or ($item['unencrypted_size'] > 0 and $cache->getMimetype($item['mimetype']) === 'httpd/unix-directory')) {