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).''.__('¡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 .= '