Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/jsxc.nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'build/ajax/getUsers.php')
-rw-r--r--build/ajax/getUsers.php25
1 files changed, 23 insertions, 2 deletions
diff --git a/build/ajax/getUsers.php b/build/ajax/getUsers.php
index 1c4b258..5b5790b 100644
--- a/build/ajax/getUsers.php
+++ b/build/ajax/getUsers.php
@@ -8,6 +8,27 @@ header('Content-Type: application/json; charset=utf-8');
$limit = 10;
$offset = 0;
-$users = OCP\User::getDisplayNames((string) $_GET['search'], $limit, $offset);
+$config = \OC::$server->getConfig();
+$preferMail = $config->getAppValue('ojsxc', 'xmppPreferMail');
+$preferMail = $preferMail === true || $preferMail === 'true';
-echo json_encode($users);
+$userManager = \OC::$server->getUserManager();
+$users = $userManager->searchDisplayName((string) $_GET['search'], $limit, $offset);
+$response = array();
+
+foreach($users as $user) {
+ $uid = $user->getUID();
+ $index = $uid;
+
+ if ($preferMail) {
+ $mail = OCP\Config::getUserValue($uid, 'settings', 'email');
+
+ if (!empty($mail)) {
+ $index = $mail;
+ }
+ }
+
+ $response[$index] = $user->getDisplayName();
+}
+
+echo json_encode($response);