summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorblizzz <blizzz@owncloud.com>2014-08-28 13:39:21 +0200
committerblizzz <blizzz@owncloud.com>2014-08-28 13:39:21 +0200
commit6fa609325ccbe95c6d4c4b5ece3ea0bfe91cb552 (patch)
tree0c854b31413b03944dce3a1b6f23270b49c3fc2f /core
parent1c0cc6c7bcf0125aa1af9298e846d0c740c1a7c4 (diff)
parentf33312f76773a46acf084dd93830c739e44e9962 (diff)
downloadnextcloud-server-6fa609325ccbe95c6d4c4b5ece3ea0bfe91cb552.tar.gz
nextcloud-server-6fa609325ccbe95c6d4c4b5ece3ea0bfe91cb552.zip
Merge pull request #8507 from owncloud/ajaxify_user_list_for_files_external
Ajaxify user list for files external
Diffstat (limited to 'core')
-rw-r--r--core/application.php (renamed from core/lostpassword/application.php)11
-rw-r--r--core/routes.php3
-rw-r--r--core/user/usercontroller.php66
3 files changed, 78 insertions, 2 deletions
diff --git a/core/lostpassword/application.php b/core/application.php
index ba2f3fc633b..33801847758 100644
--- a/core/lostpassword/application.php
+++ b/core/application.php
@@ -8,10 +8,11 @@
* See the COPYING-README file.
*/
-namespace OC\Core\LostPassword;
+namespace OC\Core;
use \OCP\AppFramework\App;
use OC\Core\LostPassword\Controller\LostController;
+use OC\Core\User\UserController;
class Application extends App {
@@ -38,6 +39,14 @@ class Application extends App {
\OC_App::isEnabled('files_encryption')
);
});
+ $container->registerService('UserController', function($c) {
+ return new UserController(
+ $c->query('AppName'),
+ $c->query('Request'),
+ $c->query('ServerContainer')->getUserManager(),
+ new \OC_Defaults()
+ );
+ });
}
diff --git a/core/routes.php b/core/routes.php
index ff79c450508..28a3680dd91 100644
--- a/core/routes.php
+++ b/core/routes.php
@@ -6,13 +6,14 @@
* See the COPYING-README file.
*/
-use OC\Core\LostPassword\Application;
+use OC\Core\Application;
$application = new Application();
$application->registerRoutes($this, array('routes' => array(
array('name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'),
array('name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'),
array('name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'),
+ array('name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'),
)
));
diff --git a/core/user/usercontroller.php b/core/user/usercontroller.php
new file mode 100644
index 00000000000..2570e3b5b05
--- /dev/null
+++ b/core/user/usercontroller.php
@@ -0,0 +1,66 @@
+<?php
+/**
+ * Copyright (c) 2014 Jörn Dreyer <jfd@owncloud.com>
+ * Copyright (c) 2014 Lukas Reschke <lukas@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;
+
+use \OCP\AppFramework\Controller;
+use \OCP\AppFramework\Http\JSONResponse;
+use \OCP\IRequest;
+
+class UserController extends Controller {
+ /**
+ * @var \OCP\IUserManager
+ */
+ protected $userManager;
+
+ /**
+ * @var \OC_Defaults
+ */
+ protected $defaults;
+
+ public function __construct($appName,
+ IRequest $request,
+ $userManager,
+ $defaults
+ ) {
+ parent::__construct($appName, $request);
+ $this->userManager = $userManager;
+ $this->defaults = $defaults;
+ }
+
+ /**
+ * Lookup user display names
+ *
+ * @NoAdminRequired
+ *
+ * @param array $users
+ *
+ * @return JSONResponse
+ */
+ public function getDisplayNames($users) {
+ $result = array();
+
+ foreach ($users as $user) {
+ $userObject = $this->userManager->get($user);
+ if (is_object($userObject)) {
+ $result[$user] = $userObject->getDisplayName();
+ } else {
+ $result[$user] = $user;
+ }
+ }
+
+ $json = array(
+ 'users' => $result,
+ 'status' => 'success'
+ );
+
+ return new JSONResponse($json);
+
+ }
+}