Clean code

This commit is contained in:
Laurent Destailleur 2017-11-25 19:16:15 +01:00
parent 2fc5d9fefb
commit 3d48e509bd
4 changed files with 22 additions and 90 deletions

View File

@ -587,9 +587,13 @@ else
}
else dol_print_error($db);
print '<tr '.$bc[$var?1:0].'><td>'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').'</td>';
print '<tr class="oddeven"><td>'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').'</td>';
print '<td>';
if ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'user')
if ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'robot')
{
print $langs->trans('RobotEmail');
}
else if ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'user')
{
print $langs->trans('UserEmail');
}
@ -726,9 +730,10 @@ else
$formmail = new FormMail($db);
$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->fromtype='all';
$formmail->fromtype=(GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
$formmail->withsubstit=0;
$formmail->withfrom=1;
$formmail->witherrorsto=1;

View File

@ -429,12 +429,14 @@ class FormMail extends Form
{
$out.= '<tr><td class="fieldrequired minwidth200">'.$langs->trans("MailFrom").'</td><td>';
// $this->fromtype is the default value to use to select sender
if (! ($this->fromtype === 'user' && $this->fromid > 0)
&& ! ($this->fromtype === 'company')
&& ! ($this->fromtype === 'robot')
&& ! preg_match('/user_aliases/', $this->fromtype)
&& ! preg_match('/global_aliases/', $this->fromtype)
&& ! preg_match('/senderprofile/', $this->fromtype)
&& ! ($this->fromtype === 'all'))
)
{
// Use this->fromname and this->frommail or error if not defined
$out.= $this->fromname;
@ -453,15 +455,6 @@ class FormMail extends Form
} else {
$liste = array();
if ($this->fromtype === 'all')
{
$liste['robot'] = $this->fromname;
if ($this->frommail)
{
$liste['robot'] .= ' &lt;'.$this->frommail.'&gt;';
}
}
// Add user email
if (empty($user->email))
{
@ -498,6 +491,16 @@ class FormMail extends Form
}
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'] .= ' &lt;'.$conf->global->MAIN_MAIL_EMAIL_FROM.'&gt;';
}
}
foreach($listaliases as $typealias => $listalias)
{
$posalias=0;

View File

@ -1557,7 +1557,7 @@ AGENDA_USE_EVENT_TYPE_DEFAULT=Set automatically this default value for type of e
AGENDA_DEFAULT_FILTER_TYPE=Set automatically this type of event into search filter of agenda view
AGENDA_DEFAULT_FILTER_STATUS=Set automatically this status for events into search filter of agenda view
AGENDA_DEFAULT_VIEW=Which tab do you want to open by default when selecting menu Agenda
AGENDA_REMINDER_EMAIL=Enable event reminder <b>by emails</b> (defined on each event). Note: Module <strong>%s</strong> must be enabled and correctly setup to have reminder sent at the correct frequency.
AGENDA_REMINDER_EMAIL=Enable event reminder <b>by emails</b> (remind option/delay can be defined on each event). Note: Module <strong>%s</strong> must be enabled and correctly setup to have reminder sent at the correct frequency.
AGENDA_REMINDER_BROWSER=Enable event reminder <b>on users browser</b> (when event date is reached, each user is able to refuse this from the browser confirmation question)
AGENDA_REMINDER_BROWSER_SOUND=Enable sound notification
AGENDA_SHOW_LINKED_OBJECT=Show linked object into agenda view

View File

@ -2440,82 +2440,6 @@ else
if (GETPOST('modelselected')) {
$action = 'presend';
}
/*if ($action == 'presend')
{
// By default if $action=='presend'
$titreform='SendMail';
$topicmail='';
$action='send';
$modelmail='thirdparty';
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print '<div class="clearboth"></div>';
print '<br>';
print load_fiche_titre($langs->trans($titreform));
dol_fiche_head();
// Define output language
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
$newlang = $_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
$newlang = $object->default_lang;
// Cree l'objet formulaire mail
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang);
$formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
if($formmail->fromtype === 'user'){
$formmail->fromid = $user->id;
}
$formmail->trackid='thi'.$object->id;
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
{
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'thi'.$object->id);
}
$formmail->withfrom=1;
$formmail->withtopic=1;
$liste=array();
foreach ($object->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value;
$formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$liste;
$formmail->withtofree=1;
$formmail->withtocc=$liste;
$formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
$formmail->withfile=2;
$formmail->withbody=1;
$formmail->withdeliveryreceipt=1;
$formmail->withcancel=1;
// Array of substitutions
$formmail->setSubstitFromObject($object, $outputlangs);
$formmail->substit['__THIRDPARTY_ID__']=$object->id; // substit in setSubstitFromObject was wrong for this one
$formmail->substit['__THIRDPARTY_NAME__']=$object->name; // substit in setSubstitFromObject was wrong for this one
$formmail->substit['__PERSONALIZED__']=''; // deprecated
$formmail->substit['__CONTACTCIVNAME__']='';
// Tableau des parametres complementaires du post
$formmail->param['action']=$action;
$formmail->param['models']=$modelmail;
$formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['socid']=$object->id;
$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?socid='.$object->id;
// Init list of files
if (GETPOST("mode")=='init')
{
$formmail->clear_attached_files();
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
}
print $formmail->get_form();
dol_fiche_end();
}*/
if ($action != 'presend')
{