aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-10-27 15:32:23 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2017-04-13 12:58:49 +0200
commit97f8ca6595caf051eae9c9261bdbd481c9dd4be1 (patch)
tree8ef3fe734b944599b5e8f3617fca1ec26335d42d /lib
parent553b3b29280dde318c4987dfd42436f72eff0df4 (diff)
downloadnextcloud-server-97f8ca6595caf051eae9c9261bdbd481c9dd4be1.tar.gz
nextcloud-server-97f8ca6595caf051eae9c9261bdbd481c9dd4be1.zip
Added ShareHelper
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Share20/ShareHelper.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/lib/private/Share20/ShareHelper.php b/lib/private/Share20/ShareHelper.php
new file mode 100644
index 00000000000..a7d46457cd8
--- /dev/null
+++ b/lib/private/Share20/ShareHelper.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016, Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OC\Share20;
+
+use OCP\Files\IRootFolder;
+use OCP\Files\Node;
+use OCP\Files\NotFoundException;
+
+class ShareHelper {
+ /** @var IRootFolder */
+ private $rootFolder;
+
+ public function __construct(IRootFolder $rootFolder) {
+ $this->rootFolder = $rootFolder;
+ }
+
+ /**
+ * If a user has access to a file
+ *
+ * @param Node $node
+ * @param array $users Array of userIds
+ * @return array Mapping $uid to an array of nodes
+ */
+ public function getPathsForAccessList(Node $node, $users) {
+ $result = [];
+
+ foreach ($users as $user) {
+ try {
+ $userFolder = $this->rootFolder->getUserFolder($user);
+ } catch (NotFoundException $e) {
+ continue;
+ }
+
+ $nodes = $userFolder->getById($node->getId());
+ if ($nodes === []) {
+ continue;
+ }
+
+ $result[$user] = $nodes;
+ }
+
+ return $result;
+ }
+}