Fix problem in some vars as reported in #8955

This commit is contained in:
Laurent Destailleur 2018-07-16 09:57:45 +02:00
parent 2cf28e055b
commit 6846ff7d21

View File

@ -279,9 +279,12 @@ class Notify
* *
* @param string $notifcode Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage) * @param string $notifcode Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
* @param Object $object Object the notification deals on * @param Object $object Object the notification deals on
* @param array $filename_list List of files to attach (full path of filename on file system)
* @param array $mimetype_list List of MIME type of attached files
* @param array $mimefilename_list List of attached file name in message
* @return int <0 if KO, or number of changes if OK * @return int <0 if KO, or number of changes if OK
*/ */
function send($notifcode, $object) function send($notifcode, $object, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array())
{ {
global $user,$conf,$langs,$mysoc; global $user,$conf,$langs,$mysoc;
global $hookmanager; global $hookmanager;
@ -310,8 +313,6 @@ class Notify
$application = 'Dolibarr'; $application = 'Dolibarr';
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $application = $conf->global->MAIN_APPLICATION_TITLE; if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $application = $conf->global->MAIN_APPLICATION_TITLE;
$replyto = $conf->notification->email_from; $replyto = $conf->notification->email_from;
$filename = basename($file);
$mimefile = dol_mimetype($file);
$object_type = ''; $object_type = '';
$link = ''; $link = '';
$num = 0; $num = 0;
@ -462,7 +463,7 @@ class Notify
$message.= $mesg; $message.= $mesg;
if ($link) $message.= "\n" . $urlwithroot . $link; if ($link) $message.= "\n" . $urlwithroot . $link;
$parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$file, 'mimefile'=>$mimefile, 'filename'=>$filename); $parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list);
$reshook=$hookmanager->executeHooks('formatNotificationMessage',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('formatNotificationMessage',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) if (empty($reshook))
{ {
@ -475,9 +476,9 @@ class Notify
$sendto, $sendto,
$replyto, $replyto,
$message, $message,
array($file), $filename_list,
array($mimefile), $mimetype_list,
array($filename[count($filename)-1]), $mimefilename_list,
'', '',
'', '',
0, 0,
@ -671,7 +672,7 @@ class Notify
if ($sendto) if ($sendto)
{ {
$parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$file, 'mimefile'=>$mimefile, 'filename'=>$filename); $parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list);
$reshook=$hookmanager->executeHooks('formatNotificationMessage',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('formatNotificationMessage',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) if (empty($reshook))
{ {
@ -683,9 +684,9 @@ class Notify
$sendto, $sendto,
$replyto, $replyto,
$message, $message,
array($file), $filename_list,
array($mimefile), $mimetype_list,
array($filename[count($filename)-1]), $mimefilename_list,
'', '',
'', '',
0, 0,