Merge pull request #7969 from marcosgdf/bug-4875
FIX #4875 Remove external module code from Dolibarr core code - Introduce hook initSendToSocid instead
This commit is contained in:
commit
6cb0793d14
@ -129,38 +129,14 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
{
|
||||
$thirdparty=$object;
|
||||
if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
|
||||
elseif (! empty($conf->dolimail->enabled))
|
||||
{
|
||||
$dolimail = new Dolimail($db);
|
||||
$possibleaccounts=$dolimail->get_societe_by_email($_POST['sendto'],"1");
|
||||
$possibleuser=$dolimail->get_from_user_by_mail($_POST['sendto'],"1"); // suche in llx_societe and socpeople
|
||||
if (!$possibleaccounts && !$possibleuser)
|
||||
{
|
||||
setEventMessages($langs->trans('ErrorFailedToFindSocieteRecord',$_POST['sendto']), null, 'errors');
|
||||
}
|
||||
elseif (count($possibleaccounts)>1)
|
||||
{
|
||||
$sendtosocid=$possibleaccounts[1]['id'];
|
||||
$result=$object->fetch($sendtosocid);
|
||||
|
||||
setEventMessages($langs->trans('ErrorFoundMoreThanOneRecordWithEmail',$_POST['sendto'],$object->name), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
if($possibleaccounts){
|
||||
$sendtosocid=$possibleaccounts[1]['id'];
|
||||
$result=$object->fetch($sendtosocid);
|
||||
}elseif($possibleuser){
|
||||
$sendtosocid=$possibleuser[0]['id'];
|
||||
|
||||
$result=$uobject->fetch($sendtosocid);
|
||||
$object=$uobject;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported');
|
||||
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('initSendToSocid',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
}
|
||||
}
|
||||
else $thirdparty = $mysoc;
|
||||
|
||||
@ -479,10 +455,10 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
|
||||
setEventMessages($mesg, null, 'mesgs');
|
||||
|
||||
$moreparam='';
|
||||
if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2;
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam);
|
||||
exit;
|
||||
$moreparam='';
|
||||
if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2;
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user