2016-11-30 18:13:57 +01:00
|
|
|
<?php
|
|
|
|
use Respect\Validation\Validator as DataValidator;
|
|
|
|
DataValidator::with('CustomValidations', true);
|
|
|
|
|
2017-04-16 07:35:04 +02:00
|
|
|
/**
|
2017-05-12 06:58:40 +02:00
|
|
|
* @api {post} /user/get-user Get user information
|
2021-10-19 03:06:20 +02:00
|
|
|
* @apiVersion 4.10.0
|
2017-04-16 07:35:04 +02:00
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @apiName Get user information
|
2017-04-16 07:35:04 +02:00
|
|
|
*
|
|
|
|
* @apiGroup User
|
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @apiDescription This path retrieves information about a specific user.
|
2017-04-16 07:35:04 +02:00
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @apiPermission staff1
|
2017-04-16 07:35:04 +02:00
|
|
|
*
|
2017-04-21 08:09:24 +02:00
|
|
|
* @apiParam {String} userId The id of the user to find information of.
|
2017-04-16 07:35:04 +02:00
|
|
|
*
|
2017-04-21 08:09:24 +02:00
|
|
|
* @apiUse NO_PERMISSION
|
|
|
|
* @apiUse INVALID_USER
|
2017-04-16 07:35:04 +02:00
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @apiSuccess {Object} data Information about an user
|
2017-04-22 03:33:17 +02:00
|
|
|
* @apiSuccess {String} data.name Name of the user
|
|
|
|
* @apiSuccess {String} data.email Email of the user
|
|
|
|
* @apiSuccess {Number} data.signupDate Date of signup of the user
|
|
|
|
* @apiSuccess {Boolean} data.verified Indicates if the user is verified
|
2017-04-16 07:35:04 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-11-30 21:30:00 +01:00
|
|
|
class GetUserByIdController extends Controller {
|
2016-11-30 18:13:57 +01:00
|
|
|
const PATH = '/get-user';
|
2017-02-08 19:09:15 +01:00
|
|
|
const METHOD = 'POST';
|
|
|
|
|
2016-11-30 18:13:57 +01:00
|
|
|
public function validations() {
|
|
|
|
return [
|
2016-12-14 01:10:49 +01:00
|
|
|
'permission' => 'staff_1',
|
2016-11-30 18:13:57 +01:00
|
|
|
'requestData' => [
|
|
|
|
'userId' => [
|
|
|
|
'validation' => DataValidator::dataStoreId('user'),
|
|
|
|
'error' => ERRORS::INVALID_USER
|
|
|
|
]
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handler() {
|
|
|
|
$userId = Controller::request('userId');
|
|
|
|
$user = User::getDataStore($userId);
|
2016-12-14 01:10:49 +01:00
|
|
|
$staff = Controller::getLoggedUser();
|
2018-09-28 00:46:30 +02:00
|
|
|
|
2016-11-30 18:13:57 +01:00
|
|
|
Response::respondSuccess([
|
|
|
|
'name' => $user->name,
|
|
|
|
'email' => $user->email,
|
|
|
|
'signupDate' => $user->signupDate,
|
2018-09-28 00:46:30 +02:00
|
|
|
'verified' => !$user->verificationToken,
|
2019-02-03 20:47:29 +01:00
|
|
|
'disabled' => !!$user->disabled,
|
|
|
|
'customfields' => $user->xownCustomfieldvalueList->toArray(),
|
2020-07-21 11:52:34 +02:00
|
|
|
'userList' => $user->supervisedrelation ? $user->supervisedrelation->sharedUserList->toArray() : []
|
2016-11-30 18:13:57 +01:00
|
|
|
]);
|
|
|
|
}
|
2018-09-28 00:46:30 +02:00
|
|
|
}
|