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/user
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-01-28 18:07:31 +0400
committerBjörn Schießle <schiessle@owncloud.com>2013-01-28 18:07:31 +0400
commite6cc0cd08a502fc426c868bd1981c80eb39a9062 (patch)
treeb873c857024319bebcedab3449428900f2ae8c51 /lib/user
parent3e0d117d6078703b46e73c6f5642f1945857da17 (diff)
implement display names for the database back-end
Diffstat (limited to 'lib/user')
-rw-r--r--lib/user/database.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/user/database.php b/lib/user/database.php
index 49c76545327..52f11a5e29d 100644
--- a/lib/user/database.php
+++ b/lib/user/database.php
@@ -129,6 +129,40 @@ class OC_User_Database extends OC_User_Backend {
}
}
+ /**
+ * @brief get display name of the user
+ * @param $uid user ID of the user
+ * @return display name
+ */
+ public function getDisplayName($uid) {
+ if( $this->userExists($uid) ) {
+ $query = OC_DB::prepare( 'SELECT displayname FROM `*PREFIX*users` WHERE `uid` = ?' );
+ $result = $query->execute( array( $uid ))->fetchAll();
+ if (!empty($result[0]['displayname'])) {
+ return $result[0]['displayname'];
+ } else {
+ return $uid;
+ }
+ }
+ }
+
+ /**
+ * @brief Get a list of all display names
+ * @returns array with all displayNames (value) and the correspondig uids (key)
+ *
+ * Get a list of all display names and user ids.
+ */
+ public function getDisplayNames($search = '', $limit = null, $offset = null) {
+ $displayNames = array();
+ $query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`uid`) LIKE LOWER(?)', $limit, $offset);
+ $result = $query->execute(array($search.'%'));
+ $users = array();
+ while ($row = $result->fetchRow()) {
+ $displayNames[$row['uid']] = $row['displayname'];
+ }
+ return $displayNames;
+ }
+
/**
* @brief Check if the password is correct
* @param $uid The username