mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-28 08:14:25 +02:00
guillermo- path- staff-un-assign-ticket [skip ci]
This commit is contained in:
parent
f94ac300bd
commit
5034ba71a3
@ -1,11 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once 'staff/get.php';
|
require_once 'staff/get.php';
|
||||||
require_once 'staff/assign-ticket.php';
|
require_once 'staff/assign-ticket.php';
|
||||||
|
require_once 'staff/un-assign-ticket.php';
|
||||||
|
|
||||||
$systemControllerGroup = new ControllerGroup();
|
$systemControllerGroup = new ControllerGroup();
|
||||||
$systemControllerGroup->setGroupPath('/staff');
|
$systemControllerGroup->setGroupPath('/staff');
|
||||||
|
|
||||||
$systemControllerGroup->addController(new GetStaffController);
|
$systemControllerGroup->addController(new GetStaffController);
|
||||||
$systemControllerGroup->addController(new AssignStaffController);
|
$systemControllerGroup->addController(new AssignStaffController);
|
||||||
|
$systemControllerGroup->addController(new UnAssignStaffController);
|
||||||
|
|
||||||
$systemControllerGroup->finalize();
|
$systemControllerGroup->finalize();
|
36
server/controllers/staff/un-assign-ticket.php
Normal file
36
server/controllers/staff/un-assign-ticket.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
use Respect\Validation\Validator as DataValidator;
|
||||||
|
DataValidator::with('CustomValidations', true);
|
||||||
|
|
||||||
|
class UnAssignStaffController extends Controller {
|
||||||
|
const PATH = '/un-assign-ticket';
|
||||||
|
|
||||||
|
public function validations() {
|
||||||
|
return [
|
||||||
|
'permission' => 'staff_1',
|
||||||
|
'requestData' => [
|
||||||
|
'ticketNumber' => [
|
||||||
|
'validation' => DataValidator::validTicketNumber(),
|
||||||
|
'error' => ERRORS::INVALID_TICKET
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handler() {
|
||||||
|
$ticketNumber = Controller::request('ticketNumber');
|
||||||
|
$user = Controller::getLoggedUser();
|
||||||
|
$ticket = Ticket::getByTicketNumber($ticketNumber);
|
||||||
|
|
||||||
|
if($ticket->owner->id == $user->id) {
|
||||||
|
$user->sharedTicketList->remove($ticket);
|
||||||
|
$user->store();
|
||||||
|
$ticket->owner = null;
|
||||||
|
$ticket->store();
|
||||||
|
Response::respondSuccess();
|
||||||
|
} else {
|
||||||
|
Response::respondError(ERRORS::NO_PERMISSION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user