Skip to content

Commit

Permalink
Merge pull request #7969 from marcosgdf/bug-4875
Browse files Browse the repository at this point in the history
FIX #4875 Remove external module code from Dolibarr core code - Introduce hook initSendToSocid instead
  • Loading branch information
eldy committed Apr 11, 2018
2 parents 698f5c1 + e468584 commit 6cb0793
Showing 1 changed file with 10 additions and 34 deletions.
44 changes: 10 additions & 34 deletions htdocs/core/actions_sendmails.inc.php
Expand Up @@ -129,38 +129,14 @@
{
$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;

Expand Down Expand Up @@ -479,10 +455,10 @@
$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
{
Expand Down

0 comments on commit 6cb0793

Please sign in to comment.