Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndras Timar <andras.timar@collabora.com>2017-06-14 15:11:09 +0300
committerAndras Timar <andras.timar@collabora.com>2017-06-14 15:17:21 +0300
commitaa4df2e800e3038d1621d5fc7451bbe2ac32d699 (patch)
tree5093eea5c07ed451085f2765474cb6c3be89e7a7 /lib/TokenManager.php
parent935674b8626444c9f0b53937bcf65e34f4396cbd (diff)
Restore 'Enable edit for specific groups' feature, fixes #66
Diffstat (limited to 'lib/TokenManager.php')
-rw-r--r--lib/TokenManager.php20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/TokenManager.php b/lib/TokenManager.php
index 846d7664..38fbe2a5 100644
--- a/lib/TokenManager.php
+++ b/lib/TokenManager.php
@@ -50,11 +50,13 @@ class TokenManager {
IManager $shareManager,
IURLGenerator $urlGenerator,
Parser $wopiParser,
+ AppConfig $appConfig,
$UserId) {
$this->rootFolder = $rootFolder;
$this->shareManager = $shareManager;
$this->urlGenerator = $urlGenerator;
$this->wopiParser = $wopiParser;
+ $this->appConfig = $appConfig;
$this->userId = $UserId;
}
@@ -79,6 +81,22 @@ class TokenManager {
/** @var File $file */
$rootFolder = $this->rootFolder->getUserFolder($this->userId);
$updatable = $rootFolder->isUpdateable();
+ // Check if the editor (user who is accessing) is in editable group
+ // UserCanWrite only if
+ // 1. No edit groups are set or
+ // 2. if they are set, it is in one of the edit groups
+ $editorUid = \OC::$server->getUserSession()->getUser()->getUID();
+ $editGroups = array_filter(explode('|', $this->appConfig->getAppValue('edit_groups')));
+ if ($updatable && count($editGroups) > 0) {
+ $updatable = false;
+ foreach($editGroups as $editGroup) {
+ $editorGroup = \OC::$server->getGroupManager()->get($editGroup);
+ if ($editorGroup !== null && sizeof($editorGroup->searchUsers($editorUid)) > 0) {
+ $updatable = true;
+ break;
+ }
+ }
+ }
} catch (\Exception $e) {
throw $e;
}
@@ -103,4 +121,4 @@ class TokenManager {
throw $e;
}
}
-} \ No newline at end of file
+}