FIX Scan IMAP must not be done automatically

This commit is contained in:
Laurent Destailleur 2022-08-04 13:42:57 +02:00
parent 9c87b56863
commit 39dccc4fdf

View File

@ -378,6 +378,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$connectstringserver = $object->getConnectStringIMAP($usessl); $connectstringserver = $object->getConnectStringIMAP($usessl);
if ($action == 'scan') {
try { try {
if ($sourcedir) { if ($sourcedir) {
//$connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir); //$connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir);
@ -407,11 +408,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print $e->getMessage(); print $e->getMessage();
} }
$morehtml .= $form->textwithpicto('', 'connect string '.$connectstringserver);
} else {
$morehtml .= 'IMAP functions not available on your PHP. ';
}
if (!$connection) { if (!$connection) {
$morehtml .= 'Failed to open IMAP connection '.$connectstringsource; $morehtml .= 'Failed to open IMAP connection '.$connectstringsource;
if (function_exists('imap_last_error')) { if (function_exists('imap_last_error')) {
@ -428,6 +424,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
dol_syslog("Imap close"); dol_syslog("Imap close");
imap_close($connection); imap_close($connection);
} }
} else {
$morehtml .= '<a class="flat" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=scan&token='.newToken().'">'.img_picto('', 'refresh', 'class="paddingrightonly"').$langs->trans("Refresh").'</a>';
}
$morehtml .= $form->textwithpicto('', 'connect string '.$connectstringserver);
} else {
$morehtml .= 'IMAP functions not available on your PHP. ';
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref.'<div class="refidno">'.$morehtml.'</div>', '', 0, '', '', 0, ''); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref.'<div class="refidno">'.$morehtml.'</div>', '', 0, '', '', 0, '');