#9073 added token for tips in user profile configuration
This commit is contained in:
parent
887d2f8f18
commit
dfb93d2cf5
|
@ -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: '<?php echo ui_get_full_url('ajax.php'); ?>',
|
||||
modal: {
|
||||
title: '<?php echo __('Hola! estos son los tips del día'); ?>',
|
||||
next: '<?php echo __('De acuerdo'); ?>',
|
||||
close: '<?php echo __('Quizás luego'); ?>'
|
||||
},
|
||||
onshow: {
|
||||
page: '<?php echo $this->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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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",
|
||||
|
|
|
@ -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')) {
|
|||
).'</div>';
|
||||
}
|
||||
|
||||
$show_tips = '<div class="label_select_simple"><p class="edit_user_labels">'.__('Show usage tips at startup').'</p>';
|
||||
$show_tips .= html_print_checkbox_switch('show_tips_startup', 1, $user_info['show_tips_startup'], true).'</div>';
|
||||
|
||||
|
||||
|
||||
$autorefresh_list_out = [];
|
||||
if (is_metaconsole() === false || is_centralized() === true) {
|
||||
|
@ -752,7 +757,7 @@ if (is_metaconsole() === true) {
|
|||
<div class="edit_user_autorefresh white_box">'.$autorefresh_show.$time_autorefresh.'</div>
|
||||
</div>
|
||||
<div class="user_edit_second_row white_box">
|
||||
<div class="edit_user_options">'.$language.$size_pagination.$skin.$home_screen.$event_filter.$double_authentication.'</div>
|
||||
<div class="edit_user_options">'.$language.$size_pagination.$skin.$home_screen.$event_filter.$show_tips.$double_authentication.'</div>
|
||||
<div class="edit_user_timezone">'.$timezone;
|
||||
|
||||
|
||||
|
|
|
@ -29,8 +29,18 @@ $output = '';
|
|||
|
||||
$output .= '<div class="window">';
|
||||
$output .= '<div class="tips_header">';
|
||||
$output .= '<p class="title">'.__('¡Hola! estos son los tips del día.').'</p>';
|
||||
$output .= '<p>'.html_print_checkbox('tips_in_start', true, true, true).__('Ver típs al iniciar').'</p>';
|
||||
$output .= '<p class="title">'.__('Hello! These are the tips of the day.').'</p>';
|
||||
$output .= '<p>'.html_print_checkbox(
|
||||
'show_tips_startup',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
'',
|
||||
'checkbox_tips_startup'
|
||||
).__('Show usage tips at startup').'</p>';
|
||||
$output .= '</div>';
|
||||
$output .= '<div class="carousel'.(($files === false) ? 'invisible' : '').'">';
|
||||
$output .= '<div class="images">';
|
||||
|
@ -51,19 +61,19 @@ $output .= $text;
|
|||
$output .= '</p>';
|
||||
|
||||
if (empty($url) === false && $url !== '') {
|
||||
$output .= '<a href="'.$url.'" id="url_tip">'.__('Ver más info').'<span class="arrow_tips">→</span></a>';
|
||||
$output .= '<a href="'.$url.'" id="url_tip">'.__('See more info').'<span class="arrow_tips">→</span></a>';
|
||||
}
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
$output .= '<div class="ui-dialog-buttonset">';
|
||||
// TODO Delete this buttons and use html_print_button when merge new design
|
||||
$output .= '<button type="button" class="submit-cancel-tips ui-button ui-corner-all ui-widget" onclick="close_dialog()">Quizás luego</button>';
|
||||
$output .= '<button type="button" class="submit-cancel-tips ui-button ui-corner-all ui-widget" onclick="close_dialog()">Maybe later</button>';
|
||||
$output .= '<div class="counter-tips">';
|
||||
$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 .= '</div>';
|
||||
$output .= '<button type="button" class="submit-next-tips ui-button ui-corner-all ui-widget" onclick="next_tip()">De acuerdo</button>';
|
||||
$output .= '<button type="button" class="submit-next-tips ui-button ui-corner-all ui-widget" onclick="next_tip()">Ok</button>';
|
||||
$output .= '</div>';
|
||||
$output .= '</div>';
|
||||
echo $output;
|
||||
|
|
Loading…
Reference in New Issue