From e9a57e28fc9b87c0fd84de39a0e4cb305165a9d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= <schiessle@owncloud.com>
Date: Fri, 25 Jan 2013 13:57:08 +0100
Subject: [PATCH] show display name instead of uid

---
 core/ajax/share.php | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/core/ajax/share.php b/core/ajax/share.php
index 077baa8ba5..231cdc5e24 100644
--- a/core/ajax/share.php
+++ b/core/ajax/share.php
@@ -72,6 +72,7 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
 		case 'email':
 			// read post variables
 			$user = OCP\USER::getUser();
+			$displayName = OCP\User::getDisplayName();
 			$type = $_POST['itemType'];
 			$link = $_POST['link'];
 			$file = $_POST['file'];
@@ -81,13 +82,13 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
 			$l = OC_L10N::get('core');
 
 			// setup the email
-			$subject = (string)$l->t('User %s shared a file with you', $user);
+			$subject = (string)$l->t('User %s shared a file with you', $displayName);
 			if ($type === 'dir')
-				$subject = (string)$l->t('User %s shared a folder with you', $user);
+				$subject = (string)$l->t('User %s shared a folder with you', $displayName);
 
-			$text = (string)$l->t('User %s shared the file "%s" with you. It is available for download here: %s', array($user, $file, $link));
+			$text = (string)$l->t('User %s shared the file "%s" with you. It is available for download here: %s', array($displayName, $file, $link));
 			if ($type === 'dir')
-				$text = (string)$l->t('User %s shared the folder "%s" with you. It is available for download here: %s', array($user, $file, $link));
+				$text = (string)$l->t('User %s shared the folder "%s" with you. It is available for download here: %s', array($displayName, $file, $link));
 
 
 			$default_from = OCP\Util::getDefaultEmailAddress('sharing-noreply');
@@ -158,14 +159,14 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
 				while ($count < 4 && count($users) == $limit) {
 					$limit = 4 - $count;
 					if ($sharePolicy == 'groups_only') {
-						$users = OC_Group::usersInGroups($groups, $_GET['search'], $limit, $offset);
+						$users = OC_Group::DisplayNamesInGroups($groups, $_GET['search'], $limit, $offset);
 					} else {
-						$users = OC_User::getUsers($_GET['search'], $limit, $offset);
+						$users = OC_User::getDisplayNames($_GET['search'], $limit, $offset);
 					}
 					$offset += $limit;
-					foreach ($users as $user) {
-						if ((!isset($_GET['itemShares']) || !is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_USER]) || !in_array($user, $_GET['itemShares'][OCP\Share::SHARE_TYPE_USER])) && $user != OC_User::getUser()) {
-							$shareWith[] = array('label' => $user, 'value' => array('shareType' => OCP\Share::SHARE_TYPE_USER, 'shareWith' => $user));
+					foreach ($users as $displayName => $uid) {
+						if ((!isset($_GET['itemShares']) || !is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_USER]) || !in_array($uid, $_GET['itemShares'][OCP\Share::SHARE_TYPE_USER])) && $uid != OC_User::getUser()) {
+							$shareWith[] = array('label' => $displayName, 'value' => array('shareType' => OCP\Share::SHARE_TYPE_USER, 'shareWith' => $uid));
 							$count++;
 						}
 					}
-- 
GitLab