diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-11-30 20:21:44 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2016-12-22 18:34:45 +0100 |
commit | 453f3beffaf629efa5c715f7ca88b5c0a1034af8 (patch) | |
tree | 68dce83e8613a7dd8321d53567a8f745c46d8266 /lib/private/Group | |
parent | 7130fa7b4cddd35e9275f7453593049c1e989562 (diff) | |
download | nextcloud-server-453f3beffaf629efa5c715f7ca88b5c0a1034af8.tar.gz nextcloud-server-453f3beffaf629efa5c715f7ca88b5c0a1034af8.zip |
Adding group display name support
Diffstat (limited to 'lib/private/Group')
-rw-r--r-- | lib/private/Group/Backend.php | 15 | ||||
-rw-r--r-- | lib/private/Group/Group.php | 11 | ||||
-rw-r--r-- | lib/private/Group/Manager.php | 16 |
3 files changed, 26 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..bb85445f541 100644 --- a/lib/private/Group/Group.php +++ b/lib/private/Group/Group.php @@ -66,18 +66,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]; } |