diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-12-23 13:57:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-23 13:57:59 +0100 |
commit | c5cc0d87a86725e03b74d0c7377a7e4d7dab846b (patch) | |
tree | 2e20b43222f8ff304a2cb1c2aed0c5e87f01491f /lib | |
parent | c4a594b78bf0f5ad0a6c8414d157cc8e4ff1f28d (diff) | |
parent | 91a1e5fd9d939c69ccacacd44001d52453957093 (diff) | |
download | nextcloud-server-c5cc0d87a86725e03b74d0c7377a7e4d7dab846b.tar.gz nextcloud-server-c5cc0d87a86725e03b74d0c7377a7e4d7dab846b.zip |
Merge pull request #2833 from nextcloud/downstream-26750
Introduce group display name support (#26750)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Group/Backend.php | 15 | ||||
-rw-r--r-- | lib/private/Group/Group.php | 14 | ||||
-rw-r--r-- | lib/private/Group/Manager.php | 16 | ||||
-rw-r--r-- | lib/public/GroupInterface.php | 12 | ||||
-rw-r--r-- | lib/public/IGroup.php | 9 |
5 files changed, 50 insertions, 16 deletions
diff --git a/lib/private/Group/Backend.php b/lib/private/Group/Backend.php index 14c36d93422..1e8d62f5e42 100644 --- a/lib/private/Group/Backend.php +++ b/lib/private/Group/Backend.php @@ -31,23 +31,14 @@ abstract class Backend implements \OCP\GroupInterface { */ const NOT_IMPLEMENTED = -501; - /** - * actions that user backends can define - */ - const CREATE_GROUP = 0x00000001; - const DELETE_GROUP = 0x00000010; - const ADD_TO_GROUP = 0x00000100; - const REMOVE_FROM_GOUP = 0x00001000; - //OBSOLETE const GET_DISPLAYNAME = 0x00010000; - const COUNT_USERS = 0x00100000; - - protected $possibleActions = array( + protected $possibleActions = [ self::CREATE_GROUP => 'createGroup', self::DELETE_GROUP => 'deleteGroup', self::ADD_TO_GROUP => 'addToGroup', self::REMOVE_FROM_GOUP => 'removeFromGroup', self::COUNT_USERS => 'countUsersInGroup', - ); + self::GROUP_DETAILS => 'getGroupDetails', + ]; /** * Get all supported actions diff --git a/lib/private/Group/Group.php b/lib/private/Group/Group.php index 9379d604c48..69dce215694 100644 --- a/lib/private/Group/Group.php +++ b/lib/private/Group/Group.php @@ -31,6 +31,9 @@ namespace OC\Group; use OCP\IGroup; class Group implements IGroup { + /** @var null|string */ + protected $displayName; + /** * @var string $id */ @@ -66,18 +69,27 @@ class Group implements IGroup { * @param \OC\Group\Backend[] $backends * @param \OC\User\Manager $userManager * @param \OC\Hooks\PublicEmitter $emitter + * @param string $displayName */ - public function __construct($gid, $backends, $userManager, $emitter = null) { + public function __construct($gid, $backends, $userManager, $emitter = null, $displayName = null) { $this->gid = $gid; $this->backends = $backends; $this->userManager = $userManager; $this->emitter = $emitter; + $this->displayName = $displayName; } public function getGID() { return $this->gid; } + public function getDisplayName() { + if (is_null($this->displayName)) { + return $this->gid; + } + return $this->displayName; + } + /** * get all users in the group * diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php index 31911138985..944598a8296 100644 --- a/lib/private/Group/Manager.php +++ b/lib/private/Group/Manager.php @@ -155,19 +155,29 @@ class Manager extends PublicEmitter implements IGroupManager { /** * @param string $gid + * @param string $displayName * @return \OCP\IGroup */ - protected function getGroupObject($gid) { + protected function getGroupObject($gid, $displayName = null) { $backends = array(); foreach ($this->backends as $backend) { - if ($backend->groupExists($gid)) { + if ($backend->implementsActions(\OC\Group\Backend::GROUP_DETAILS)) { + $groupData = $backend->getGroupDetails($gid); + if (is_array($groupData)) { + // take the display name from the first backend that has a non-null one + if (is_null($displayName) && isset($groupData['displayName'])) { + $displayName = $groupData['displayName']; + } + $backends[] = $backend; + } + } else if ($backend->groupExists($gid)) { $backends[] = $backend; } } if (count($backends) === 0) { return null; } - $this->cachedGroups[$gid] = new Group($gid, $backends, $this->userManager, $this); + $this->cachedGroups[$gid] = new Group($gid, $backends, $this->userManager, $this, $displayName); return $this->cachedGroups[$gid]; } diff --git a/lib/public/GroupInterface.php b/lib/public/GroupInterface.php index 6f456f51fd7..97837e50b16 100644 --- a/lib/public/GroupInterface.php +++ b/lib/public/GroupInterface.php @@ -41,6 +41,18 @@ namespace OCP; interface GroupInterface { /** + * actions that user backends can define + */ + const CREATE_GROUP = 0x00000001; + const DELETE_GROUP = 0x00000010; + const ADD_TO_GROUP = 0x00000100; + const REMOVE_FROM_GOUP = 0x00001000; // oops + const REMOVE_FROM_GROUP = 0x00001000; + //OBSOLETE const GET_DISPLAYNAME = 0x00010000; + const COUNT_USERS = 0x00100000; + const GROUP_DETAILS = 0x01000000; + + /** * Check if backend implements actions * @param int $actions bitwise-or'ed actions * @return boolean diff --git a/lib/public/IGroup.php b/lib/public/IGroup.php index d5fcbcc5cd9..0cc62e9a8ed 100644 --- a/lib/public/IGroup.php +++ b/lib/public/IGroup.php @@ -4,6 +4,7 @@ * * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <robin@icewind.nl> + * @author Vincent Petry <PVince81@owncloud.com> * * @license AGPL-3.0 * @@ -37,6 +38,14 @@ interface IGroup { public function getGID(); /** + * Returns the group display name + * + * @return string + * @since 9.2 + */ + public function getDisplayName(); + + /** * get all users in the group * * @return \OCP\IUser[] |