Skip to content

Commit

Permalink
Fix the from robot must be visible only on test page
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Nov 25, 2017
1 parent 3d48e50 commit 5935ad8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
5 changes: 3 additions & 2 deletions htdocs/admin/mails.php
Original file line number Diff line number Diff line change
Expand Up @@ -728,12 +728,13 @@ function initfields()
// Cree l'objet formulaire mail
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->trackid=(($action == 'testhtml')?"testhtml":"test");
$formmail->fromname = (isset($_POST['fromname'])?$_POST['fromname']:$conf->global->MAIN_MAIL_EMAIL_FROM);
$formmail->frommail = (isset($_POST['frommail'])?$_POST['frommail']:$conf->global->MAIN_MAIL_EMAIL_FROM);
$formmail->fromid=$user->id;
$formmail->trackid=(($action == 'testhtml')?"testhtml":"test");
$formmail->withfromreadonly=1;
$formmail->fromalsorobot=1;
$formmail->fromtype=(GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
$formmail->withfromreadonly=1;
$formmail->withsubstit=0;
$formmail->withfrom=1;
$formmail->witherrorsto=1;
Expand Down
23 changes: 13 additions & 10 deletions htdocs/core/class/html.formmail.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,19 @@ function get_form($addfileaction='addfile',$removefileaction='removefile')
// Add also email aliases if there is some
$listaliases=array('user_aliases'=>$user->email_aliases, 'global_aliases'=>$conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);

// Also add robot email
if (! empty($this->fromalsorobot))
{
if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && $conf->global->MAIN_MAIL_EMAIL_FROM != $conf->global->MAIN_INFO_SOCIETE_MAIL)
{
$liste['robot'] = $conf->global->MAIN_MAIL_EMAIL_FROM;
if ($this->frommail)
{
$liste['robot'] .= ' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
}
}
}

// Add also email aliases from the c_email_senderprofile table
$sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1 ORDER BY position';
$resql = $this->db->query($sql);
Expand All @@ -491,16 +504,6 @@ function get_form($addfileaction='addfile',$removefileaction='removefile')
}
else dol_print_error($this->db);

// Also add robot email
if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && $conf->global->MAIN_MAIL_EMAIL_FROM != $conf->global->MAIN_INFO_SOCIETE_MAIL)
{
$liste['robot'] = $conf->global->MAIN_MAIL_EMAIL_FROM;
if ($this->frommail)
{
$liste['robot'] .= ' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
}
}

foreach($listaliases as $typealias => $listalias)
{
$posalias=0;
Expand Down

0 comments on commit 5935ad8

Please sign in to comment.