Browse Source

Working on adding a login header image

tags/3.1.0
Mike Koch 2 years ago
parent
commit
55a1d3d5ad

+ 37
- 14
admin/admin_settings.php View File

@@ -3791,6 +3791,7 @@ $modsForHesk_settings = mfh_getSettings();
</div>
</div>
</div>
<h4>LOGIN PAGE</h4>
<div class="row">
<div class="col-xs-12">
<div class="form-group">
@@ -3800,7 +3801,9 @@ $modsForHesk_settings = mfh_getSettings();
<div class="col-sm-9 col-xs-7 form-inline">
<div class="radio">
<label>
<input type="radio" name="login-background" value="color" <?php if ($modsForHesk_settings['login_background_type'] == 'color') { echo 'checked'; } ?>>
<input type="radio" name="login-background"
data-activate="input[name='login-background-color']" data-deactivate="input[name='login-background-image']"
value="color" <?php if ($modsForHesk_settings['login_background_type'] == 'color') { echo 'checked'; } ?>>
SOLID COLOR
</label>
</div>&nbsp;&nbsp;&nbsp;
@@ -3808,35 +3811,55 @@ $modsForHesk_settings = mfh_getSettings();
<br>
<div class="radio">
<label>
<input type="radio" name="login-background" value="image" <?php if ($modsForHesk_settings['login_background_type'] == 'image') { echo 'checked'; } ?>>
IMAGE URL
<input type="radio" name="login-background"
data-activate="input[name='login-background-image']" data-deactivate="input[name='login-background-color']"
value="image" <?php if ($modsForHesk_settings['login_background_type'] == 'image') { echo 'checked'; } ?>>
IMAGE
</label>
</div>
<input title="LOGIN BACKGROUND COLOR" type="file" name="login-background-image" style="display: inline;vertical-align: bottom" <?php if ($modsForHesk_settings['login_background_type'] == 'color') { echo 'disabled'; } ?>>
<?php if ($modsForHesk_settings['login_background_type'] == 'image'): ?>
<br>
<img src="../<?php echo $hesk_settings['cache_dir']; ?>/lb_<?php echo $modsForHesk_settings['login_background']; ?>" alt="Login Background" height="125" width="125" class="push-down-10">
<img src="<?php echo HESK_PATH . $hesk_settings['cache_dir']; ?>/lb_<?php echo $modsForHesk_settings['login_background']; ?>" alt="Login Background" height="125" width="125" class="push-down-10">
<?php endif; ?>
<script type="text/javascript">
$('input[name="login-background-color"]').colorpicker({
format: 'hex',
color: <?php if ($modsForHesk_settings['login_background_type'] == 'color') { echo "'{$modsForHesk_settings['login_background']}'"; } else { echo 'false'; } ?>
});

$('input[name="login-background"]').change(function() {
if ($(this).val() == 'color') {
$('input[name="login-background-color"]').removeAttr('disabled');
$('input[name="login-background-image"]').attr('disabled', 'disabled');
} else {
$('input[name="login-background-image"]').removeAttr('disabled');
$('input[name="login-background-color"]').attr('disabled', 'disabled');
}
});
</script>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="form-group">
<label for="login-box-header" class="col-sm-3 col-xs-5 control-label">
LOGIN BOX HEADER
</label>
<div class="col-sm-9 col-xs-7 form-inline">
<div class="radio">
<label>
<input type="radio" name="login-box-header" value="helpdesk-title" data-deactivate="input[name='login-box-header-image']" <?php if ($modsForHesk_settings['login_box_header'] == 'helpdesk-title') { echo 'checked'; } ?>>
HELPDESK TITLE
</label>
</div><br>
<div class="radio">
<label>
<input type="radio" name="login-box-header" value="image" data-activate="input[name='login-box-header-image']" <?php if ($modsForHesk_settings['login_box_header'] == 'image') { echo 'checked'; } ?>>
IMAGE
</label>
<input title="LOGIN HEADER IMAGE" type="file" name="login-box-header-image" style="display: inline;vertical-align: bottom" <?php if ($modsForHesk_settings['login_box_header'] == 'helpdesk-title') { echo 'disabled'; } ?>>
<?php if ($modsForHesk_settings['login_box_header'] == 'image'): ?>
<br>
<img src="<?php echo HESK_PATH . $hesk_settings['cache_dir']; ?>/lbh_<?php echo $modsForHesk_settings['login_box_header_image']; ?>" alt="<?php echo $modsForHesk_settings['login_box_header_image']; ?>" height="125" width="125" class="push-down-10">
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group" style="margin-left: 10px">

+ 63
- 6
admin/admin_settings_save.php View File

@@ -39,6 +39,8 @@ hesk_checkPermission('can_manage_settings');
// A security check
hesk_token_check('POST');

$modsForHesk_settings = mfh_getSettings();

// Demo mode
if (defined('HESK_DEMO')) {
hesk_process_messages($hesklang['sdemo'], 'admin_settings.php');
@@ -497,10 +499,14 @@ $set['dropdownItemTextHoverBackgroundColor'] = hesk_input(hesk_POST('dropdownIte
$set['admin_color_scheme'] = hesk_input(hesk_POST('admin-color-scheme'));

$set['login_background_type'] = hesk_input(hesk_POST('login-background'));
$set['login_box_header'] = hesk_input(hesk_POST('login-box-header'));

$changedBackground = false;
$loadedAttachmentFuncs = false;
if ($set['login_background_type'] == 'color') {
unlink($hesk_settings['cache_dir'] . '/lb_' . $set['login_background']);
if (file_exists($hesk_settings['cache_dir'] . '/lb_' . $set['login_background'])) {
unlink($hesk_settings['cache_dir'] . '/lb_' . $set['login_background']);
}
$set['login_background'] = hesk_input(hesk_POST('login-background-color'));
if ($set['login_background'] == '') {
$set['login_background'] = '#d2d6de';
@@ -508,8 +514,11 @@ if ($set['login_background_type'] == 'color') {

$changedBackground = true;
} else {
include(HESK_PATH . 'inc/attachments.inc.php');
include(HESK_PATH . 'inc/posting_functions.inc.php');
if (!$loadedAttachmentFuncs) {
include(HESK_PATH . 'inc/attachments.inc.php');
include(HESK_PATH . 'inc/posting_functions.inc.php');
$loadedAttachmentFuncs = true;
}


$file_name = hesk_cleanFileName($_FILES['login-background-image']['name']);
@@ -522,8 +531,8 @@ if ($set['login_background_type'] == 'color') {
}
$ext = strtolower(strrchr($file_name, "."));

if (file_exists($hesk_settings['cache_dir'] . '/lb_' . $set['login_background'])) {
unlink($hesk_settings['cache_dir'] . '/lb_' . $set['login_background']);
if (file_exists($hesk_settings['cache_dir'] . '/lb_' . $modsForHesk_settings['login_background'])) {
unlink($hesk_settings['cache_dir'] . '/lb_' . $modsForHesk_settings['login_background']);
}

$saved_name = 'login-background' . $ext;
@@ -539,6 +548,49 @@ if ($set['login_background_type'] == 'color') {
$changedBackground = true;
}
}
$changedLoginImage = false;
if ($set['login_box_header'] == 'image') {
if (!$loadedAttachmentFuncs) {
include(HESK_PATH . 'inc/attachments.inc.php');
include(HESK_PATH . 'inc/posting_functions.inc.php');
$loadedAttachmentFuncs = true;
}


$file_name = hesk_cleanFileName($_FILES['login-box-header-image']['name']);

if (!empty($_FILES['login-box-header-image']['name'])) {
$file_size = $_FILES['login-box-header-image']['size'];
if ($file_size > $hesk_settings['attachments']['max_size']) {
return hesk_fileError(sprintf($hesklang['file_too_large'], $file_name));
}
$ext = strtolower(strrchr($file_name, "."));

if (file_exists($hesk_settings['cache_dir'] . '/lbh_' . $modsForHesk_settings['login_box_header_image'])) {
unlink($hesk_settings['cache_dir'] . '/lbh_' . $modsForHesk_settings['login_box_header_image']);
}

$saved_name = 'login-box-header-image' . $ext;

$file_to_move = $_FILES['login-box-header-image']['tmp_name'];


if (!move_uploaded_file($file_to_move, dirname(dirname(__FILE__)) . '/' . $hesk_settings['cache_dir'] . '/lbh_' . $saved_name)) {
hesk_error($hesklang['cannot_move_tmp']);
}

$set['login_box_header_image'] = $saved_name;
$changedLoginImage = true;
}
} else {
if (file_exists($hesk_settings['cache_dir'] . '/lbh_' . $set['login_box_header_image'])) {
unlink($hesk_settings['cache_dir'] . '/lbh_' . $set['login_box_header_image']);
}

$set['login_box_header_image'] = '';
$changedLoginImage = true;
}

mfh_updateSetting('rtl', $set['rtl']);
mfh_updateSetting('show_icons', $set['show-icons']);
mfh_updateSetting('custom_field_setting', $set['custom-field-setting']);
@@ -577,9 +629,14 @@ mfh_updateSetting('first_day_of_week', $set['first_day_of_week'], false);
mfh_updateSetting('default_calendar_view', $set['default_view'], true);
mfh_updateSetting('admin_color_scheme', $set['admin_color_scheme'], true);

mfh_updateSetting('login_background_type', $set['login_background_type'], true);
if ($changedBackground) {
mfh_updateSetting('login_background', $set['login_background'], true);
mfh_updateSetting('login_background_type', $set['login_background_type'], true);
}

mfh_updateSetting('login_box_header', $set['login_box_header'], true);
if ($changedLoginImage) {
mfh_updateSetting('login_box_header_image', $set['login_box_header_image'], true);
}

// Prepare settings file and save it

+ 2
- 0
install/mods-for-hesk/sql/installSql.php View File

@@ -1011,6 +1011,8 @@ function execute310Scripts() {
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` CHANGE `color` `background_color` VARCHAR(7) NOT NULL DEFAULT '#FFFFFF'");
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('login_background_type', 'color')");
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_image', '')");

updateVersion('3.1.0');
}

+ 10
- 0
js/modsForHesk-javascript.js View File

@@ -94,6 +94,16 @@ var loadJquery = function()
closeOnContentClick: true
});

$('[data-activate]').click(function() {
var activate = $(this).data('activate');
$(activate).removeAttr('disabled');
});

$('[data-deactivate]').click(function() {
var deactivate = $(this).data('deactivate');
$(deactivate).attr('disabled', 'disabled');
});

//-- Initialize toastr properties
toastr.options.progressBar = true;
toastr.options.closeButton = true;

Loading…
Cancel
Save