'; // Do not put 'disabled' on 'option' tag, it is already on 'select' and it makes chrome crazy.
@@ -518,12 +514,10 @@ class FormMail extends Form
// Substitution array/string
$helpforsubstitution = '';
if (is_array($this->substit) && count($this->substit)) $helpforsubstitution .= $langs->trans('AvailableVariables').' :
'."\n";
- foreach ($this->substit as $key => $val)
- {
+ foreach ($this->substit as $key => $val) {
$helpforsubstitution .= $key.' -> '.$langs->trans(dol_string_nohtmltag(dolGetFirstLineOfText($val))).'
';
}
- if (!empty($this->withsubstit)) // Unset or set ->withsubstit=0 to disable this.
- {
+ if (!empty($this->withsubstit)) { // Unset or set ->withsubstit=0 to disable this.
$out .= '
';
//$out.='';
if (is_numeric($this->withsubstit)) $out .= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltip'); // Old usage
@@ -538,10 +532,8 @@ class FormMail extends Form
var_dump($this->fromname);*/
// From
- if (!empty($this->withfrom))
- {
- if (!empty($this->withfromreadonly))
- {
+ if (!empty($this->withfrom)) {
+ if (!empty($this->withfromreadonly)) {
$out .= ' | '.$langs->trans("MailFrom").' | ';
// $this->fromtype is the default value to use to select sender
@@ -551,16 +543,13 @@ class FormMail extends Form
&& !preg_match('/user_aliases/', $this->fromtype)
&& !preg_match('/global_aliases/', $this->fromtype)
&& !preg_match('/senderprofile/', $this->fromtype)
- )
- {
+ ) {
// Use this->fromname and this->frommail or error if not defined
$out .= $this->fromname;
- if ($this->frommail)
- {
+ if ($this->frommail) {
$out .= ' <'.$this->frommail.'>';
} else {
- if ($this->fromtype)
- {
+ if ($this->fromtype) {
$langs->load('errors');
$out .= ' <'.$langs->trans('ErrorNoMailDefinedForThisUser').'> ';
}
@@ -569,8 +558,7 @@ class FormMail extends Form
$liste = array();
// Add user email
- if (empty($user->email))
- {
+ if (empty($user->email)) {
$langs->load('errors');
$liste['user'] = $user->getFullName($langs).' <'.$langs->trans('ErrorNoMailDefinedForThisUser').'>';
} else {
@@ -584,13 +572,10 @@ class FormMail extends Form
$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)
- {
+ 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)
- {
+ if ($this->frommail) {
$liste['robot'] .= ' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
}
}
@@ -601,31 +586,27 @@ class FormMail extends Form
$sql .= ' WHERE active = 1 AND (private = 0 OR private = '.$user->id.')';
$sql .= ' ORDER BY position';
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $this->db->fetch_object($resql);
- if ($obj)
- {
+ if ($obj) {
$listaliases['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>';
}
$i++;
}
- } else dol_print_error($this->db);
+ } else {
+ dol_print_error($this->db);
+ }
- foreach ($listaliases as $typealias => $listalias)
- {
+ foreach ($listaliases as $typealias => $listalias) {
$posalias = 0;
$listaliasarray = explode(',', $listalias);
- foreach ($listaliasarray as $listaliasval)
- {
+ foreach ($listaliasarray as $listaliasval) {
$posalias++;
$listaliasval = trim($listaliasval);
- if ($listaliasval)
- {
+ if ($listaliasval) {
$listaliasval = preg_replace('/', '<', $listaliasval);
$listaliasval = preg_replace('/>/', '>', $listaliasval);
if (!preg_match('/</', $listaliasval)) $listaliasval = '<'.$listaliasval.'>';
@@ -637,8 +618,7 @@ class FormMail extends Form
// Set the default "From"
$defaultfrom = '';
$reshook = $hookmanager->executeHooks('getDefaultFromEmail', $parameters, $this);
- if (empty($reshook))
- {
+ if (empty($reshook)) {
$defaultfrom = $this->fromtype;
}
if (!empty($hookmanager->resArray['defaultfrom'])) $defaultfrom = $hookmanager->resArray['defaultfrom'];
@@ -665,19 +645,15 @@ class FormMail extends Form
if ($this->withtofree) $out .= $form->textwithpicto($langs->trans("MailTo"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
else $out .= $langs->trans("MailTo");
$out .= ' | ';
- if ($this->withtoreadonly)
- {
- if (!empty($this->toname) && !empty($this->tomail))
- {
+ if ($this->withtoreadonly) {
+ if (!empty($this->toname) && !empty($this->tomail)) {
$out .= '';
$out .= '';
- if ($this->totype == 'thirdparty')
- {
+ if ($this->totype == 'thirdparty') {
$soc = new Societe($this->db);
$soc->fetch($this->toid);
$out .= $soc->getNomUrl(1);
- } elseif ($this->totype == 'contact')
- {
+ } elseif ($this->totype == 'contact') {
$contact = new Contact($this->db);
$contact->fetch($this->toid);
$out .= $contact->getNomUrl(1);
@@ -685,8 +661,7 @@ class FormMail extends Form
$out .= $this->toname;
}
$out .= ' <'.$this->tomail.'>';
- if ($this->withtofree)
- {
+ if ($this->withtofree) {
$out .= ' '.$langs->trans("and").' withto) : "").'" />';
}
} else {
@@ -695,25 +670,21 @@ class FormMail extends Form
}
} else {
// The free input of email
- if (!empty($this->withtofree))
- {
+ if (!empty($this->withtofree)) {
$out .= 'withto) : "")).'" />';
}
// The select combo
- if (!empty($this->withto) && is_array($this->withto))
- {
+ if (!empty($this->withto) && is_array($this->withto)) {
if (!empty($this->withtofree)) $out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
$tmparray = $this->withto;
- foreach ($tmparray as $key => $val)
- {
+ foreach ($tmparray as $key => $val) {
$tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
}
$withtoselected = GETPOST("receiver", 'array'); // Array of selected value
- if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend')
- {
+ if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') {
$withtoselected = array_keys($tmparray);
}
$out .= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, "");
@@ -723,21 +694,18 @@ class FormMail extends Form
}
// To User
- if (!empty($this->withtouser) && is_array($this->withtouser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
- {
+ if (!empty($this->withtouser) && is_array($this->withtouser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
$out .= ' | | ';
$out .= $langs->trans("MailToUsers");
$out .= ' | ';
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
$tmparray = $this->withtouser;
- foreach ($tmparray as $key => $val)
- {
+ foreach ($tmparray as $key => $val) {
$tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
}
$withtoselected = GETPOST("receiveruser", 'array'); // Array of selected value
- if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend')
- {
+ if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') {
$withtoselected = array_keys($tmparray);
}
$out .= $form->multiselectarray("receiveruser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, "");
@@ -745,8 +713,7 @@ class FormMail extends Form
}
// With option one email per recipient
- if (!empty($this->withoptiononeemailperrecipient))
- {
+ if (!empty($this->withoptiononeemailperrecipient)) {
$out .= ' | | ';
$out .= $langs->trans("GroupEmails");
$out .= ' | ';
@@ -760,23 +727,19 @@ class FormMail extends Form
}
// CC
- if (!empty($this->withtocc) || is_array($this->withtocc))
- {
+ if (!empty($this->withtocc) || is_array($this->withtocc)) {
$out .= ' | | ';
$out .= $form->textwithpicto($langs->trans("MailCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
$out .= ' | ';
- if ($this->withtoccreadonly)
- {
+ if ($this->withtoccreadonly) {
$out .= (!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : "";
} else {
$out .= 'withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />';
- if (!empty($this->withtocc) && is_array($this->withtocc))
- {
+ if (!empty($this->withtocc) && is_array($this->withtocc)) {
$out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
$tmparray = $this->withtocc;
- foreach ($tmparray as $key => $val)
- {
+ foreach ($tmparray as $key => $val) {
$tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
}
$withtoccselected = GETPOST("receivercc", 'array'); // Array of selected value
@@ -787,21 +750,18 @@ class FormMail extends Form
}
// To User cc
- if (!empty($this->withtoccuser) && is_array($this->withtoccuser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
- {
+ if (!empty($this->withtoccuser) && is_array($this->withtoccuser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
$out .= ' | | ';
$out .= $langs->trans("MailToCCUsers");
$out .= ' | ';
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
$tmparray = $this->withtoccuser;
- foreach ($tmparray as $key => $val)
- {
+ foreach ($tmparray as $key => $val) {
$tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
}
$withtoselected = GETPOST("receiverccuser", 'array'); // Array of selected value
- if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend')
- {
+ if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') {
$withtoselected = array_keys($tmparray);
}
$out .= $form->multiselectarray("receiverccuser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, "");
@@ -814,10 +774,8 @@ class FormMail extends Form
}
// Replyto
- if (!empty($this->withreplyto))
- {
- if ($this->withreplytoreadonly)
- {
+ if (!empty($this->withreplyto)) {
+ if ($this->withreplytoreadonly) {
$out .= '';
$out .= '';
$out .= " | | ".$langs->trans("MailReply")." | ".$this->replytoname.($this->replytomail ? (" <".$this->replytomail.">") : "");
@@ -841,41 +799,32 @@ class FormMail extends Form
}
// Attached files
- if (!empty($this->withfile))
- {
+ if (!empty($this->withfile)) {
$out .= ' | ';
$out .= '| '.$langs->trans("MailFile").' | ';
$out .= '';
- if ($this->withmaindocfile) // withmaindocfile is set to 1 or -1 to show the checkbox (-1 = checked or 1 = not checked)
- {
- if (GETPOSTISSET('sendmail'))
- {
+ if ($this->withmaindocfile) { // withmaindocfile is set to 1 or -1 to show the checkbox (-1 = checked or 1 = not checked)
+ if (GETPOSTISSET('sendmail')) {
$this->withmaindocfile = (GETPOST('addmaindocfile', 'alpha') ? -1 : 1);
- }
- // If a template was selected, we use setup of template to define if join file checkbox is selected or not.
- elseif (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
- {
+ } elseif (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
+ // If a template was selected, we use setup of template to define if join file checkbox is selected or not.
$this->withmaindocfile = ($arraydefaultmessage->joinfiles ? -1 : 1);
}
}
- if (!empty($this->withmaindocfile))
- {
- if ($this->withmaindocfile == 1)
- {
+ if (!empty($this->withmaindocfile)) {
+ if ($this->withmaindocfile == 1) {
$out .= '';
}
- if ($this->withmaindocfile == -1)
- {
+ if ($this->withmaindocfile == -1) {
$out .= '';
}
$out .= ' '.$langs->trans("JoinMainDoc").'. ';
}
- if (is_numeric($this->withfile))
- {
+ if (is_numeric($this->withfile)) {
// TODO Trick to have param removedfile containing nb of file to delete. But this does not works without javascript
$out .= ''."\n";
$out .= ''."\n";
- if (count($listofpaths))
- {
- foreach ($listofpaths as $key => $val)
- {
+ if (count($listofpaths)) {
+ foreach ($listofpaths as $key => $val) {
$out .= '';
// Preview of attachment
preg_match('#^(/)(\w+)(/)(.+)$#', substr($val, (strlen(DOL_DATA_ROOT) - strlen($val))), $formfile_params);
$out .= img_mime($listofnames[$key]).' '.$listofnames[$key];
$out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]);
- if (!$this->withfilereadonly)
- {
+ if (!$this->withfilereadonly) {
$out .= ' ';
//$out.= ' '.img_delete($langs->trans("Delete").'';
}
$out .= ' ';
}
- } elseif (empty($this->withmaindocfile)) // Do not show message if we asked to show the checkbox
- {
+ } elseif (empty($this->withmaindocfile)) { // Do not show message if we asked to show the checkbox
$out .= $langs->trans("NoAttachedFiles").' ';
}
- if ($this->withfile == 2) // Can add other files
- {
+ if ($this->withfile == 2) { // Can add other files
if (!empty($conf->global->FROM_MAIL_USE_INPUT_FILE_MULTIPLE)) $out .= '';
else $out .= '';
$out .= ' ';
@@ -920,11 +864,9 @@ class FormMail extends Form
}
// Message
- if (!empty($this->withbody))
- {
+ if (!empty($this->withbody)) {
$defaultmessage = GETPOST('message', 'restricthtml');
- if (!GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1')
- {
+ if (!GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1') {
if ($arraydefaultmessage && $arraydefaultmessage->content) {
$defaultmessage = $arraydefaultmessage->content;
} elseif (!is_numeric($this->withbody)) {
@@ -934,25 +876,29 @@ class FormMail extends Form
// Complete substitution array with the url to make online payment
$paymenturl = ''; $validpaymentmethod = array();
- if (empty($this->substit['__REF__']))
- {
+ if (empty($this->substit['__REF__'])) {
$paymenturl = '';
} else {
// Set the online payment url link into __ONLINE_PAYMENT_URL__ key
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
$langs->loadLangs(array('paypal', 'other'));
$typeforonlinepayment = 'free';
- if ($this->param["models"] == 'order' || $this->param["models"] == 'order_send') $typeforonlinepayment = 'order'; // TODO use detection on something else than template
- if ($this->param["models"] == 'invoice' || $this->param["models"] == 'facture_send') $typeforonlinepayment = 'invoice'; // TODO use detection on something else than template
- if ($this->param["models"] == 'member') $typeforonlinepayment = 'member'; // TODO use detection on something else than template
+ if ($this->param["models"] == 'order' || $this->param["models"] == 'order_send') {
+ $typeforonlinepayment = 'order'; // TODO use detection on something else than template
+ }
+ if ($this->param["models"] == 'invoice' || $this->param["models"] == 'facture_send') {
+ $typeforonlinepayment = 'invoice'; // TODO use detection on something else than template
+ }
+ if ($this->param["models"] == 'member') {
+ $typeforonlinepayment = 'member'; // TODO use detection on something else than template
+ }
$url = getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']);
$paymenturl = $url;
$validpaymentmethod = getValidOnlinePaymentMethods('');
}
- if (count($validpaymentmethod) > 0 && $paymenturl)
- {
+ if (count($validpaymentmethod) > 0 && $paymenturl) {
$langs->load('other');
$this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'] = str_replace('\n', "\n", $langs->transnoentities("PredefinedMailContentLink", $paymenturl));
$this->substit['__ONLINE_PAYMENT_URL__'] = $paymenturl;
@@ -966,10 +912,8 @@ class FormMail extends Form
// Add lines substitution key from each line
$lines = '';
$defaultlines = $arraydefaultmessage->content_lines;
- if (isset($defaultlines))
- {
- foreach ($this->substit_lines as $substit_line)
- {
+ if (isset($defaultlines)) {
+ foreach ($this->substit_lines as $substit_line) {
$lines .= make_substitutions($defaultlines, $substit_line)."\n";
}
}
@@ -1003,8 +947,9 @@ class FormMail extends Form
}
}
- if (GETPOSTISSET("message") && !$_POST['modelselected']) $defaultmessage = $_POST["message"];
- else {
+ if (GETPOSTISSET("message") && !$_POST['modelselected']) {
+ $defaultmessage = $_POST["message"];
+ } else {
$defaultmessage = make_substitutions($defaultmessage, $this->substit);
// Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty)
$defaultmessage = preg_replace("/^( )+/", "", $defaultmessage);
@@ -1016,17 +961,17 @@ class FormMail extends Form
$out .= $form->textwithpicto($langs->trans('MailText'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfrombody');
$out .= ' | ';
$out .= '';
- if ($this->withbodyreadonly)
- {
+ if ($this->withbodyreadonly) {
$out .= nl2br($defaultmessage);
$out .= '';
} else {
- if (!isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes';
+ if (!isset($this->ckeditortoolbar)) {
+ $this->ckeditortoolbar = 'dolibarr_notes';
+ }
// Editor wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- if ($this->withfckeditor == -1)
- {
+ if ($this->withfckeditor == -1) {
if (!empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $this->withfckeditor = 1;
else $this->withfckeditor = 0;
}
@@ -1039,29 +984,27 @@ class FormMail extends Form
$out .= ''."\n";
- if ($this->withform == 1 || $this->withform == -1)
- {
+ if ($this->withform == 1 || $this->withform == -1) {
$out .= '
';
$out .= 'withfile == 2 && $conf->use_javascript_ajax)
- {
+ if ($this->withfile == 2 && $conf->use_javascript_ajax) {
$out .= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"';
}
$out .= ' />';
- if ($this->withcancel)
- {
+ if ($this->withcancel) {
$out .= ' ';
$out .= '';
}
$out .= ' '."\n";
}
- if ($this->withform == 1) $out .= ''."\n";
+ if ($this->withform == 1) {
+ $out .= ''."\n";
+ }
// Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set
- if (!empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY))
- {
+ if (!empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) {
$out .= ' | |