aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2015-10-08 21:47:30 +0200
committerRoeland Jago Douma <rullzer@owncloud.com>2015-10-13 21:07:48 +0200
commit002e9c76cdfa805c798ff9f9543df17ae7fa4232 (patch)
tree3c13a17fcba5d6be468905b1ff1f4914e48b438c
parentef4278cfa9570b3910b35cc82313d6391aec3c22 (diff)
downloadnextcloud-server-002e9c76cdfa805c798ff9f9543df17ae7fa4232.tar.gz
nextcloud-server-002e9c76cdfa805c798ff9f9543df17ae7fa4232.zip
Combine OCS API getUser method code into provisioning_api app
Fixes #13002 Move the cloud/users/{userid} code in total to the provisioning API.
-rw-r--r--apps/provisioning_api/lib/users.php37
-rw-r--r--lib/private/ocs/cloud.php46
-rw-r--r--ocs/routes.php7
3 files changed, 10 insertions, 80 deletions
diff --git a/apps/provisioning_api/lib/users.php b/apps/provisioning_api/lib/users.php
index add6325bde0..fc5e79d4b2b 100644
--- a/apps/provisioning_api/lib/users.php
+++ b/apps/provisioning_api/lib/users.php
@@ -115,46 +115,28 @@ class Users {
return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
}
+ $data = [];
+
// Admin? Or SubAdmin?
if($this->groupManager->isAdmin($user->getUID()) || OC_SubAdmin::isUserAccessible($user->getUID(), $userId)) {
// Check they exist
if(!$this->userManager->userExists($userId)) {
return new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, 'The requested user could not be found');
}
- // Show all
- $return = [
- 'email',
- 'enabled',
- ];
- if($user->getUID() !== $userId) {
- $return[] = 'quota';
- }
+ $data['enabled'] = $this->config->getUserValue($userId, 'core', 'enabled', 'true');
} else {
// Check they are looking up themselves
if($user->getUID() !== $userId) {
return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
}
- // Return some additional information compared to the core route
- $return = array(
- 'email',
- 'displayname',
- );
}
// Find the data
- $data = [];
- $data = self::fillStorageInfo($userId, $data);
- $data['enabled'] = $this->config->getUserValue($userId, 'core', 'enabled', 'true');
+ $data['quota'] = self::fillStorageInfo($userId);
$data['email'] = $this->config->getUserValue($userId, 'settings', 'email');
- $data['displayname'] = $this->userManager->get($parameters['userid'])->getDisplayName();
+ $data['displayname'] = $this->userManager->get($userId)->getDisplayName();
- // Return the appropriate data
- $responseData = array();
- foreach($return as $key) {
- $responseData[$key] = $data[$key];
- }
-
- return new OC_OCS_Result($responseData);
+ return new OC_OCS_Result($data);
}
/**
@@ -473,19 +455,20 @@ class Users {
* @return mixed
* @throws \OCP\Files\NotFoundException
*/
- private static function fillStorageInfo($userId, $data) {
+ private static function fillStorageInfo($userId) {
+ $data = [];
try {
\OC_Util::tearDownFS();
\OC_Util::setupFS($userId);
$storage = OC_Helper::getStorageInfo('/');
- $data['quota'] = [
+ $data = [
'free' => $storage['free'],
'used' => $storage['used'],
'total' => $storage['total'],
'relative' => $storage['relative'],
];
} catch (NotFoundException $ex) {
- $data['quota'] = [];
+ $data = [];
}
return $data;
}
diff --git a/lib/private/ocs/cloud.php b/lib/private/ocs/cloud.php
index 8f4f1769e9c..441e53400a3 100644
--- a/lib/private/ocs/cloud.php
+++ b/lib/private/ocs/cloud.php
@@ -42,52 +42,6 @@ class OC_OCS_Cloud {
return new OC_OCS_Result($result);
}
- /**
- * gets user info
- *
- * exposes the quota of an user:
- * <data>
- * <quota>
- * <free>1234</free>
- * <used>4321</used>
- * <total>5555</total>
- * <ralative>0.78</ralative>
- * </quota>
- * </data>
- *
- * @param array $parameters should contain parameter 'userid' which identifies
- * the user from whom the information will be returned
- */
- public static function getUser($parameters) {
- $return = array();
- // Check if they are viewing information on themselves
- if($parameters['userid'] === OC_User::getUser()) {
- // Self lookup
- $storage = OC_Helper::getStorageInfo('/');
- $return['quota'] = array(
- 'free' => $storage['free'],
- 'used' => $storage['used'],
- 'total' => $storage['total'],
- 'relative' => $storage['relative'],
- );
- }
- if(OC_User::isAdminUser(OC_User::getUser())
- || OC_Subadmin::isUserAccessible(OC_User::getUser(), $parameters['userid'])) {
- if(OC_User::userExists($parameters['userid'])) {
- // Is an admin/subadmin so can see display name
- $return['displayname'] = OC_User::getDisplayName($parameters['userid']);
- } else {
- return new OC_OCS_Result(null, 101);
- }
- }
- if(count($return)) {
- return new OC_OCS_Result($return);
- } else {
- // No permission to view this user data
- return new OC_OCS_Result(null, 997);
- }
- }
-
public static function getCurrentUser() {
$email=\OC::$server->getConfig()->getUserValue(OC_User::getUser(), 'settings', 'email', '');
$data = array(
diff --git a/ocs/routes.php b/ocs/routes.php
index 1722180c201..4aaa1434b8b 100644
--- a/ocs/routes.php
+++ b/ocs/routes.php
@@ -91,13 +91,6 @@ API::register(
);
API::register(
'get',
- '/cloud/users/{userid}',
- array('OC_OCS_Cloud', 'getUser'),
- 'core',
- API::USER_AUTH
-);
-API::register(
- 'get',
'/cloud/user',
array('OC_OCS_Cloud', 'getCurrentUser'),
'core',