mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-30 01:05:18 +02:00
Ivan - Add delete custom response [skip ci]
This commit is contained in:
parent
01c1c6bfd6
commit
6083c8731d
@ -3,6 +3,7 @@ include 'ticket/create.php';
|
||||
include 'ticket/comment.php';
|
||||
include 'ticket/get.php';
|
||||
include 'ticket/add-custom-response.php';
|
||||
include 'ticket/delete-custom-response.php';
|
||||
include 'ticket/edit-custom-response.php';
|
||||
include 'ticket/get-custom-responses.php';
|
||||
|
||||
@ -13,6 +14,7 @@ $ticketControllers->addController(new CreateController);
|
||||
$ticketControllers->addController(new CommentController);
|
||||
$ticketControllers->addController(new TicketGetController);
|
||||
$ticketControllers->addController(new AddCustomResponseController);
|
||||
$ticketControllers->addController(new DeleteCustomResponseController);
|
||||
$ticketControllers->addController(new EditCustomResponseController);
|
||||
$ticketControllers->addController(new GetCustomResponsesController);
|
||||
|
||||
|
26
server/controllers/ticket/delete-custom-response.php
Normal file
26
server/controllers/ticket/delete-custom-response.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
use Respect\Validation\Validator as DataValidator;
|
||||
DataValidator::with('CustomValidations', true);
|
||||
|
||||
class DeleteCustomResponseController extends Controller {
|
||||
const PATH = '/delete-custom-response';
|
||||
|
||||
public function validations() {
|
||||
return [
|
||||
'permission' => 'staff_2',
|
||||
'requestData' => [
|
||||
'id' => [
|
||||
'validation' => DataValidator::dataStoreId('customresponse'),
|
||||
'error' => ERRORS::INVALID_NAME
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function handler() {
|
||||
$customResponse = CustomResponse::getDataStore(Controller::request('id'));
|
||||
$customResponse->trash();
|
||||
|
||||
Response::respondSuccess();
|
||||
}
|
||||
}
|
@ -120,6 +120,10 @@ abstract class DataStore {
|
||||
return RedBean::store($this->getBeanInstance());
|
||||
}
|
||||
|
||||
public function trash() {
|
||||
RedBean::trash($this->getBeanInstance());
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
RedBean::trash($this->getBeanInstance());
|
||||
unset($this);
|
||||
|
@ -53,4 +53,18 @@ describe 'CustomResponses' do
|
||||
(result['data'][0]['language']).should.equal('en')
|
||||
end
|
||||
end
|
||||
|
||||
describe '/ticket/delete-custom-responses/' do
|
||||
it 'should delete custom response' do
|
||||
result = request('/ticket/delete-custom-response', {
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token,
|
||||
id: 1
|
||||
})
|
||||
|
||||
(result['status']).should.equal('success')
|
||||
customResponse = $database.getRow('customresponse', 1)
|
||||
(customResponse).should.equal(nil)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user