diff --git a/pandora_console/include/class/TipsWindow.class.php b/pandora_console/include/class/TipsWindow.class.php index 4e8da71712..d306ba01f1 100644 --- a/pandora_console/include/class/TipsWindow.class.php +++ b/pandora_console/include/class/TipsWindow.class.php @@ -44,6 +44,7 @@ class TipsWindow public $AJAXMethods = [ 'getRandomTip', 'renderView', + 'setShowTipsAtStartup', ]; /** @@ -126,6 +127,13 @@ class TipsWindow */ public function run() { + global $config; + $user_info = users_get_user_by_id($config['id_user']); + + if ((bool) $user_info['show_tips_startup'] === false) { + return; + } + ui_require_css_file('tips_window'); ui_require_css_file('jquery.bxslider'); ui_require_javascript_file('tipsWindow'); @@ -146,11 +154,6 @@ class TipsWindow load_tips_modal({ target: $('#tips_window_modal'), url: '', - modal: { - title: '', - next: '', - close: '' - }, onshow: { page: 'ajaxController; ?>', method: 'renderView', @@ -183,7 +186,7 @@ class TipsWindow { $exclude = get_parameter('exclude', ''); - $sql = 'SELECT id, title, text, url + $sql = 'SELECT id, title, text, url FROM twelcome_tip'; if (empty($exclude) === false && $exclude !== null) { @@ -233,4 +236,30 @@ class TipsWindow return db_get_all_rows_sql($sql); } + + + public function setShowTipsAtStartup() + { + global $config; + $show_tips_startup = get_parameter('show_tips_startup', ''); + if ($show_tips_startup !== '' && $show_tips_startup !== null) { + $result = db_process_sql_update( + 'tusuario', + ['show_tips_startup' => $show_tips_startup], + ['id_user' => $config['id_user']] + ); + + if ($result !== false) { + echo json_encode(['success' => true]); + return; + } else { + echo json_encode(['success' => false]); + return; + } + } else { + echo json_encode(['success' => false]); + return; + } + + } } \ No newline at end of file diff --git a/pandora_console/include/javascript/tipsWindow.js b/pandora_console/include/javascript/tipsWindow.js index 0b73e22043..c6693922ad 100644 --- a/pandora_console/include/javascript/tipsWindow.js +++ b/pandora_console/include/javascript/tipsWindow.js @@ -4,6 +4,26 @@ $(".carousel .images").ready(function() { $(".carousel .images").bxSlider({ controls: true }); } }); + +$("#checkbox_tips_startup").ready(function() { + $("#checkbox_tips_startup").on("click", function() { + $.ajax({ + method: "POST", + url: url, + dataType: "json", + data: { + page: page, + method: "setShowTipsAtStartup", + show_tips_startup: this.checked ? "1" : "0" + }, + success: function({ success }) { + if (!success) { + $("#checkbox_tips_startup").prop("checked", true); + } + } + }); + }); +}); function render({ title, text, url, files }) { $("#title_tip").html(title); $("#text_tip").html(text); @@ -124,13 +144,6 @@ function load_tips_modal(settings) { width = settings.onshow.width; } - if (settings.modal.overlay == undefined) { - settings.modal.overlay = { - opacity: 0.5, - background: "black" - }; - } - if (settings.beforeClose == undefined) { settings.beforeClose = function() {}; } @@ -177,7 +190,7 @@ function load_tips_modal(settings) { modal: true, header: false, dialogClass: "dialog_tips", - title: settings.modal.title, + title: "", width: width, minHeight: settings.onshow.minHeight != undefined @@ -187,7 +200,6 @@ function load_tips_modal(settings) { settings.onshow.maxHeight != undefined ? settings.onshow.maxHeight : "auto", - overlay: settings.modal.overlay, position: { my: "top+20%", at: "top", diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 78e2d3163a..c34c4172b4 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -83,6 +83,7 @@ if (isset($_GET['modified']) && !$view_mode) { $upd_info['timezone'] = get_parameter_post('timezone', ''); $upd_info['id_skin'] = get_parameter('skin', $user_info['id_skin']); $upd_info['default_event_filter'] = get_parameter('event_filter', null); + $upd_info['show_tips_startup'] = get_parameter_switch('show_tips_startup'); $upd_info['block_size'] = get_parameter('block_size', $config['block_size']); // API Token information. $apiTokenRenewed = (bool) get_parameter('renewAPIToken'); @@ -539,6 +540,10 @@ if (check_acl($config['id_user'], 0, 'ER')) { ).''; } +$show_tips = '

'.__('Show usage tips at startup').'

'; +$show_tips .= html_print_checkbox_switch('show_tips_startup', 1, $user_info['show_tips_startup'], true).'
'; + + $autorefresh_list_out = []; if (is_metaconsole() === false || is_centralized() === true) { @@ -752,7 +757,7 @@ if (is_metaconsole() === true) {
'.$autorefresh_show.$time_autorefresh.'
-
'.$language.$size_pagination.$skin.$home_screen.$event_filter.$double_authentication.'
+
'.$language.$size_pagination.$skin.$home_screen.$event_filter.$show_tips.$double_authentication.'
'.$timezone; diff --git a/pandora_console/views/dashboard/tipsWindow.php b/pandora_console/views/dashboard/tipsWindow.php index 1a8fa963c4..0fc1ad1a92 100644 --- a/pandora_console/views/dashboard/tipsWindow.php +++ b/pandora_console/views/dashboard/tipsWindow.php @@ -29,8 +29,18 @@ $output = ''; $output .= '
'; $output .= '
'; -$output .= '

'.__('¡Hola! estos son los tips del día.').'

'; -$output .= '

'.html_print_checkbox('tips_in_start', true, true, true).__('Ver típs al iniciar').'

'; +$output .= '

'.__('Hello! These are the tips of the day.').'

'; +$output .= '

'.html_print_checkbox( + 'show_tips_startup', + true, + true, + true, + false, + '', + false, + '', + 'checkbox_tips_startup' +).__('Show usage tips at startup').'

'; $output .= '
'; $output .= '
'; $output .= '
'; @@ -51,19 +61,19 @@ $output .= $text; $output .= '

'; if (empty($url) === false && $url !== '') { - $output .= ''.__('Ver más info').''; + $output .= ''.__('See more info').''; } $output .= '
'; $output .= '
'; // TODO Delete this buttons and use html_print_button when merge new design -$output .= ''; +$output .= ''; $output .= '
'; $output .= html_print_image('images/arrow-left-grey.png', true, ['class' => 'arrow-counter']); $output .= html_print_image('images/arrow-right-grey.png', true, ['class' => 'arrow-counter']); $output .= '
'; -$output .= ''; +$output .= ''; $output .= '
'; $output .= '
'; echo $output;