2016-09-25 06:16:10 +02:00
|
|
|
<?php
|
|
|
|
use Respect\Validation\Validator as DataValidator;
|
|
|
|
DataValidator::with('CustomValidations', true);
|
|
|
|
|
2017-04-18 06:39:55 +02:00
|
|
|
/**
|
2017-05-12 06:58:40 +02:00
|
|
|
* @api {post} /staff/get Get staff
|
2020-06-17 02:26:04 +02:00
|
|
|
* @apiVersion 4.7.0
|
2017-04-18 06:39:55 +02:00
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @apiName Get staff
|
2017-04-18 06:39:55 +02:00
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @apiGroup Staff
|
2017-04-18 06:39:55 +02:00
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @apiDescription This path retrieves information about a staff member.
|
2017-04-18 06:39:55 +02:00
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @apiPermission staff1
|
2017-04-18 06:39:55 +02:00
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @apiParam {Number} staffId The id of the staff member to be searched.
|
2018-11-16 00:51:44 +01:00
|
|
|
*
|
2017-04-21 08:09:24 +02:00
|
|
|
* @apiUse NO_PERMISSION
|
2017-04-18 06:39:55 +02:00
|
|
|
*
|
2017-04-22 03:33:17 +02:00
|
|
|
* @apiSuccess {Object} data Information about a staff member
|
2017-06-28 15:02:54 +02:00
|
|
|
* @apiSuccess {String} data.name Name of the staff member
|
|
|
|
* @apiSuccess {String} data.email Elmail of the staff member
|
|
|
|
* @apiSuccess {String} data.profilePic Profile pic filename of staff member
|
|
|
|
* @apiSuccess {Number} data.level Level of staff member
|
|
|
|
* @apiSuccess {Boolean} data.staff Indicates that it is a staff (always true)
|
2017-04-22 03:33:17 +02:00
|
|
|
* @apiSuccess {[Department](#api-Data_Structures-ObjectDepartment)[]} data.departments Array of departments that has assigned.
|
|
|
|
* @apiSuccess {[Ticket](#api-Data_Structures-ObjectTicket)[]} data.tickets Array of tickets that has assigned.
|
2017-06-28 15:02:54 +02:00
|
|
|
* @apiSuccess {Boolean} data.sendEmailOnNewTicket Indicates if this member receives a mail when a ticket is created.
|
2017-04-18 06:39:55 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-09-25 06:16:10 +02:00
|
|
|
class GetStaffController extends Controller {
|
|
|
|
const PATH = '/get';
|
2017-02-08 19:09:15 +01:00
|
|
|
const METHOD = 'POST';
|
2016-09-25 06:16:10 +02:00
|
|
|
|
|
|
|
public function validations() {
|
|
|
|
return [
|
|
|
|
'permission' => 'staff_1',
|
|
|
|
'requestData' => []
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handler() {
|
|
|
|
$user = Controller::getLoggedUser();
|
2016-12-06 05:32:00 +01:00
|
|
|
|
2016-12-08 07:21:37 +01:00
|
|
|
$userId = Controller::request('staffId');
|
|
|
|
$userRow = Staff::getDataStore($userId);
|
2016-12-06 05:32:00 +01:00
|
|
|
|
|
|
|
if($user->level == 3 && !$userRow->isNull()) {
|
2016-12-08 07:21:37 +01:00
|
|
|
$user = $userRow;
|
2016-12-06 05:32:00 +01:00
|
|
|
}
|
|
|
|
|
2016-09-25 06:16:10 +02:00
|
|
|
$parsedDepartmentList = [];
|
|
|
|
$departmentList = $user->sharedDepartmentList;
|
|
|
|
|
|
|
|
foreach($departmentList as $department) {
|
|
|
|
$parsedDepartmentList[] = [
|
|
|
|
'id' => $department->id,
|
2018-11-16 00:51:44 +01:00
|
|
|
'name' => $department->name,
|
|
|
|
'private' => $department->private
|
2016-09-25 06:16:10 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
Response::respondSuccess([
|
|
|
|
'name' => $user->name,
|
|
|
|
'email' => $user->email,
|
|
|
|
'profilePic' => $user->profilePic,
|
|
|
|
'level' => $user->level,
|
|
|
|
'staff' => true,
|
2016-12-12 05:46:50 +01:00
|
|
|
'departments' => $parsedDepartmentList,
|
2019-02-03 20:47:29 +01:00
|
|
|
'tickets' => $user->sharedTicketList->toArray(true),
|
2017-06-26 00:03:56 +02:00
|
|
|
'sendEmailOnNewTicket' => $user->sendEmailOnNewTicket
|
2016-09-25 06:16:10 +02:00
|
|
|
]);
|
|
|
|
}
|
2018-11-16 00:51:44 +01:00
|
|
|
}
|