All main staff calendar endpoints moved
This commit is contained in:
parent
c4b79a722c
commit
3d73b9a4b2
@ -3,10 +3,8 @@
|
|||||||
namespace BusinessLogic\Calendar;
|
namespace BusinessLogic\Calendar;
|
||||||
|
|
||||||
|
|
||||||
use BusinessLogic\Exceptions\ApiFriendlyException;
|
|
||||||
use BusinessLogic\Security\UserContext;
|
use BusinessLogic\Security\UserContext;
|
||||||
use DataAccess\Calendar\CalendarGateway;
|
use DataAccess\Calendar\CalendarGateway;
|
||||||
use PHPUnit\Runner\Exception;
|
|
||||||
|
|
||||||
class CalendarHandler extends \BaseClass {
|
class CalendarHandler extends \BaseClass {
|
||||||
private $calendarGateway;
|
private $calendarGateway;
|
||||||
@ -58,4 +56,8 @@ class CalendarHandler extends \BaseClass {
|
|||||||
|
|
||||||
return $events[0];
|
return $events[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteEvent($id, $userContext, $heskSettings) {
|
||||||
|
$this->calendarGateway->deleteEvent($id, $userContext, $heskSettings);
|
||||||
|
}
|
||||||
}
|
}
|
@ -73,6 +73,18 @@ class CalendarController extends \BaseClass {
|
|||||||
return output($calendarHandler->updateEvent($event, $userContext, $hesk_settings));
|
return output($calendarHandler->updateEvent($event, $userContext, $hesk_settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function delete($id) {
|
||||||
|
/* @var $userContext UserContext */
|
||||||
|
global $applicationContext, $hesk_settings, $userContext;
|
||||||
|
|
||||||
|
/* @var $calendarHandler CalendarHandler */
|
||||||
|
$calendarHandler = $applicationContext->get(CalendarHandler::clazz());
|
||||||
|
|
||||||
|
$calendarHandler->deleteEvent($id, $userContext, $hesk_settings);
|
||||||
|
|
||||||
|
return http_response_code(204);
|
||||||
|
}
|
||||||
|
|
||||||
private function transformJson($json, $id = null) {
|
private function transformJson($json, $id = null) {
|
||||||
$event = new CalendarEvent();
|
$event = new CalendarEvent();
|
||||||
|
|
||||||
|
@ -192,4 +192,20 @@ class CalendarGateway extends CommonDao {
|
|||||||
|
|
||||||
$this->close();
|
$this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id int
|
||||||
|
* @param $userContext UserContext
|
||||||
|
* @param $heskSettings array
|
||||||
|
*/
|
||||||
|
public function deleteEvent($id, $userContext, $heskSettings) {
|
||||||
|
$this->init();
|
||||||
|
|
||||||
|
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "calendar_event_reminder`
|
||||||
|
WHERE `event_id` = " . intval($id) . " AND `user_id` = " . intval($userContext->id));
|
||||||
|
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "calendar_event`
|
||||||
|
WHERE `id` = " . intval($id));
|
||||||
|
|
||||||
|
$this->close();
|
||||||
|
}
|
||||||
}
|
}
|
@ -205,7 +205,7 @@ Link::all(array(
|
|||||||
'/v1/settings' => action(\Controllers\Settings\SettingsController::clazz(), RequestMethod::all()),
|
'/v1/settings' => action(\Controllers\Settings\SettingsController::clazz(), RequestMethod::all()),
|
||||||
// Calendar
|
// Calendar
|
||||||
'/v1/calendar/events/staff' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::GET, RequestMethod::POST), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
'/v1/calendar/events/staff' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::GET, RequestMethod::POST), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
||||||
'/v1/calendar/events/staff/{i}' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::PUT), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
'/v1/calendar/events/staff/{i}' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::PUT, RequestMethod::DELETE), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
||||||
|
|
||||||
/* Internal use only routes */
|
/* Internal use only routes */
|
||||||
// Resend email response
|
// Resend email response
|
||||||
|
@ -16,7 +16,7 @@ $(document).ready(function() {
|
|||||||
defaultView: $('#setting_default_view').text().trim(),
|
defaultView: $('#setting_default_view').text().trim(),
|
||||||
events: function(start, end, timezone, callback) {
|
events: function(start, end, timezone, callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: heskPath + 'api/v1/calendar/events/staff?start=' + start + '&end=' + end,
|
url: heskPath + 'api/index.php/v1/calendar/events/staff?start=' + start + '&end=' + end,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
headers: { 'X-Internal-Call': true },
|
headers: { 'X-Internal-Call': true },
|
||||||
@ -160,17 +160,15 @@ $(document).ready(function() {
|
|||||||
$editForm.find('#delete-button').click(function() {
|
$editForm.find('#delete-button').click(function() {
|
||||||
var id = $editForm.find('input[name="id"]').val();
|
var id = $editForm.find('input[name="id"]').val();
|
||||||
|
|
||||||
var data = {
|
|
||||||
id: id,
|
|
||||||
action: 'delete'
|
|
||||||
};
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: heskPath + 'internal-api/admin/calendar/',
|
url: heskPath + 'api/index.php/v1/calendar/events/staff/' + id,
|
||||||
data: data,
|
headers: {
|
||||||
|
'X-Internal-Call': true,
|
||||||
|
'X-HTTP-Method-Override': 'DELETE'
|
||||||
|
},
|
||||||
success: function() {
|
success: function() {
|
||||||
removeFromCalendar(data.id);
|
removeFromCalendar(id);
|
||||||
mfhAlert.success(mfhLang.text('event_deleted'));
|
mfhAlert.success(mfhLang.text('event_deleted'));
|
||||||
$('#edit-event-modal').modal('hide');
|
$('#edit-event-modal').modal('hide');
|
||||||
},
|
},
|
||||||
@ -216,7 +214,7 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: heskPath + 'api/v1/calendar/events/staff',
|
url: heskPath + 'api/index.php/v1/calendar/events/staff',
|
||||||
data: JSON.stringify(data),
|
data: JSON.stringify(data),
|
||||||
contentType: 'json',
|
contentType: 'json',
|
||||||
headers: { 'X-Internal-Call': true },
|
headers: { 'X-Internal-Call': true },
|
||||||
@ -268,7 +266,7 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: heskPath + 'api/v1/calendar/events/staff/' + data.id,
|
url: heskPath + 'api/index.php/v1/calendar/events/staff/' + data.id,
|
||||||
data: JSON.stringify(data),
|
data: JSON.stringify(data),
|
||||||
contentType: 'json',
|
contentType: 'json',
|
||||||
headers: {
|
headers: {
|
||||||
@ -490,7 +488,7 @@ function respondToDragAndDrop(event, delta, revertFunc) {
|
|||||||
var heskPath = $('p#hesk-path').text();
|
var heskPath = $('p#hesk-path').text();
|
||||||
|
|
||||||
if (event.type === 'TICKET') {
|
if (event.type === 'TICKET') {
|
||||||
var uri = 'api/v1/staff/tickets/' + event.id + '/due-date';
|
var uri = 'api/index.php/v1/staff/tickets/' + event.id + '/due-date';
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: heskPath + uri,
|
url: heskPath + uri,
|
||||||
@ -541,7 +539,7 @@ function respondToDragAndDrop(event, delta, revertFunc) {
|
|||||||
reminderUnits: event.reminderUnits
|
reminderUnits: event.reminderUnits
|
||||||
};
|
};
|
||||||
|
|
||||||
var url = heskPath + 'api/v1/calendar/events/staff/' + event.id;
|
var url = heskPath + 'api/index.php/v1/calendar/events/staff/' + event.id;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: url,
|
url: url,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user