diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index acd5353faf..5672c78dc3 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -207,6 +207,7 @@ if ($linkItem) { OCP\Util::addScript('files', 'fileactions'); $tmpl = new OCP\Template('files_sharing', 'public', 'base'); $tmpl->assign('uidOwner', $shareOwner); + $tmpl->assign('displayName', \OCP\User::getDisplayName($shareOwner)); $tmpl->assign('dir', $dir); $tmpl->assign('filename', $file); $tmpl->assign('mimetype', OC_Filesystem::getMimeType($path)); diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index 35cca7c42d..71fca09ed6 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -6,9 +6,9 @@ ownCloud
- t('%s shared the folder %s with you', array($_['uidOwner'], $_['filename'])) ?> + t('%s shared the folder %s with you', array($_['displayName'], $_['filename'])) ?> - t('%s shared the file %s with you', array($_['uidOwner'], $_['filename'])) ?> + t('%s shared the file %s with you', array($_['displayName'], $_['filename'])) ?> Download" />t('Download')?> diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index 6591d1d5fe..4928ad2e27 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -208,6 +208,50 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface { return false; } + /** + * @brief get display name of the user + * @param $uid user ID of the user + * @return display name + */ + public function getDisplayName($uid) { + $cacheKey = 'getDisplayName'.$uid; + if(!is_null($displayName = $this->connection->getFromCache($cacheKey))) { + return $displayName; + } + + $displayName = $this->readAttribute( + $this->username2dn($uid), + $this->connection->ldapUserDisplayName); + + if($displayName && (count($displayName) > 0)) { + $this->connection->writeToCache($cacheKey, $displayName); + return $displayName[0]; + } + + return null; + } + + /** + * @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) { + $cacheKey = 'getDisplayNames-'.$search.'-'.$limit.'-'.$offset; + if(!is_null($displayNames = $this->connection->getFromCache($cacheKey))) { + return $displayNames; + } + + $displayNames = array(); + $users = $this->getUsers($search, $limit, $offset); + foreach ($users as $user) { + $displayNames[$user] = $this->getDisplayName($user); + } + $this->connection->writeToCache($cacheKey, $displayNames); + return $displayNames; + } + /** * @brief Check if backend implements actions * @param $actions bitwise-or'ed actions diff --git a/core/ajax/share.php b/core/ajax/share.php index 077baa8ba5..6704a00c5a 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 $uid => $displayName) { + 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++; } } diff --git a/core/js/share.js b/core/js/share.js index b9b7201dd8..0c45765bd8 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -165,9 +165,9 @@ OC.Share={ var html = '