From 5da9223d1c61257cbccbc762e6a7c28bc06f110b Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 5 Mar 2013 21:22:34 +0100 Subject: make getDisplayNames optional feature for Group Backends, fall back to internal names --- lib/group.php | 8 +++++++- lib/group/backend.php | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/group.php b/lib/group.php index 88f0a2a032c..d1a830730b7 100644 --- a/lib/group.php +++ b/lib/group.php @@ -294,7 +294,13 @@ class OC_Group { public static function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) { $displayNames=array(); foreach(self::$_usedBackends as $backend) { - $displayNames = array_merge($backend->displayNamesInGroup($gid, $search, $limit, $offset), $displayNames); + if($backend->implementsActions(OC_GROUP_BACKEND_GET_DISPLAYNAME)) { + $displayNames = array_merge($backend->displayNamesInGroup($gid, $search, $limit, $offset), $displayNames); + } else { + $users = $backend->usersInGroup($gid, $search, $limit, $offset); + $names = array_combine($users, $users); + $displayNames = array_merge($names, $displayNames); + } } return $displayNames; } diff --git a/lib/group/backend.php b/lib/group/backend.php index 26a784efb28..2e17b5d0b7f 100644 --- a/lib/group/backend.php +++ b/lib/group/backend.php @@ -33,6 +33,7 @@ define('OC_GROUP_BACKEND_CREATE_GROUP', 0x00000001); define('OC_GROUP_BACKEND_DELETE_GROUP', 0x00000010); define('OC_GROUP_BACKEND_ADD_TO_GROUP', 0x00000100); define('OC_GROUP_BACKEND_REMOVE_FROM_GOUP', 0x00001000); +define('OC_GROUP_BACKEND_GET_DISPLAYNAME', 0x00010000); /** * Abstract base class for user management @@ -43,6 +44,7 @@ abstract class OC_Group_Backend implements OC_Group_Interface { OC_GROUP_BACKEND_DELETE_GROUP => 'deleteGroup', OC_GROUP_BACKEND_ADD_TO_GROUP => 'addToGroup', OC_GROUP_BACKEND_REMOVE_FROM_GOUP => 'removeFromGroup', + OC_GROUP_BACKEND_GET_DISPLAYNAME => 'displayNamesInGroup', ); /** -- cgit v1.2.3 From 72c293e834a41f7c0368ead099513deb8388cbc9 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 5 Mar 2013 21:23:58 +0100 Subject: LDAP: implementation of displayNamesInGroup --- apps/user_ldap/group_ldap.php | 17 ++++++++++++++--- apps/user_ldap/group_proxy.php | 16 ++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php index 4fd4c636913..efa5f8b4fe3 100644 --- a/apps/user_ldap/group_ldap.php +++ b/apps/user_ldap/group_ldap.php @@ -209,6 +209,19 @@ class GROUP_LDAP extends lib\Access implements \OCP\GroupInterface { return $groupUsers; } + /** + * @brief get a list of all display names in a group + * @returns array with display names (value) and user ids(key) + */ + public function displayNamesInGroup($gid, $search, $limit, $offset) { + $users = $this->usersInGroup($gid, $search, $limit, $offset); + $displayNames = array(); + foreach($users as $user) { + $displayNames[$user] = \OC_User::getDisplayName($user); + } + return $displayNames; + } + /** * @brief get a list of all groups * @returns array with group names @@ -287,8 +300,6 @@ class GROUP_LDAP extends lib\Access implements \OCP\GroupInterface { * compared with OC_USER_BACKEND_CREATE_USER etc. */ public function implementsActions($actions) { - //always returns false, because possible actions are modifying - // actions. We do not write to LDAP, at least for now. - return false; + return (bool)(OC_GROUP_BACKEND_GET_DISPLAYNAME & $actions); } } diff --git a/apps/user_ldap/group_proxy.php b/apps/user_ldap/group_proxy.php index 5aa1aef0e0e..8f2e34e9b7a 100644 --- a/apps/user_ldap/group_proxy.php +++ b/apps/user_ldap/group_proxy.php @@ -135,6 +135,22 @@ class Group_Proxy extends lib\Proxy implements \OCP\GroupInterface { return $users; } + /** + * @brief get a list of all display names in a group + * @returns array with display names (value) and user ids(key) + */ + public function displayNamesInGroup($gid, $search, $limit, $offset) { + $displayNames = array(); + + foreach($this->backends as $backend) { + $backendUsers = $backend->displayNamesInGroup($gid, $search, $limit, $offset); + if (is_array($backendUsers)) { + $displayNames = array_merge($displayNames, $backendUsers); + } + } + return $displayNames; + } + /** * @brief get a list of all groups * @returns array with group names -- cgit v1.2.3 From b5dc8b9ca364adc301bf8be62061a160d94c22ca Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 5 Mar 2013 21:25:59 +0100 Subject: whitespace --- apps/user_ldap/group_proxy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/user_ldap/group_proxy.php b/apps/user_ldap/group_proxy.php index 8f2e34e9b7a..68d2efe3871 100644 --- a/apps/user_ldap/group_proxy.php +++ b/apps/user_ldap/group_proxy.php @@ -143,7 +143,7 @@ class Group_Proxy extends lib\Proxy implements \OCP\GroupInterface { $displayNames = array(); foreach($this->backends as $backend) { - $backendUsers = $backend->displayNamesInGroup($gid, $search, $limit, $offset); + $backendUsers = $backend->displayNamesInGroup($gid, $search, $limit, $offset); if (is_array($backendUsers)) { $displayNames = array_merge($displayNames, $backendUsers); } -- cgit v1.2.3 From 1e5f8b0e205d01bee32b5db5b9cd20c69c8f467a Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 5 Mar 2013 23:43:22 +0100 Subject: LDAP: fix settings output thus make settings work again --- apps/user_ldap/templates/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php index cd004cec4b3..f44127594c7 100644 --- a/apps/user_ldap/templates/settings.php +++ b/apps/user_ldap/templates/settings.php @@ -14,7 +14,7 @@