diff options
author | Björn Schießle <schiessle@owncloud.com> | 2013-01-28 15:07:31 +0100 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2013-01-28 15:07:31 +0100 |
commit | e6cc0cd08a502fc426c868bd1981c80eb39a9062 (patch) | |
tree | b873c857024319bebcedab3449428900f2ae8c51 /lib/user | |
parent | 3e0d117d6078703b46e73c6f5642f1945857da17 (diff) | |
download | nextcloud-server-e6cc0cd08a502fc426c868bd1981c80eb39a9062.tar.gz nextcloud-server-e6cc0cd08a502fc426c868bd1981c80eb39a9062.zip |
implement display names for the database back-end
Diffstat (limited to 'lib/user')
-rw-r--r-- | lib/user/database.php | 34 |
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 |