From 8f2302630c9ed9ff3163697beca92c74865fdda3 Mon Sep 17 00:00:00 2001 From: Fermin Date: Mon, 21 May 2018 14:29:11 +0200 Subject: [PATCH] [Rebranding] Docs and Support login icons are configurables --- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 + pandora_console/general/login_page.php | 24 ++-- .../godmode/setup/setup_visuals.php | 128 ++++++++++++++++++ pandora_console/include/functions_config.php | 12 ++ pandora_console/include/functions_ui.php | 37 +++++ pandora_console/include/styles/pandora.css | 8 ++ pandora_console/pandoradb_data.sql | 5 +- 7 files changed, 206 insertions(+), 10 deletions(-) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index e3572edb04..b8f41cedf4 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1160,6 +1160,8 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 13); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png'); UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '720'); diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index f34d11e8d0..8387d62366 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -86,6 +86,9 @@ if (!empty($config['login_background'])) { $background_url = "images/backgrounds/" . $config['login_background']; $login_body_style = "style=\"background-image: url('$background_url');\""; } +// Get the custom icons +$docs_logo = ui_get_docs_logo(); +$support_logo = ui_get_support_logo(); echo '
'; echo '
'; echo '
'; @@ -102,15 +105,20 @@ echo '
'; echo 'pandora_console'; } echo '
'; - echo '
    '; - echo '
  • docs pandora
  • '; - echo '
  • ' . __('Docs') . '
  • '; - if (file_exists (ENTERPRISE_DIR . "/load_enterprise.php")) { - echo '
  • support pandora
  • '; - } else { - echo '
  • support pandora
  • '; + echo '
    '; diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index d647bc89b1..72efbbf138 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -234,6 +234,52 @@ if(enterprise_installed()) { $row++; } +if(enterprise_installed()){ + // Custom docs icon + $table_styles->data[$row][0] = __('Custom documentation logo'); + $table_styles->data[$row][0] .= ui_print_help_tip(__('You can place your custom logos into the folder enterprise/images/custom_general_logos/'), true); + + $files = list_files('enterprise/images/custom_general_logos', "png", 1, 0); + $table_styles->data[$row][1] = html_print_select( + $files, + 'custom_docs_logo', + $config["custom_docs_logo"], + '', + __('None'), + '', + true, + false, + true, + '', + false, + 'width:240px' + ); + $table_styles->data[$row][1] .= " " . html_print_button(__("View"), 'custom_docs_logo_preview', $open, '', 'class="sub camera"', true,false,$open,'visualmodal'); + $row++; + + // Custom support icon + $table_styles->data[$row][0] = __('Custom support logo'); + $table_styles->data[$row][0] .= ui_print_help_tip(__('You can place your custom logos into the folder enterprise/images/custom_general_logos/'), true); + + $files = list_files('enterprise/images/custom_general_logos', "png", 1, 0); + $table_styles->data[$row][1] = html_print_select( + $files, + 'custom_support_logo', + $config["custom_support_logo"], + '', + __('None'), + '', + true, + false, + true, + '', + false, + 'width:240px' + ); + $table_styles->data[$row][1] .= " " . html_print_button(__("View"), 'custom_support_logo_preview', $open, '', 'class="sub camera"', true,false,$open,'visualmodal'); + $row++; +} + //login title1 if(enterprise_installed()) { $table_styles->data[$row][0] = __('Title 1 (login)'); @@ -1190,6 +1236,88 @@ $("#button-custom_splash_login_preview").click (function (e) { } }); +$("#button-custom_docs_logo_preview").click (function (e) { + var icon_name = $("select#custom_docs_logo option:selected").val(); + var icon_path = "enterprise/images/custom_general_logos/" + icon_name; + + if (icon_name == "") + return; + + $dialog = $("
    "); + $image = $(""); + $image + .css('max-width', '500px') + .css('max-height', '500px'); + + try { + $dialog + .hide() + .html($image) + .dialog({ + title: "", + resizable: true, + draggable: true, + modal: true, + overlay: { + opacity: 0.5, + background: "black" + }, + dialogClass: 'dialog-grayed', + minHeight: 1, + width: $image.width, + close: function () { + $dialog + .empty() + .remove(); + } + }).show(); + } + catch (err) { + // console.log(err); + } +}); + + +$("#button-custom_support_logo_preview").click (function (e) { + var icon_name = $("select#custom_support_logo option:selected").val(); + var icon_path = "enterprise/images/custom_general_logos/" + icon_name; + + if (icon_name == "") + return; + + $dialog = $("
    "); + $image = $(""); + $image + .css('max-width', '500px') + .css('max-height', '500px'); + + try { + $dialog + .hide() + .html($image) + .dialog({ + title: "", + resizable: true, + draggable: true, + modal: true, + overlay: { + opacity: 0.5, + background: "black" + }, + dialogClass: 'dialog-grayed', + minHeight: 1, + width: $image.width, + close: function () { + $dialog + .empty() + .remove(); + } + }).show(); + } + catch (err) { + // console.log(err); + } +}); $("#button-login_background_preview").click (function (e) { var icon_name = $("select#login_background option:selected").val(); diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index b2460b39d3..f572ebd148 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -506,6 +506,10 @@ function config_update_config () { $error_update[] = __('Custom logo login'); if (!config_update_value ('custom_splash_login', (string) get_parameter ('custom_splash_login'))) $error_update[] = __('Custom splash login'); + if (!config_update_value ('custom_docs_logo', (string) get_parameter ('custom_docs_logo'))) + $error_update[] = __('Custom documentation logo'); + if (!config_update_value ('custom_support_logo', (string) get_parameter ('custom_support_logo'))) + $error_update[] = __('Custom support logo'); if (!config_update_value ('custom_title1_login', (string) get_parameter ('custom_title1_login'))) $error_update[] = __('Custom title1 login'); if (!config_update_value ('custom_title2_login', (string) get_parameter ('custom_title2_login'))) @@ -1195,6 +1199,14 @@ function config_process_config () { if (!isset ($config["custom_splash_login"])) { config_update_value ('custom_splash_login', 'splash_image_default.png'); } + + if (!isset ($config["custom_docs_logo"])) { + config_update_value ('custom_docs_logo', ''); + } + + if (!isset ($config["custom_support_logo"])) { + config_update_value ('custom_support_logo', ''); + } if (!isset ($config["custom_title1_login"])) { config_update_value ('custom_title1_login', __('WELCOME TO PANDORA FMS')); diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 4fc40ba611..bfcd3ed44f 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3919,4 +3919,41 @@ function ui_get_snapshot_link($params, $only_params = false) { // Return the function call to inline js execution return "winopeng_var('" . implode("', '", $link_parts) . "')"; } + +/** + * Get the custom docs logo + * + * @return string with the path to logo. False if it should not be displayed + * + */ +function ui_get_docs_logo () { + global $config; + + // Default logo to open version (enterprise_installed function only works in login status) + if (!file_exists (ENTERPRISE_DIR . "/load_enterprise.php")) { + return "images/icono_docs.png"; + } + + if (empty($config['custom_docs_logo'])) return false; + return 'enterprise/images/custom_general_logos/' . $config['custom_docs_logo']; +} + +/** + * Get the custom support logo + * + * @return string with the path to logo. False if it should not be displayed + * + */ +function ui_get_support_logo () { + global $config; + + // Default logo to open version (enterprise_installed function only works in login status) + if (!file_exists (ENTERPRISE_DIR . "/load_enterprise.php")) { + return "images/icono_support.png"; + } + + if (empty($config['custom_support_logo'])) return false; + return 'enterprise/images/custom_general_logos/' . $config['custom_support_logo']; +} + ?> diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 293045208f..c06cdbfed6 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4653,4 +4653,12 @@ form ul.form_flex li ul li{ .pandora_upper { text-transform: uppercase; +} + +.dialog-grayed { + background: #373737 !important; +} + +.dialog-grayed .ui-dialog-buttonpane { + background: #373737 !important; } \ No newline at end of file diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 85b0c84439..fb1de26061 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -113,8 +113,9 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('identification_reminder', 1), ('identification_reminder_timestamp', 0), ('current_package_enterprise', '722'), -('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'); - +('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'), +('custom_docs_logo', 'default_docs.png'), +('custom_support_logo', 'default_support.png'); UNLOCK TABLES; --