aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib/Group_Proxy.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_ldap/lib/Group_Proxy.php')
-rw-r--r--apps/user_ldap/lib/Group_Proxy.php80
1 files changed, 18 insertions, 62 deletions
diff --git a/apps/user_ldap/lib/Group_Proxy.php b/apps/user_ldap/lib/Group_Proxy.php
index 1544d5f91e9..f0cdc7a465d 100644
--- a/apps/user_ldap/lib/Group_Proxy.php
+++ b/apps/user_ldap/lib/Group_Proxy.php
@@ -1,30 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Christopher Schäpers <kondou@ts.unde.re>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Johannes Leuker <j.leuker@hosting.de>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Vinicius Cubas Brand <vinicius@eita.org.br>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\User_LDAP;
@@ -39,45 +18,24 @@ use OCP\GroupInterface;
use OCP\IConfig;
use OCP\IUserManager;
-class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGetDisplayNameBackend, INamedBackend, IDeleteGroupBackend, IBatchMethodsBackend, IIsAdminBackend {
- private $backends = [];
- private ?Group_LDAP $refBackend = null;
- private Helper $helper;
- private GroupPluginManager $groupPluginManager;
- private bool $isSetUp = false;
- private IConfig $config;
- private IUserManager $ncUserManager;
-
+/**
+ * @template-extends Proxy<Group_LDAP>
+ */
+class Group_Proxy extends Proxy implements GroupInterface, IGroupLDAP, IGetDisplayNameBackend, INamedBackend, IDeleteGroupBackend, IBatchMethodsBackend, IIsAdminBackend {
public function __construct(
- Helper $helper,
+ private Helper $helper,
ILDAPWrapper $ldap,
AccessFactory $accessFactory,
- GroupPluginManager $groupPluginManager,
- IConfig $config,
- IUserManager $ncUserManager,
+ private GroupPluginManager $groupPluginManager,
+ private IConfig $config,
+ private IUserManager $ncUserManager,
) {
- parent::__construct($ldap, $accessFactory);
- $this->helper = $helper;
- $this->groupPluginManager = $groupPluginManager;
- $this->config = $config;
- $this->ncUserManager = $ncUserManager;
+ parent::__construct($helper, $ldap, $accessFactory);
}
- protected function setup(): void {
- if ($this->isSetUp) {
- return;
- }
-
- $serverConfigPrefixes = $this->helper->getServerConfigurationPrefixes(true);
- foreach ($serverConfigPrefixes as $configPrefix) {
- $this->backends[$configPrefix] =
- new Group_LDAP($this->getAccess($configPrefix), $this->groupPluginManager, $this->config, $this->ncUserManager);
- if (is_null($this->refBackend)) {
- $this->refBackend = &$this->backends[$configPrefix];
- }
- }
- $this->isSetUp = true;
+ protected function newInstance(string $configPrefix): Group_LDAP {
+ return new Group_LDAP($this->getAccess($configPrefix), $this->groupPluginManager, $this->config, $this->ncUserManager);
}
/**
@@ -162,7 +120,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet
* Get all groups a user belongs to
*
* @param string $uid Name of the user
- * @return string[] with group names
+ * @return list<string> with group names
*
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
@@ -173,9 +131,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet
$groups = [];
foreach ($this->backends as $backend) {
$backendGroups = $backend->getUserGroups($uid);
- if (is_array($backendGroups)) {
- $groups = array_merge($groups, $backendGroups);
- }
+ $groups = array_merge($groups, $backendGroups);
}
return array_values(array_unique($groups));
@@ -273,7 +229,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP, IGet
*/
public function getGroupsDetails(array $gids): array {
if (!($this instanceof IGroupDetailsBackend || $this->implementsActions(GroupInterface::GROUP_DETAILS))) {
- throw new \Exception("Should not have been called");
+ throw new \Exception('Should not have been called');
}
$groupData = [];