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

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-05-11 13:39:22 +0300
committerVincent Petry <pvince81@owncloud.com>2016-05-20 18:56:02 +0300
commitb5eb3d9e5a7edf61bfc3f4243533de9ca4afa8d4 (patch)
treea203c5b863b77a4de2c3db1f2b099268a8ffc712 /lib/private/SystemTag
parent3cd65fe25dc6f213dd7e4a1687616dc5e0960d4d (diff)
Add system tag assignability check with groups
Whenever a user is not an admin, a tag is visible but not user-assignable, check whether the user is a member of the allowed groups.
Diffstat (limited to 'lib/private/SystemTag')
-rw-r--r--lib/private/SystemTag/SystemTagManager.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/private/SystemTag/SystemTagManager.php b/lib/private/SystemTag/SystemTagManager.php
index 1c91ad1f578..832afc2a114 100644
--- a/lib/private/SystemTag/SystemTagManager.php
+++ b/lib/private/SystemTag/SystemTagManager.php
@@ -337,6 +337,7 @@ class SystemTagManager implements ISystemTagManager {
* {@inheritdoc}
*/
public function canUserAssignTag(ISystemTag $tag, IUser $user) {
+ // early check to avoid unneeded group lookups
if ($tag->isUserAssignable() && $tag->isUserVisible()) {
return true;
}
@@ -345,6 +346,18 @@ class SystemTagManager implements ISystemTagManager {
return true;
}
+ if (!$tag->isUserVisible()) {
+ return false;
+ }
+
+ $groupIds = $this->groupManager->getUserGroupIds($user->getUID());
+ if (!empty($groupIds)) {
+ $matchingGroups = array_intersect($groupIds, $this->getTagGroups($tag));
+ if (!empty($matchingGroups)) {
+ return true;
+ }
+ }
+
return false;
}