Skip to content

Commit

Permalink
Merge branch 'develop' into fix/ignored_phpstan_61
Browse files Browse the repository at this point in the history
  • Loading branch information
frederic34 authored Oct 1, 2024
2 parents 942896f + 6b2fa56 commit 34c2678
Show file tree
Hide file tree
Showing 76 changed files with 736 additions and 427 deletions.
1 change: 1 addition & 0 deletions htdocs/admin/accountant.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
$("#selectcountry_id").change(function() {
console.log("selectcountry_id change");
document.form_index.action.value="updateedit";
document.form_index.submit();
});
Expand Down
4 changes: 2 additions & 2 deletions htdocs/admin/agenda_other.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'</td>'."\n";
print '<td class="center">&nbsp;</td>'."\n";
print '<td class="right nowrap">'."\n";
$formactions->select_type_actions(getDolGlobalString('AGENDA_USE_EVENT_TYPE_DEFAULT'), "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1);
print $formactions->select_type_actions(getDolGlobalString('AGENDA_USE_EVENT_TYPE_DEFAULT'), "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1, 0, 1, 'minwidth300', 1);
print '</td></tr>'."\n";
}

Expand Down Expand Up @@ -401,7 +401,7 @@
// We use an option here because it adds bugs when used on agenda page "peruser" and "list"
$multiselect = (getDolGlobalString('AGENDA_USE_EVENT_TYPE'));
}
$formactions->select_type_actions(getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE'), "AGENDA_DEFAULT_FILTER_TYPE", '', (getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? -1 : 1), 1, $multiselect);
print $formactions->select_type_actions(getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE'), "AGENDA_DEFAULT_FILTER_TYPE", '', (getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? -1 : 1), 1, $multiselect, 1, 'minwidth300', 1);
print '</td></tr>'."\n";

// AGENDA_DEFAULT_FILTER_STATUS
Expand Down
2 changes: 2 additions & 0 deletions htdocs/admin/agenda_reminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
print '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER&token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
print '</td></tr>'."\n";

/* This feature need to use the old method AGENDA_NOTIFICATION_METHOD = 'jsnotification' that is broken on a lot of browser setup
print '<tr class="oddeven">'."\n";
print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').'</td>'."\n";
print '<td class="center">&nbsp;</td>'."\n";
Expand All @@ -202,6 +203,7 @@
}
print '</td></tr>'."\n";
*/
}

$job = new Cronjob($db);
Expand Down
1 change: 1 addition & 0 deletions htdocs/admin/company.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
$("#selectcountry_id").change(function() {
console.log("selectcountry_id change");
document.form_index.action.value="updateedit";
document.form_index.submit();
});
Expand Down
4 changes: 2 additions & 2 deletions htdocs/admin/mails.php
Original file line number Diff line number Diff line change
Expand Up @@ -1092,12 +1092,12 @@ function change_smtp_auth_method() {
if (($dnstype == 'SPF' && stripos($info['txt'], 'v=spf') !== false)
|| ($dnstype == 'DMARC' && stripos($info['txt'], 'v=dmarc') !== false)) {
$foundforemail++;
$text .= ($text ? '<br>' : '').$langs->trans("ActualMailDNSRecordFound", $dnstype, implode(', ', $listofemails), $info['txt']);
$text .= ($text ? '<br>' : '').'- '.$langs->trans("ActualMailDNSRecordFound", '<b>'.$dnstype.'</b>', '<b>'.implode(', ', $listofemails).'</b>', '<span class="opacitylow">'.$info['txt'].'</span>');
}
}
}
if (!$foundforemail) {
$text .= ($text ? '<br>' : '').$langs->trans("ActualMailDNSRecordFound", $dnstype, implode(', ', $listofemails), '<span class="opacitymedium">'.$langs->transnoentitiesnoconv("None").'</span>');
$text .= ($text ? '<br>' : '').'- '.$langs->trans("ActualMailDNSRecordFound", '<b>'.$dnstype.'</b>', '<b>'.implode(', ', $listofemails).'</b>', '<span class="opacitymedium">'.$langs->transnoentitiesnoconv("None").'</span>');
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions htdocs/admin/system/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
print '<tr class="oddeven"><td width="300">'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $dolibarr_main_db_pass).'</td></tr>'."\n";
print '<tr class="oddeven"><td width="300">'.$langs->trans("DBStoringCharset").'</td><td>'.$db->getDefaultCharacterSetDatabase();
if ($db->type == 'mysqli') {
print ' '.$form->textwithpicto('', $langs->transnoentitiesnoconv("HelpMariaDBToGetValue", "<br>SHOW VARIABLES LIKE 'character_set_database' (cached)<br>You can avoid cache effect with:<br>SELECT DEFAULT_CHARACTER_SET_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = '".$conf->db->name."'").'<br>'.$langs->transnoentitiesnoconv("HelpMariaDBToGetPossibleValues", "<br>SHOW CHARSET"));
$tooltipexample = "<br>SHOW VARIABLES LIKE 'character_set_database' (cached)<br>You can avoid cache effect with:<br>SELECT DEFAULT_CHARACTER_SET_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = '".$db->escape($conf->db->name)."'";
print ' '.$form->textwithpicto('', $langs->transnoentitiesnoconv("HelpMariaDBToGetValue", $tooltipexample.'<br>'.$langs->transnoentitiesnoconv("HelpMariaDBToGetPossibleValues", "<br>SHOW CHARSET")));
// We can use $db->getDefaultCharacterSetDatabase(), $db->getListOfCharacterSet(),
}
print '</td></tr>'."\n";
Expand All @@ -93,7 +94,8 @@
if ($defaultcollation != $dolibarr_main_db_collation) {

Check warning on line 94 in htdocs/admin/system/database.php

View workflow job for this annotation

GitHub Actions / phan / Run phan

database.php: PhanUndeclaredGlobalVariable: Global variable $dolibarr_main_db_collation is undeclared
print img_warning('The database default value of collation '.$defaultcollation.' differs from conf setup '.$dolibarr_main_db_collation);

Check warning on line 95 in htdocs/admin/system/database.php

View workflow job for this annotation

GitHub Actions / phan / Run phan

database.php: PhanUndeclaredGlobalVariable: Global variable $dolibarr_main_db_collation is undeclared
}
print ' '.$form->textwithpicto('', $langs->transnoentitiesnoconv("HelpMariaDBToGetValue", "<br>SHOW VARIABLES LIKE 'collation_database' (cached)<br>You can avoid cache effect with:<br>SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = '".$conf->db->name."'").'<br>'.$langs->transnoentitiesnoconv("HelpMariaDBToGetPossibleValues", "<br>SHOW COLLATION"));
$tooltipexample = "<br>SHOW VARIABLES LIKE 'collation_database' (cached)<br>You can avoid cache effect with:<br>SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = '".$db->escape($conf->db->name)."'";
print ' '.$form->textwithpicto('', $langs->transnoentitiesnoconv("HelpMariaDBToGetValue", $tooltipexample.'<br>'.$langs->transnoentitiesnoconv("HelpMariaDBToGetPossibleValues", "<br>SHOW COLLATION")));
// We can use $db->getDefaultCollationDatabase(), $db->getListOfCollation();

print ' &nbsp; &nbsp; &nbsp; <span class="opacitymedium small">'.$langs->trans("ConvertInto");
Expand Down
10 changes: 5 additions & 5 deletions htdocs/comm/action/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1399,15 +1399,15 @@ function init_repeat()
print '</td></tr>';

$datep = ($datep ? $datep : (is_null($object->datep) ? '' : $object->datep));
if (GETPOSTINT('datep', 1)) {
$datep = dol_stringtotime((string) GETPOSTINT('datep', 1), 'tzuserrel');
if (GETPOST('datep', 'alpha', 1)) {
$datep = dol_stringtotime(GETPOST('datep', 'alpha', 1), 'tzuserrel');
}
$datef = ($datef ? $datef : $object->datef);
if (GETPOSTINT('datef', 1)) {
$datef = dol_stringtotime((string) GETPOSTINT('datef', 1), 'tzuserrel');
if (GETPOST('datef', 'alpha', 1)) {
$datef = dol_stringtotime(GETPOST('datef', 'alpha', 1), 'tzuserrel');
}
if (empty($datef) && !empty($datep)) {
if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || !getDolGlobalString('AGENDA_USE_EVENT_TYPE_DEFAULT')) {
if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || (!getDolGlobalString('AGENDA_USE_EVENT_TYPE_DEFAULT') || getDolGlobalString('AGENDA_USE_EVENT_TYPE_DEFAULT') == '-1')) {
$datef = dol_time_plus_duree($datep, getDolGlobalInt('AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS', 1), 'h');
}
}
Expand Down
5 changes: 4 additions & 1 deletion htdocs/comm/action/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
} else {
$actioncode = GETPOST("search_actioncode", "alpha", 3) ? GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : ((!getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE') || $disabledefaultvalues) ? '' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE')));
}
if (is_scalar($actioncode) && $actioncode == '-1') {
$actioncode = '';
}

if ($status == '' && !GETPOSTISSET('search_status')) {
$status = ((!getDolGlobalString('AGENDA_DEFAULT_FILTER_STATUS') || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
Expand Down Expand Up @@ -286,7 +289,7 @@
}

// Define list of external calendars (user setup)
if (empty($user->conf->AGENDA_DISABLE_EXT)) {
if (!getDolUserString('AGENDA_DISABLE_EXT')) {
$i = 0;
while ($i < $MAXAGENDA) {
$i++;
Expand Down
9 changes: 5 additions & 4 deletions htdocs/core/js/lib_foot.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
if ($conf->browser->layout != 'phone') {
print "\n/* JS CODE TO ENABLE document_preview */\n"; // Function document_preview is into header
print ' jQuery(document).ready(function () {
// Click on the preview picto
jQuery(".documentpreview").click(function () {
console.log("We click on preview for element with href="+$(this).attr(\'href\')+" mime="+$(this).attr(\'mime\'));
document_preview($(this).attr(\'href\'), $(this).attr(\'mime\'), \''.dol_escape_js($langs->transnoentities("Preview")).'\');
Expand Down Expand Up @@ -387,15 +388,15 @@ function() {
text: confirmActionBtnLabel,
"class": \'ui-state-information\',
click: function () {
window.location.replace(confirmUrl);
}
window.location.replace(confirmUrl);
}
},
{
text: confirmCancelBtnLabel,
"class": \'ui-state-information\',
click: function () {
$(this).dialog("close");
}
$(this).dialog("close");
}
}
],
close: function( event, ui ) {
Expand Down
128 changes: 84 additions & 44 deletions htdocs/core/js/lib_notification.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@

// We set a delay before launching first test so next check will arrive after the time_auto_update compared to previous one.
//var time_first_execution = (time_auto_update + (time_js_next_test - nowtime)) * 1000; //need milliseconds
var time_first_execution = <?php echo max(3, !getDolGlobalString('MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION') ? 0 : $conf->global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION); ?>;
var time_first_execution = <?php echo max(3, getDolGlobalInt('MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION', 0)); ?>;

setTimeout(first_execution, time_first_execution * 1000); // Launch a first execution after a time_first_execution delay
time_js_next_test = nowtime + time_first_execution;
Expand All @@ -112,8 +112,17 @@ function first_execution() {
function check_events() {
var result = 0;
dolnotif_nb_test_for_page += 1;
var methodfornotification = '<?php print getDolUserString('AGENDA_NOTIFICATION_METHOD', getDolGlobalString('AGENDA_NOTIFICATION_METHOD', 'jnotify')); ?>';

if (Notification.permission === "granted") {
permissionok = 0;
if (methodfornotification == "jsnotification" && Notification.permission == "granted") {
permissionok = 1;
}
if (methodfornotification == "jnotify") {
permissionok = 1;
}

if (permissionok == 1) {
var currentToken = 'notrequired';
const allMeta = document.getElementsByTagName("meta");
for (let i = 0; i < allMeta.length; i++) {
Expand All @@ -138,72 +147,103 @@ function check_events() {
console.log("Retrieved "+arrayofpastreminders.length+" reminders to do.");
var audio = null;
<?php
if (getDolGlobalString('AGENDA_REMINDER_BROWSER_SOUND')) {
if (getDolUserString('AGENDA_REMINDER_BROWSER_SOUND', getDolGlobalString('AGENDA_REMINDER_BROWSER_SOUND'))) {
print 'audio = new Audio(\''.DOL_URL_ROOT.'/theme/common/sound/notification_agenda.wav\');';
}
?>
var icon = '<?php print DOL_URL_ROOT.'/theme/common/octicons/build/svg/bell.svg'; ?>';
var listofreminderids = '';
var noti = []

$.each(arrayofpastreminders, function (index, value) {
console.log(value);
var url = "notdefined";
var title = "Not defined";
var body = value.label;
var icon = '<?php print DOL_URL_ROOT.'/theme/common/octicons/build/svg/bell.svg'; ?>';
var image = '<?php print DOL_URL_ROOT.'/theme/common/octicons/build/svg/bell.svg'; ?>';
if (value.type == 'agenda' && value.location != null && value.location != '') {
body += '\n' + value.location;
}

if (value.type == 'agenda' && (value.event_date_start_formated != null || value.event_date_start_formated['event_date_start'] != '')) {
body += '\n' + value.event_date_start_formated;
}
var body = "";

if (value.type == 'agenda')
{
url = '<?php print DOL_URL_ROOT.'/comm/action/card.php?id='; ?>' + value.id_agenda;
title = '<?php print dol_escape_js($langs->transnoentities('EventReminder')) ?>';
}
var extra = {
icon: icon,
body: body,
lang: '<?php print dol_escape_js($langs->getDefaultLang(1)); ?>',
tag: value.id_agenda,
requireInteraction: true /* wait that the user click or close the notification */
/* only supported for persistent notification shown using ServiceWorkerRegistration.showNotification() so disabled */
/* actions: [{ action: 'action1', title: 'New Button Label' }, { action: 'action2', title: 'Another Button' }] */
};

// We release the notify
console.log("Send notification on browser url="+url);
noti[index] = new Notification(title, extra);
if (index==0 && audio)
{
audio.play();
if (methodfornotification == "jsnotification") {
body = value.label;
if (value.type == 'agenda' && value.location != null && value.location != '') {
body += '\n' + value.location;
}

if (value.type == 'agenda' && (value.event_date_start_formated != null || value.event_date_start_formated['event_date_start'] != '')) {
body += '\n' + value.event_date_start_formated;
}
} else {
if (title != "Not defined") {
body = title+'<br><br>';
}
body += '<img src="'+icon+'">';
if (value.type == 'agenda' && (value.event_date_start_formated != null || value.event_date_start_formated['event_date_start'] != '')) {
body += ' '+value.event_date_start_formated;
}
body += ' - <a href="'+url+'"><?php echo img_picto("", "url", 'class="pictofixedwidth"').dol_escape_js($langs->trans("ShowDetails")); ?></a>';
body += '<br>'+value.label;
if (value.type == 'agenda' && value.location != null && value.location != '') {
body += '<br>' + value.location;
}
}

if (noti[index]) {
noti[index].onclick = function (event) {
/* If the user has clicked on button Activate */
console.log("A click on notification on browser has been done for url="+url);
event.preventDefault(); // prevent the browser from focusing the Notification's tab
window.focus();
window.open(url, '_blank');
noti[index].close();
// We release the notify
console.log("Send notification on browser url="+url+" using method="+methodfornotification);

// Using the js browser Notification() popup
if (methodfornotification == 'jsnotification') {
var extra = {
icon: icon,
body: body,
lang: '<?php print dol_escape_js($langs->getDefaultLang(1)); ?>',
tag: value.id_agenda,
requireInteraction: true /* wait that the user click or close the notification */
/* "actions:" parameter is only supported for persistent notification shown using ServiceWorkerRegistration.showNotification() so disabled */
/* actions: [{ action: 'action1', title: 'New Button Label' }, { action: 'action2', title: 'Another Button' }] */
};

noti[index] = new Notification(title, extra);
if (index==0 && audio)
{
audio.play();
}

if (noti[index]) {
noti[index].onclick = function (event) {
/* If the user has clicked on button Activate */
console.log("A click on notification on browser has been done for url="+url);
event.preventDefault(); // prevent the browser from focusing the Notification's tab
window.focus();
window.open(url, '_blank');
noti[index].close();
};

listofreminderids = (listofreminderids == '' ? '' : listofreminderids + ',') + value.id_reminder
}
}

// Using jNotify popup
if (methodfornotification == 'jnotify') {
// Output a message with level "warning"
$.jnotify(body, 'warning', true, { remove: function (){} } );

listofreminderids = (listofreminderids == '' ? '' : listofreminderids + ',') + value.id_reminder
}
});

// Update status of all notifications we sent on browser (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, {
type: "POST", // Usually post or get
async: true,
data: { time_js_next_test: time_js_next_test, token: currentToken }
});
if (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, {
type: "POST",
async: true,
data: { time_js_next_test: time_js_next_test, token: currentToken }
});
}
} else {
console.log("No remind to do found, next search at "+time_js_next_test);
}
Expand All @@ -212,9 +252,9 @@ function check_events() {

result = 1;
} else {
console.log("Cancel check_events() with dolnotif_nb_test_for_page="+dolnotif_nb_test_for_page+". Check is useless because javascript Notification.permission is "+Notification.permission+" (blocked manually or web site is not https or browser is in Private mode).");
console.log("Cancel check_events() with dolnotif_nb_test_for_page="+dolnotif_nb_test_for_page+". Check is useless because permission is off. Javascript Notification.permission is "+Notification.permission+" (blocked manually or web site is not https or browser is in Private mode).");

result = 2; // We return a positive so the repeated check will done even if authorization is not yet allowed may be after this check)
result = 2; // We return a positive so the repeated check will be done even if authorization is not yet allowed may be after this check)
}

if (dolnotif_nb_test_for_page >= 5) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/lib/agenda.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function print_actions_filter(
$multiselect = (getDolGlobalString('AGENDA_USE_EVENT_TYPE'));
}
print img_picto($langs->trans("ActionType"), 'square', 'class="pictofixedwidth inline-block" style="color: #ddd;"');
print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 1 : -1), 0, $multiselect, 0, 'minwidth200 maxwidth250 widthcentpercentminusx');
print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? -1 : 1), 0, $multiselect, 0, 'minwidth200 maxwidth250 widthcentpercentminusx', 1);
print '</div>';

if ($canedit) {
Expand Down
Loading

0 comments on commit 34c2678

Please sign in to comment.