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
path: root/lib/group
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-01-28 18:47:57 +0400
committerBjörn Schießle <schiessle@owncloud.com>2013-01-28 18:47:57 +0400
commitc00b66fe5bb37403e4dec1ede9d509947b795df0 (patch)
tree5862b29d772e719116c4fb665231a1fd4e3127d5 /lib/group
parente6cc0cd08a502fc426c868bd1981c80eb39a9062 (diff)
implement DisplayNamesInGroup for database back-end
Diffstat (limited to 'lib/group')
-rw-r--r--lib/group/backend.php2
-rw-r--r--lib/group/database.php28
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/group/backend.php b/lib/group/backend.php
index ceb2d9242dd..4f6570c3be3 100644
--- a/lib/group/backend.php
+++ b/lib/group/backend.php
@@ -140,7 +140,7 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
* @param string $search
* @param int $limit
* @param int $offset
- * @return array with display names (key) and user ids (value)
+ * @return array with display names (value) and user ids (key)
*/
public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
$displayNames = '';
diff --git a/lib/group/database.php b/lib/group/database.php
index 6eca98ba019..c5dd402b212 100644
--- a/lib/group/database.php
+++ b/lib/group/database.php
@@ -208,4 +208,32 @@ class OC_Group_Database extends OC_Group_Backend {
}
return $users;
}
+
+ /**
+ * @brief get a list of all display names in a group
+ * @param string $gid
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with display names (value) and user ids (key)
+ */
+ public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
+ $displayNames = '';
+ /*
+
+ SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
+ FROM Persons
+ INNER JOIN Orders
+ ON Persons.P_Id=Orders.P_Id
+ ORDER BY Persons.LastName
+ */
+ $stmt = OC_DB::prepare('SELECT `*PREFIX*users`.`uid`, `*PREFIX*users`.`displayname` FROM `*PREFIX*users` INNER JOIN `*PREFIX*group_user` ON `*PREFIX*group_user`.`uid` = `*PREFIX*users`.`uid` WHERE `gid` = ? AND `*PREFIX*group_user.uid` LIKE ?', $limit, $offset);
+ $result = $stmt->execute(array($gid, $search.'%'));
+ $users = array();
+ while ($row = $result->fetchRow()) {
+ $displayName = trim($row['displayname'], ' ');
+ $displayNames[$row['uid']] = empty($displayName) ? $row['uid'] : $displayName;
+ }
+ return $displayNames;
+ }
}