]> source.dussan.org Git - nextcloud-server.git/commitdiff
add lookup route for displaynames
authorJörn Friedrich Dreyer <jfd@butonic.de>
Fri, 22 Aug 2014 14:06:46 +0000 (16:06 +0200)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Mon, 25 Aug 2014 09:50:19 +0000 (11:50 +0200)
core/routes.php
core/user/controller.php [new file with mode: 0644]

index ff79c450508a0303a74c02ce40d7596502cbf7e1..37eb2f8a56cc29eaf4e1f5713468df27211accbb 100644 (file)
@@ -35,6 +35,10 @@ $this->create('core_ajax_share', '/core/ajax/share.php')
 // Translations
 $this->create('core_ajax_translations', '/core/ajax/translations.php')
        ->actionInclude('core/ajax/translations.php');
+// User display names
+$this->create('core_user_displaynames', '/displaynames')
+       ->get()
+       ->action('OC\Core\User\Controller', 'getDisplayNames');
 // Tags
 $this->create('core_tags_tags', '/tags/{type}')
        ->get()
diff --git a/core/user/controller.php b/core/user/controller.php
new file mode 100644 (file)
index 0000000..cbcbd93
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Copyright (c) 2014 Jörn Dreyer <jfd@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Core\User;
+
+class Controller {
+       public static function getDisplayNames($args) {
+               \OC_JSON::checkLoggedIn();
+               \OC_JSON::callCheck();
+
+               $users = $_GET['users'];
+               $result = array();
+               $userManager = \OC::$server->getUserManager();
+
+               foreach ($users as $user) {
+                       $userObject = $userManager->get($user);
+                       if (is_object($userObject)) {
+                               $result[$user] = $userObject->getDisplayName();
+                       } else {
+                               $result[$user] = false;
+                       }
+               }
+
+               \OC_JSON::success(array('users'=>$result));
+       }
+}