Add a URL rewrite setting for the API. Not using it in code yet... might not even do that lol
This commit is contained in:
parent
a47773cf98
commit
3ca6b1a435
@ -119,13 +119,29 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
<?php echo $hesklang['disable']; ?>
|
<?php echo $hesklang['disable']; ?>
|
||||||
</label>
|
</label>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
</div>
|
||||||
<i id="public-api-success" class="fa fa-check-circle fa-2x green hide media-middle"
|
</div>
|
||||||
data-toggle="tooltip" title="<?php echo $hesklang['changes_saved']; ?>"></i>
|
<div class="form-group">
|
||||||
<i id="public-api-failure" class="fa fa-times-circle fa-2x red hide media-middle"
|
<label for="url-rewrite" class="col-sm-3 control-label">
|
||||||
data-toggle="tooltip" title="<?php echo $hesklang['save_failed_check_logs']; ?>"></i>
|
<?php echo $hesklang['url_rewrite']; ?>
|
||||||
<i id="public-api-saving" class="fa fa-spin fa-spinner fa-2x hide media-middle"
|
<i class="fa fa-question-circle settingsquestionmark" data-toggle="popover"
|
||||||
data-toggle="tooltip" title="<?php echo $hesklang['saving']; ?>"></i>
|
title="<?php echo $hesklang['url_rewrite']; ?>"
|
||||||
|
data-content="<?php echo $hesklang['url_rewrite_help']; ?>"></i>
|
||||||
|
</label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<span class="btn-group" data-toggle="buttons">
|
||||||
|
<?php
|
||||||
|
$on = $modsForHesk_settings['api_url_rewrite'] == '1' ? 'active' : '';
|
||||||
|
$off = $modsForHesk_settings['api_url_rewrite'] == '1' ? '' : 'active';
|
||||||
|
?>
|
||||||
|
<label id="enable-url-rewrite-button" class="btn btn-success <?php echo $on; ?>">
|
||||||
|
<input type="radio" name="url-rewrite" value="1"> <i class="fa fa-check-circle"></i>
|
||||||
|
<?php echo $hesklang['enable']; ?>
|
||||||
|
</label>
|
||||||
|
<label id="disable-url-rewrite-button" class="btn btn-danger <?php echo $off; ?>">
|
||||||
|
<input type="radio" name="url-rewrite" value="0"> <i class="fa fa-times-circle"></i>
|
||||||
|
<?php echo $hesklang['disable']; ?>
|
||||||
|
</label>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -204,7 +220,8 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
echo mfh_get_hidden_fields_for_language(array('success', 'url_rewrite_saved', 'api_settings_saved', 'an_error_occurred'));
|
||||||
|
|
||||||
require_once(HESK_PATH . 'inc/footer.inc.php');
|
require_once(HESK_PATH . 'inc/footer.inc.php');
|
||||||
exit();
|
exit();
|
16
api/htaccess.txt
Normal file
16
api/htaccess.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<IfModule mod_rewrite.c>
|
||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
# If your helpdesk is installed in a sub-directory, change /api to /<your subfolder>/api
|
||||||
|
RewriteBase /api
|
||||||
|
|
||||||
|
# remove index.php from URLs
|
||||||
|
RewriteCond %{THE_REQUEST} /index\.php [NC]
|
||||||
|
RewriteRule ^(.*?)index\.php$ $1 [L,R=302,NC,NE]
|
||||||
|
|
||||||
|
RewriteRule ^index\.php$ - [L]
|
||||||
|
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteRule . index.php [L]
|
||||||
|
</IfModule>
|
@ -1013,6 +1013,7 @@ function execute310Scripts() {
|
|||||||
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('login_background', '#d2d6de')");
|
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('login_background', '#d2d6de')");
|
||||||
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('login_box_header', 'helpdesk-title')");
|
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('login_box_header', 'helpdesk-title')");
|
||||||
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('login_box_header_image', '')");
|
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('login_box_header_image', '')");
|
||||||
|
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('api_url_rewrite', '0')");
|
||||||
|
|
||||||
// Copy over color presets to the custom values
|
// Copy over color presets to the custom values
|
||||||
$theme_preset_rs = executeQuery("SELECT `Value` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` WHERE `Key` = 'admin_color_scheme'");
|
$theme_preset_rs = executeQuery("SELECT `Value` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` WHERE `Key` = 'admin_color_scheme'");
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#enable-api-button').click(function() {
|
$('#enable-api-button').click(function() {
|
||||||
updatePublicApi('1', '#enable-api-button');
|
updatePublicApi('1');
|
||||||
});
|
});
|
||||||
$('#disable-api-button').click(function() {
|
$('#disable-api-button').click(function() {
|
||||||
updatePublicApi('0', '#disable-api-button');
|
updatePublicApi('0');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#enable-url-rewrite-button').click(function() {
|
||||||
|
updateUrlRewrite('1');
|
||||||
|
});
|
||||||
|
$('#disable-url-rewrite-button').click(function() {
|
||||||
|
updateUrlRewrite('0');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -16,53 +23,49 @@ function updatePublicApi(enable) {
|
|||||||
};
|
};
|
||||||
$('#enable-api-button').addClass('disabled');
|
$('#enable-api-button').addClass('disabled');
|
||||||
$('#disable-api-button').addClass('disabled');
|
$('#disable-api-button').addClass('disabled');
|
||||||
markSaving('public-api');
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: endpoint,
|
url: endpoint,
|
||||||
data: data,
|
data: data,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
success: function() {
|
success: function() {
|
||||||
|
mfhAlert.success(mfhLang.text('api_settings_saved'), mfhLang.text('success'));
|
||||||
$('#enable-api-button').removeClass('disabled');
|
$('#enable-api-button').removeClass('disabled');
|
||||||
$('#disable-api-button').removeClass('disabled');
|
$('#disable-api-button').removeClass('disabled');
|
||||||
markSuccess('public-api');
|
|
||||||
|
|
||||||
if (enable == '1') {
|
|
||||||
$('#public-api-sidebar').addClass('success')
|
|
||||||
.removeClass('danger');
|
|
||||||
$('#public-api-sidebar-enabled').removeClass('hide');
|
|
||||||
$('#public-api-sidebar-disabled').addClass('hide');
|
|
||||||
} else {
|
|
||||||
$('#public-api-sidebar').addClass('danger')
|
|
||||||
.removeClass('success');
|
|
||||||
$('#public-api-sidebar-disabled').removeClass('hide');
|
|
||||||
$('#public-api-sidebar-enabled').addClass('hide');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(data) {
|
||||||
console.error(data);
|
console.error(data);
|
||||||
$('#enable-api-button').removeClass('disabled');
|
$('#enable-api-button').removeClass('disabled');
|
||||||
$('#disable-api-button').removeClass('disabled');
|
$('#disable-api-button').removeClass('disabled');
|
||||||
markFailure('public-api');
|
mfhAlert.error(mfhLang.text('an_error_occurred'), mfhLang.text('error'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function markSuccess(id) {
|
function updateUrlRewrite(enable) {
|
||||||
$('#' + id + '-saving').addClass('hide');
|
var heskPath = $('p#hesk-path').text();
|
||||||
$('#' + id + '-failure').addClass('hide');
|
var endpoint = heskPath + 'internal-api/admin/api-settings/';
|
||||||
$('#' + id + '-success').removeClass('hide');
|
var data = {
|
||||||
}
|
key: 'api_url_rewrite',
|
||||||
|
value: enable
|
||||||
function markSaving(id) {
|
};
|
||||||
$('#' + id + '-saving').removeClass('hide');
|
$('#enable-url-rewrite-button').addClass('disabled');
|
||||||
$('#' + id + '-failure').addClass('hide');
|
$('#disable-url-rewrite-button').addClass('disabled');
|
||||||
$('#' + id + '-success').addClass('hide');
|
$.ajax({
|
||||||
}
|
url: endpoint,
|
||||||
|
data: data,
|
||||||
function markFailure(id) {
|
method: 'POST',
|
||||||
$('#' + id + '-saving').addClass('hide');
|
success: function() {
|
||||||
$('#' + id + '-failure').removeClass('hide');
|
mfhAlert.success(mfhLang.text('url_rewrite_saved'), mfhLang.text('success'));
|
||||||
$('#' + id + '-success').addClass('hide');
|
$('#enable-url-rewrite-button').removeClass('disabled');
|
||||||
|
$('#disable-url-rewrite-button').removeClass('disabled');
|
||||||
|
},
|
||||||
|
error: function(data) {
|
||||||
|
console.error(data);
|
||||||
|
$('#enable-url-rewrite-button').removeClass('disabled');
|
||||||
|
$('#disable-url-rewrite-button').removeClass('disabled');
|
||||||
|
mfhAlert.error(mfhLang.text('an_error_occurred'), mfhLang.text('error'));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateToken(userId) {
|
function generateToken(userId) {
|
||||||
|
@ -2168,6 +2168,11 @@ $hesklang['preset_red'] = 'Red';
|
|||||||
$hesklang['preset_red_light'] = 'Red (light)';
|
$hesklang['preset_red_light'] = 'Red (light)';
|
||||||
$hesklang['preset_black'] = 'Black';
|
$hesklang['preset_black'] = 'Black';
|
||||||
$hesklang['preset_black_light'] = 'Black (light)';
|
$hesklang['preset_black_light'] = 'Black (light)';
|
||||||
|
$hesklang['url_rewrite'] = 'URL Rewrite';
|
||||||
|
$hesklang['url_rewrite_help'] = 'Remove the need to include /index.php in API URLs (i.e. /api/index.php/v1/... -> /api/v1/...). Rename htaccess.txt to .htaccess in the /api folder to use.';
|
||||||
|
$hesklang['url_rewrite_saved'] = 'URL rewrite setting saved!';
|
||||||
|
$hesklang['api_settings_saved'] = 'API settings saved!';
|
||||||
|
$hesklang['an_error_occurred'] = 'An error occurred. Check the logs for more information';
|
||||||
|
|
||||||
// DO NOT CHANGE BELOW
|
// DO NOT CHANGE BELOW
|
||||||
if (!defined('IN_SCRIPT')) die('PHP syntax OK!');
|
if (!defined('IN_SCRIPT')) die('PHP syntax OK!');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user