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
path: root/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2019-05-15 12:40:31 +0300
committerGitHub <noreply@github.com>2019-05-15 12:40:31 +0300
commitbe03e8c24bbb7101cc776cf64034999179079436 (patch)
treeb3ecc7a16d6e4d61e3d6924956a434358329cb17 /lib
parent0a658b2e9f80ce008906455c3ed1f5e0840fa766 (diff)
parentaf503f45d0a83f45ac367a15112add21d09ee5e3 (diff)
Fix searching for groups (#501)
Fix searching for groups
Diffstat (limited to 'lib')
-rw-r--r--lib/TokenManager.php26
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/TokenManager.php b/lib/TokenManager.php
index 03a9efed..0d73e45f 100644
--- a/lib/TokenManager.php
+++ b/lib/TokenManager.php
@@ -28,7 +28,9 @@ use OCA\Richdocuments\Db\Wopi;
use OCA\Richdocuments\WOPI\Parser;
use OCP\Files\File;
use OCP\Files\IRootFolder;
+use OCP\IGroupManager;
use OCP\IURLGenerator;
+use OCP\IUserManager;
use OCP\Share\IManager;
use OCP\IL10N;
@@ -49,6 +51,10 @@ class TokenManager {
private $wopiMapper;
/** @var IL10N */
private $trans;
+ /** @var IUserManager */
+ private $userManager;
+ /** @var IGroupManager */
+ private $groupManager;
/**
* @param IRootFolder $rootFolder
@@ -67,7 +73,9 @@ class TokenManager {
AppConfig $appConfig,
$UserId,
WopiMapper $wopiMapper,
- IL10N $trans) {
+ IL10N $trans,
+ IUserManager $userManager,
+ IGroupManager $groupManager) {
$this->rootFolder = $rootFolder;
$this->shareManager = $shareManager;
$this->urlGenerator = $urlGenerator;
@@ -76,6 +84,8 @@ class TokenManager {
$this->trans = $trans;
$this->userId = $UserId;
$this->wopiMapper = $wopiMapper;
+ $this->userManager = $userManager;
+ $this->groupManager = $groupManager;
}
/**
@@ -116,11 +126,12 @@ class TokenManager {
// 1. No edit groups are set or
// 2. if they are set, it is in one of the edit groups
$editGroups = array_filter(explode('|', $this->appConfig->getAppValue('edit_groups')));
- if ($updatable && count($editGroups) > 0) {
+ $editorUser = $this->userManager->get($editoruid);
+ if ($updatable && count($editGroups) > 0 && $editorUser) {
$updatable = false;
foreach($editGroups as $editGroup) {
- $editorGroup = \OC::$server->getGroupManager()->get($editGroup);
- if ($editorGroup !== null && sizeof($editorGroup->searchUsers($editoruid)) > 0) {
+ $editorGroup = $this->groupManager->get($editGroup);
+ if ($editorGroup !== null && $editorGroup->inGroup($editorUser)) {
$updatable = true;
break;
}
@@ -180,11 +191,12 @@ class TokenManager {
// 1. No edit groups are set or
// 2. if they are set, it is in one of the edit groups
$editGroups = array_filter(explode('|', $this->appConfig->getAppValue('edit_groups')));
- if ($updatable && count($editGroups) > 0) {
+ $editorUser = $this->userManager->get($editoruid);
+ if ($updatable && count($editGroups) > 0 && $editorUser) {
$updatable = false;
foreach($editGroups as $editGroup) {
- $editorGroup = \OC::$server->getGroupManager()->get($editGroup);
- if ($editorGroup !== null && sizeof($editorGroup->searchUsers($editoruid)) > 0) {
+ $editorGroup = $this->groupManager->get($editGroup);
+ if ($editorGroup !== null && $editorGroup->inGroup($editorUser)) {
$updatable = true;
break;
}