Browse Source

Make all AJAX calls relative

tags/3.1.0
Mike Koch 2 years ago
parent
commit
4a49c8c510

+ 3
- 1
admin/admin_ticket.php View File

@@ -1506,13 +1506,15 @@ function hesk_getAdminButtonsInTicket($reply = 0, $white = 1)
$replyDataAttribute = 'data-reply-id="' . $reply['id'] . '"';
}

$options .= '
if ($ticket['email'] !== '') {
$options .= '
<button class="btn btn-default" data-action="resend-email-notification" ' . $replyDataAttribute . ' data-ticket-id="' . $ticket['id'] . '">
<i class="fa fa-envelope navy-blue"></i> ' . $hesklang['resend_email_notification'] . '
</button>
<span id="lang_email_notification_sent" style="display: none">' . $hesklang['email_notification_sent'] . '</span>
<span id="lang_email_notification_resend_failed" style="display: none">' . $hesklang['email_notification_resend_failed'] . '</span>
';
}

/* Edit post */
if ($can_edit) {

+ 3
- 2
inc/header.inc.php View File

@@ -93,7 +93,6 @@ if (is_dir(HESK_PATH . 'install')) {
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/platform.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/bootstrap-validator.min.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>internal-api/js/core.php?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/bootstrap-colorpicker.min.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/toastr.min.js?v=<?php echo MODS_FOR_HESK_BUILD ?>"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/jquery.magnific-popup.min.js?v=<?php echo MODS_FOR_HESK_BUILD ?>"></script>
@@ -348,4 +347,6 @@ if ($modsForHesk_settings['show_icons']) {
</div>
<?php } ?>
</div>
</nav>
</nav>
<?php // GLOBAL JAVASCRIPT IDs ?>
<p style="display: none" id="hesk-path"><?php echo HESK_PATH; ?></p>

+ 2
- 2
inc/headerAdmin.inc.php View File

@@ -67,7 +67,6 @@ $modsForHesk_settings = mfh_getSettings();
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/platform.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/bootstrap-validator.min.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>internal-api/js/core-admin.php?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/bootstrap-colorpicker.min.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/jquery.slimscroll.min.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/toastr.min.js?v=<?php echo MODS_FOR_HESK_BUILD; ?>"></script>
@@ -305,7 +304,8 @@ if (defined('MFH_PAGE_LAYOUT') && MFH_PAGE_LAYOUT == 'TOP_ONLY') {
unset($onload); ?>" class="<?php echo $layout_tag ?> fixed js">

<?php // GLOBAL JAVASCRIPT IDs ?>
<p style="display: none" id="heskUrl"><?php echo $hesk_settings['hesk_url']; ?></p>
<p style="display: none" id="hesk-path"><?php echo HESK_PATH; ?></p>
<p style="display: none" id="admin-dir"><?php echo $hesk_settings['admin_dir']; ?></p>
<p style="display: none" id="lang_alert_success"><?php echo $hesklang['alert_success']; ?></p>
<p style="display: none" id="lang_alert_error"><?php echo $hesklang['alert_error']; ?></p>


+ 4
- 3
internal-api/js/admin-ticket.js View File

@@ -1,4 +1,6 @@
$(document).ready(function() {
var heskPath = $('p#hesk-path').text();

var $readonlyDueDateContainer = $('#readonly-due-date');
var $changeButton = $readonlyDueDateContainer.find('#change-button');
var $editableDueDateContainer = $('#editable-due-date');
@@ -20,7 +22,7 @@ $(document).ready(function() {
var newDueDate = $editableDueDateContainer.find('input[type="text"][name="due-date"]').val();
$.ajax({
method: 'POST',
url: getHelpdeskUrl() + '/internal-api/admin/calendar/',
url: heskPath + 'internal-api/admin/calendar/',
data: {
trackingId: $('input[type="hidden"][name="track"]').val(),
action: 'update-ticket',
@@ -48,8 +50,7 @@ $(document).ready(function() {

var ticketId = $this.data('ticket-id');
var replyId = $this.data('reply-id');
var heskUrl = $('span#heskUrl').text();
var apiUrl = heskUrl + '/api/index.php/v1-internal/staff/tickets/' + ticketId + '/resend-email';
var apiUrl = heskPath + 'api/index.php/v1-internal/staff/tickets/' + ticketId + '/resend-email';

if (replyId !== undefined) {
apiUrl += '?replyId=' + replyId;

+ 6
- 6
internal-api/js/api-settings.js View File

@@ -8,8 +8,8 @@ $(document).ready(function() {
});

function updatePublicApi(enable) {
var endpoint = getHelpdeskUrl();
endpoint += '/internal-api/admin/api-settings/';
var heskPath = $('p#hesk-path').text();
var endpoint = heskPath + 'internal-api/admin/api-settings/';
var data = {
key: 'public_api',
value: enable
@@ -66,8 +66,8 @@ function markFailure(id) {
}

function generateToken(userId) {
var endpoint = getHelpdeskUrl();
endpoint += '/internal-api/admin/api-authentication/';
var heskPath = $('p#hesk-path').text();
var endpoint = heskPath + 'internal-api/admin/api-authentication/';
markSaving('token-' + userId);
$('#token-' + userId + '-reset').addClass('hide');
$('#token-' + userId + '-created').addClass('hide');
@@ -94,8 +94,8 @@ function generateToken(userId) {
}

function clearTokens(userId) {
var endpoint = getHelpdeskUrl();
endpoint += '/internal-api/admin/api-authentication/';
var heskPath = $('p#hesk-path').text();
var endpoint = heskPath + 'internal-api/admin/api-authentication/';
markSaving('token-' + userId);
$('#token-' + userId + '-reset').addClass('hide');
$('#token-' + userId + '-created').addClass('hide');

+ 0
- 15
internal-api/js/core-admin.php View File

@@ -1,15 +0,0 @@
<?php
define('IN_SCRIPT', 1);
require_once('../../hesk_settings.inc.php');
header('Content-Type: application/javascript');
echo "
var g_isInAdmin = true;

function getHelpdeskUrl() {
return '".$hesk_settings['hesk_url']."';
}

function getAdminDirectory() {
return '".$hesk_settings['admin_dir']."';
}
";

+ 0
- 11
internal-api/js/core.php View File

@@ -1,11 +0,0 @@
<?php
define('IN_SCRIPT', 1);
require_once('../../hesk_settings.inc.php');
header('Content-Type: application/javascript');
echo "
var g_isInAdmin = false;

function getHelpdeskUrl() {
return '".$hesk_settings['hesk_url']."';
}
";

+ 2
- 2
internal-api/js/view-message-log.js View File

@@ -20,8 +20,8 @@ function getNullableField(value) {
}

function searchLogs(location, fromDate, toDate, severity) {
var endpoint = getHelpdeskUrl();
endpoint += '/internal-api/admin/message-log/';
var heskPath = $('p#hesk-path').text();
var endpoint = heskPath + 'internal-api/admin/message-log/';

$.ajax({
url: endpoint,

+ 3
- 1
js/calendar/mods-for-hesk-calendar-admin-readonly.js View File

@@ -1,4 +1,6 @@
$(document).ready(function() {
var heskPath = $('p#hesk-path').text();

$('#calendar').fullCalendar({
header: {
left: 'prevYear,prev,next,nextYear today',
@@ -13,7 +15,7 @@ $(document).ready(function() {
defaultView: $('#setting_default_view').text().trim(),
events: function(start, end, timezone, callback) {
$.ajax({
url: getHelpdeskUrl() + '/internal-api/admin/calendar/?start=' + start + '&end=' + end,
url: heskPath + 'internal-api/admin/calendar/?start=' + start + '&end=' + end,
method: 'GET',
dataType: 'json',
success: function(data) {

+ 3
- 1
js/calendar/mods-for-hesk-calendar-readonly.js View File

@@ -1,4 +1,6 @@
$(document).ready(function() {
var heskPath = $('p#hesk-path').text();

$('#calendar').fullCalendar({
header: {
left: 'prevYear,prev,next,nextYear today',
@@ -13,7 +15,7 @@ $(document).ready(function() {
defaultView: $('#setting_default_view').text().trim(),
events: function(start, end, timezone, callback) {
$.ajax({
url: getHelpdeskUrl() + '/internal-api/calendar/?start=' + start + '&end=' + end,
url: heskPath + 'internal-api/calendar/?start=' + start + '&end=' + end,
method: 'GET',
dataType: 'json',
success: function(data) {

+ 13
- 8
js/calendar/mods-for-hesk-calendar.js View File

@@ -1,4 +1,6 @@
$(document).ready(function() {
var heskPath = $('p#hesk-path').text();

$('#calendar').fullCalendar({
header: {
left: 'prevYear,prev,next,nextYear today',
@@ -13,7 +15,7 @@ $(document).ready(function() {
defaultView: $('#setting_default_view').text().trim(),
events: function(start, end, timezone, callback) {
$.ajax({
url: getHelpdeskUrl() + '/internal-api/admin/calendar/?start=' + start + '&end=' + end,
url: heskPath + 'internal-api/admin/calendar/?start=' + start + '&end=' + end,
method: 'GET',
dataType: 'json',
success: function(data) {
@@ -165,7 +167,7 @@ $(document).ready(function() {

$.ajax({
method: 'POST',
url: getHelpdeskUrl() + '/internal-api/admin/calendar/',
url: heskPath + 'internal-api/admin/calendar/',
data: data,
success: function() {
removeFromCalendar(data.id);
@@ -210,7 +212,7 @@ $(document).ready(function() {

$.ajax({
method: 'POST',
url: getHelpdeskUrl() + '/internal-api/admin/calendar/',
url: heskPath + 'internal-api/admin/calendar/',
data: data,
success: function(id) {
addToCalendar(id, data, $('#lang_event_created').text());
@@ -256,7 +258,7 @@ $(document).ready(function() {

$.ajax({
method: 'POST',
url: getHelpdeskUrl() + '/internal-api/admin/calendar/',
url: heskPath + 'internal-api/admin/calendar/',
data: data,
success: function() {
removeFromCalendar(data.id);
@@ -308,7 +310,7 @@ function buildEvent(id, dbObject) {
if (dbObject.allDay) {
endTime.add(1, 'days');
}
console.log(dbObject);
return {
id: id,
title: dbObject.title,
@@ -432,7 +434,9 @@ function displayEditModal(date) {
}


var createTicketLink = getHelpdeskUrl() + '/' + getAdminDirectory() + '/new_ticket.php?subject=';
var heskPath = $('p#hesk-path').text();
var adminDir = $('p#admin-dir').text();
var createTicketLink = heskPath + adminDir + '/new_ticket.php?subject=';
createTicketLink += encodeURI('[' + date.start.format('YYYY-MM-DD') + '] ' + date.title);
if (date.location != '') {
createTicketLink += encodeURI(' @ ' + date.location);
@@ -467,10 +471,11 @@ function updateCategoryVisibility() {
}

function respondToDragAndDrop(event, delta, revertFunc) {
var heskPath = $('p#hesk-path').text();
if (event.type === 'TICKET') {
$.ajax({
method: 'POST',
url: getHelpdeskUrl() + '/internal-api/admin/calendar/',
url: heskPath + 'internal-api/admin/calendar/',
data: {
trackingId: event.trackingId,
action: 'update-ticket',
@@ -518,7 +523,7 @@ function respondToDragAndDrop(event, delta, revertFunc) {
};
$.ajax({
method: 'POST',
url: getHelpdeskUrl() + '/internal-api/admin/calendar/',
url: heskPath + 'internal-api/admin/calendar/',
data: data,
success: function() {
mfhAlert.success(mfhLang.text('event_updated'));

+ 2
- 1
js/modsForHesk-javascript.js View File

@@ -300,9 +300,10 @@ function outputAttachmentIdHolder(value, id) {
}

function removeAttachment(id) {
var heskPath = $('p#hesk-path').text();
$('input[name="attachment-ids[]"][value="' + id + '"]').remove();
$.ajax({
url: getHelpdeskUrl() + '/internal-api/ticket/delete-attachment.php?id=' + id,
url: heskPath + 'internal-api/ticket/delete-attachment.php?id=' + id,
method: 'GET'
});
}

Loading…
Cancel
Save