summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/share
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-10-01 15:13:10 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-10-10 12:16:26 +0200
commit3431d547a9834dce70fab8a835862bb276c8575b (patch)
tree785e4763c6cc1876d4476639c35c5e5c6c0a2e00 /apps/files_sharing/lib/share
parent94a9ff1cd8b18577e16bde90146b0be84223d725 (diff)
downloadnextcloud-server-3431d547a9834dce70fab8a835862bb276c8575b.tar.gz
nextcloud-server-3431d547a9834dce70fab8a835862bb276c8575b.zip
fix performance issues
Diffstat (limited to 'apps/files_sharing/lib/share')
-rw-r--r--apps/files_sharing/lib/share/folder.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/share/folder.php b/apps/files_sharing/lib/share/folder.php
index 4426beec636..2671f5738b7 100644
--- a/apps/files_sharing/lib/share/folder.php
+++ b/apps/files_sharing/lib/share/folder.php
@@ -21,6 +21,53 @@
class OC_Share_Backend_Folder extends OC_Share_Backend_File implements OCP\Share_Backend_Collection {
+ /**
+ * get shared parents
+ *
+ * @param int $itemSource item source ID
+ * @param string $shareWith with whom should the item be shared
+ * @return array with shares
+ */
+ public function getParents($itemSource, $shareWith = null) {
+ $result = array();
+ $parent = $this->getParentId($itemSource);
+ while ($parent) {
+ $shares = \OCP\Share::getItemSharedWithUser('folder', $parent, $shareWith);
+ if ($shares) {
+ foreach ($shares as $share) {
+ $name = substr($share['path'], strrpos($share['path'], '/') + 1);
+ $share['collection']['path'] = $name;
+ $share['collection']['item_type'] = 'folder';
+ $share['file_path'] = $name;
+ $displayNameOwner = \OCP\User::getDisplayName($share['uid_owner']);
+ $displayNameShareWith = \OCP\User::getDisplayName($share['share_with']);
+ $share['displayname_owner'] = ($displayNameOwner) ? $displayNameOwner : $share['uid_owner'];
+ $share['share_with_displayname'] = ($displayNameShareWith) ? $displayNameShareWith : $share['uid_owner'];
+
+ $result[] = $share;
+ }
+ }
+ $parent = $this->getParentId($parent);
+ }
+
+ return $result;
+ }
+
+ /**
+ * get file cache ID of parent
+ *
+ * @param int $child file cache ID of child
+ * @return mixed parent ID or null
+ */
+ private function getParentId($child) {
+ $query = \OC_DB::prepare('SELECT `parent` FROM `*PREFIX*filecache` WHERE `fileid` = ?');
+ $result = $query->execute(array($child));
+ $row = $result->fetchRow();
+ $parent = ($row) ? $row['parent'] : null;
+
+ return $parent;
+ }
+
public function getChildren($itemSource) {
$children = array();
$parents = array($itemSource);