summaryrefslogtreecommitdiffstats
path: root/core/user
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-08-22 18:16:55 +0200
committerJörn Friedrich Dreyer <jfd@butonic.de>2014-08-25 11:50:19 +0200
commitf33312f76773a46acf084dd93830c739e44e9962 (patch)
tree4caa766b1d11ac1087b81f2d648f59f92194c1a1 /core/user
parent6202ef3258c7db707f32c0bcaa17552b92fa15eb (diff)
downloadnextcloud-server-f33312f76773a46acf084dd93830c739e44e9962.tar.gz
nextcloud-server-f33312f76773a46acf084dd93830c739e44e9962.zip
Use AppFramework instead of custom controller
Diffstat (limited to 'core/user')
-rw-r--r--core/user/controller.php31
-rw-r--r--core/user/usercontroller.php66
2 files changed, 66 insertions, 31 deletions
diff --git a/core/user/controller.php b/core/user/controller.php
deleted file mode 100644
index cbcbd936183..00000000000
--- a/core/user/controller.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?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));
- }
-}
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);
+
+ }
+}