Fixes
This commit is contained in:
parent
7c50cc9c72
commit
c6e66d1651
@ -39,7 +39,7 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP
|
|||||||
print 'var login = \''.$_SESSION['dol_login'].'\';'."\n";
|
print 'var login = \''.$_SESSION['dol_login'].'\';'."\n";
|
||||||
print 'var nowtime = Date.now();';
|
print 'var nowtime = Date.now();';
|
||||||
print 'var time_auto_update = '.$conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY.';'."\n"; // Always defined
|
print 'var time_auto_update = '.$conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY.';'."\n"; // Always defined
|
||||||
print 'var time_js_next_test = (nowtime + time_auto_update);'."\n";
|
print 'var time_js_next_test;'."\n";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
/* Check if permission ok */
|
/* Check if permission ok */
|
||||||
@ -53,25 +53,28 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP
|
|||||||
//var time_first_execution = (time_auto_update + (time_js_next_test - nowtime)) * 1000; //need milliseconds
|
//var time_first_execution = (time_auto_update + (time_js_next_test - nowtime)) * 1000; //need milliseconds
|
||||||
var time_first_execution = <?php echo max(3, $conf->global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION); ?>;
|
var time_first_execution = <?php echo max(3, $conf->global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION); ?>;
|
||||||
if (login != '') {
|
if (login != '') {
|
||||||
console.log("Launch browser notif check: setTimeout is set to launch 'first_execution' function after a wait of time_first_execution="+time_first_execution+". nowtime (time php page generation) = "+nowtime+" time_js_next_test = "+time_js_next_test+" time_auto_update="+time_auto_update);
|
setTimeout(first_execution, time_first_execution * 1000);
|
||||||
setTimeout(first_execution, time_first_execution);
|
time_js_next_test = nowtime + time_first_execution;
|
||||||
|
console.log("Launch browser notif check: setTimeout is set to launch 'first_execution' function after a wait of time_first_execution="+time_first_execution+". nowtime (time php page generation) = "+nowtime+" time_js_next_check = "+time_js_next_test);
|
||||||
} //first run auto check
|
} //first run auto check
|
||||||
|
|
||||||
|
|
||||||
function first_execution() {
|
function first_execution() {
|
||||||
console.log("Call first_execution time_auto_update (MAIN_BROWSER_NOTIFICATION_FREQUENCY) = "+time_auto_update);
|
console.log("Call first_execution then set repeat time to time_auto_update = MAIN_BROWSER_NOTIFICATION_FREQUENCY = "+time_auto_update);
|
||||||
check_events(); //one check before launching timer to launch other checks
|
check_events(); //one check before setting the new time for other checks
|
||||||
setInterval(check_events, time_auto_update * 1000); //program time to run next check events
|
setInterval(check_events, time_auto_update * 1000); // Set new time to run next check events
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_events() {
|
function check_events() {
|
||||||
if (Notification.permission === "granted")
|
if (Notification.permission === "granted")
|
||||||
{
|
{
|
||||||
console.log("Call check_events time_js_next_test = date we are looking for event after this date = "+time_js_next_test);
|
time_js_next_test += time_auto_update;
|
||||||
|
console.log("Call ajax to check_events with time_js_next_test = "+time_js_next_test);
|
||||||
|
|
||||||
$.ajax("<?php print DOL_URL_ROOT.'/core/ajax/check_notifications.php'; ?>", {
|
$.ajax("<?php print DOL_URL_ROOT.'/core/ajax/check_notifications.php'; ?>", {
|
||||||
type: "post", // Usually post or get
|
type: "post", // Usually post or get
|
||||||
async: true,
|
async: true,
|
||||||
data: {time: time_js_next_test},
|
data: { time_js_next_test: time_js_next_test },
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
var arr = JSON.parse(result);
|
var arr = JSON.parse(result);
|
||||||
if (arr.length > 0) {
|
if (arr.length > 0) {
|
||||||
@ -130,9 +133,9 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP
|
|||||||
// Update status of all notifications we sent on browser (listofreminderids)
|
// Update status of all notifications we sent on browser (listofreminderids)
|
||||||
console.log("Flag notification as done for listofreminderids="+listofreminderids);
|
console.log("Flag notification as done for listofreminderids="+listofreminderids);
|
||||||
$.ajax("<?php print DOL_URL_ROOT.'/core/ajax/check_notifications.php?action=stopreminder&listofreminderids='; ?>"+listofreminderids, {
|
$.ajax("<?php print DOL_URL_ROOT.'/core/ajax/check_notifications.php?action=stopreminder&listofreminderids='; ?>"+listofreminderids, {
|
||||||
type: "get", // Usually post or get
|
type: "post", // Usually post or get
|
||||||
async: true,
|
async: true,
|
||||||
data: {time: time_js_next_test}
|
data: { time_js_next_test: time_js_next_test }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,9 +145,6 @@ if (!($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root.'/' || $_SERVER['HTTP
|
|||||||
{
|
{
|
||||||
console.log("Cancel check_events. Useless because javascript Notification.permission is "+Notification.permission+" (blocked manualy or web site is not https).");
|
console.log("Cancel check_events. Useless because javascript Notification.permission is "+Notification.permission+" (blocked manualy or web site is not https).");
|
||||||
}
|
}
|
||||||
|
|
||||||
time_js_next_test += time_auto_update;
|
|
||||||
console.log('Updated time_js_next_test. New value is '+time_js_next_test);
|
|
||||||
}
|
}
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|||||||
@ -373,6 +373,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl
|
|||||||
//if ($conf->global->MAIN_FEATURES_LEVEL >= 1) setEventMessages('Unset POST and GET params by CSRF protection in main.inc.php (Token provided was not generated by the previous page).'."<br>\n".'$_SERVER[REQUEST_URI] = '.$_SERVER['REQUEST_URI'].' $_SERVER[REQUEST_METHOD] = '.$_SERVER['REQUEST_METHOD'].' GETPOST(token) = '.GETPOST('token', 'alpha').' $_SESSION[token] = '.$_SESSION['token'], null, 'warnings');
|
//if ($conf->global->MAIN_FEATURES_LEVEL >= 1) setEventMessages('Unset POST and GET params by CSRF protection in main.inc.php (Token provided was not generated by the previous page).'."<br>\n".'$_SERVER[REQUEST_URI] = '.$_SERVER['REQUEST_URI'].' $_SERVER[REQUEST_METHOD] = '.$_SERVER['REQUEST_METHOD'].' GETPOST(token) = '.GETPOST('token', 'alpha').' $_SESSION[token] = '.$_SESSION['token'], null, 'warnings');
|
||||||
unset($_POST);
|
unset($_POST);
|
||||||
unset($_GET['confirm']);
|
unset($_GET['confirm']);
|
||||||
|
unset($_GET['action']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user