diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-08-22 16:06:46 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2015-04-23 14:23:03 +0200 |
commit | 79187fcb102595d292c9acbd6b68a457bb3fc047 (patch) | |
tree | ca958e120781ab6f62f3a3133e5ce4f59d058ceb /core | |
parent | e72cd711ad63f45b35272efeafe83b30445a1ea0 (diff) | |
download | nextcloud-server-79187fcb102595d292c9acbd6b68a457bb3fc047.tar.gz nextcloud-server-79187fcb102595d292c9acbd6b68a457bb3fc047.zip |
add lookup route for displaynames
Diffstat (limited to 'core')
-rw-r--r-- | core/routes.php | 4 | ||||
-rw-r--r-- | core/user/controller.php | 31 |
2 files changed, 35 insertions, 0 deletions
diff --git a/core/routes.php b/core/routes.php index c8fda2ee3dc..9f305bb43ce 100644 --- a/core/routes.php +++ b/core/routes.php @@ -32,6 +32,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 index 00000000000..cbcbd936183 --- /dev/null +++ b/core/user/controller.php @@ -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)); + } +} |