diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php
index ed8936ee3ee..6903571d394 100644
--- a/htdocs/admin/defaultvalues.php
+++ b/htdocs/admin/defaultvalues.php
@@ -295,6 +295,7 @@ if ($mode != 'focus' && $mode != 'mandatory') {
if ($mode != 'sortorder') {
$substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST
unset($substitutionarray['__USER_SIGNATURE__']);
+ unset($substitutionarray['__SENDEREMAIL_SIGNATURE__']);
$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'
';
foreach ($substitutionarray as $key => $val) {
$texthelp .= $key.' -> '.$val.'
';
diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index 208c81c794f..ff24a708797 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -51,6 +51,7 @@ $substitutionarrayfortest = array(
'__USER_LOGIN__' => $user->login,
'__USER_EMAIL__' => $user->email,
'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails
+ '__SENDEREMAIL_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails
'__ID__' => 'RecipientIdRecord',
//'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails
'__LASTNAME__' => 'RecipientLastname',
diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php
index f3a1506a771..d2eabd95e2b 100644
--- a/htdocs/admin/mails_emailing.php
+++ b/htdocs/admin/mails_emailing.php
@@ -50,6 +50,7 @@ $substitutionarrayfortest = array(
//'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails
'__CHECK_READ__' => (!empty($object) && is_object($object) && is_object($object->thirdparty)) ? '
' : '',
'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails
+ '__SENDEREMAIL_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails
'__LOGIN__' => $user->login,
'__LASTNAME__' => 'RecipientLastname',
'__FIRSTNAME__' => 'RecipientFirstname',
diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php
index cf83ad2cfbe..95f57d5dfc5 100644
--- a/htdocs/admin/mails_senderprofile_list.php
+++ b/htdocs/admin/mails_senderprofile_list.php
@@ -381,14 +381,17 @@ if ($action != 'create') {
if ($action == 'edit') {
print '
';
- print '| '.$langs->trans("Label").' | |
';
- print '| '.$langs->trans("Email").' | |
';
+ print '| '.$langs->trans("Label").' | |
';
+ print '| '.$langs->trans("Email").' | ';
+ print img_picto('', 'email', 'class="pictofixedwidth"');
+ print ' |
';
print '| '.$langs->trans("Signature").' | ';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('signature', (GETPOSTISSET('signature') ? GETPOST('signature', 'restricthtml') : $object->signature), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%');
print $doleditor->Create(1);
print ' |
';
print '| '.$langs->trans("User").' | ';
+ print img_picto('', 'user', 'class="pictofixedwidth"');
print $form->select_dolusers((GETPOSTISSET('private') ? GETPOST('private', 'int') : $object->private), 'private', 1, null, 0, ($user->admin ? '' : $user->id));
print ' |
';
print '| '.$langs->trans("Position").' | |
';
@@ -410,14 +413,17 @@ if ($action != 'create') {
print '';
*/
print '';
- print '| '.$langs->trans("Label").' | |
';
- print '| '.$langs->trans("Email").' | |
';
+ print '| '.$langs->trans("Label").' | |
';
+ print '| '.$langs->trans("Email").' | ';
+ print img_picto('', 'email', 'class="pictofixedwidth"');
+ print ' |
';
print '| '.$langs->trans("Signature").' | ';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('signature', GETPOST('signature'), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%');
print $doleditor->Create(1);
print ' |
';
print '| '.$langs->trans("User").' | ';
+ print img_picto('', 'user', 'class="pictofixedwidth"');
print $form->select_dolusers((GETPOSTISSET('private') ? GETPOST('private', 'int') : -1), 'private', 1, null, 0, ($user->admin ? '' : $user->id));
print ' |
';
print '| '.$langs->trans("Position").' | |
';
diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php
index b78b3e43857..c48146fc937 100644
--- a/htdocs/admin/mails_ticket.php
+++ b/htdocs/admin/mails_ticket.php
@@ -47,6 +47,7 @@ $substitutionarrayfortest = array(
'__LASTNAME__' => 'TESTLastname',
'__FIRSTNAME__' => 'TESTFirstname',
'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''),
+'__SENDEREMAIL_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails
//'__PERSONALIZED__' => 'TESTPersonalized' // Hiden because not used yet
);
complete_substitutions_array($substitutionarrayfortest, $langs);
diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php
index 633e881030c..81e36c006ca 100644
--- a/htdocs/comm/mailing/card.php
+++ b/htdocs/comm/mailing/card.php
@@ -221,6 +221,7 @@ if (empty($reshook)) {
$substitutionarray['__OTHER4__'] = $other4;
$substitutionarray['__OTHER5__'] = $other5;
$substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter)
+ $substitutionarray['__SENDEREMAIL_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter)
$substitutionarray['__CHECK_READ__'] = '
';
$substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").'';
$substitutionarray['__UNSUBSCRIBE_URL__'] = DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'&email='.urlencode($obj->email).'&mtid='.$obj->rowid;
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 9cbe8b5c686..9a1e4aed2e1 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -2101,7 +2101,7 @@ if ($action == 'create') {
if ($object->statut == 0 && $nbofservices) {
if ($user->rights->contrat->creer) {
- print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid&token='.newToken(), '', true, $params);
+ print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid&token='.newToken(), '', true, $params);
} else {
$params['attr']['title'] = $langs->trans("NotEnoughPermissions");
print dolGetButtonAction($langs->trans('Validate'), '', 'default', '#', '', false, $params);
@@ -2129,7 +2129,7 @@ if ($action == 'create') {
if (isModEnabled('facture') && $object->statut > 0) {
$langs->load("bills");
if ($user->rights->facture->creer) {
- print dolGetButtonAction($langs->trans('CreateBill'), '', 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id, '', true, $params);
+ print dolGetButtonAction($langs->trans('CreateBill'), '', 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id, '', true, $params);
} else {
$params['attr']['title'] = $langs->trans("NotEnoughPermissions");
print dolGetButtonAction($langs->trans('CreateBill'), '', 'default', '#', '', false, $params);
@@ -2138,14 +2138,14 @@ if ($action == 'create') {
if ($object->nbofservicesclosed > 0 || $object->nbofserviceswait > 0) {
if ($user->rights->contrat->activer) {
- print dolGetButtonAction($langs->trans('ActivateAllContracts'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=activate&token='.newToken(), '', true, $params);
+ print dolGetButtonAction($langs->trans('ActivateAllContracts'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=activate&token='.newToken(), '', true, $params);
} else {
print dolGetButtonAction($langs->trans('ActivateAllContracts'), '', 'default', '#', '', false, $params);
}
}
if ($object->nbofservicesclosed < $nbofservices) {
if ($user->rights->contrat->desactiver) {
- print dolGetButtonAction($langs->trans('CloseAllContracts'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', true, $params);
+ print dolGetButtonAction($langs->trans('CloseAllContracts'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', true, $params);
} else {
print dolGetButtonAction($langs->trans('CloseAllContracts'), '', 'default', '#', '', false, $params);
}
@@ -2169,7 +2169,7 @@ if ($action == 'create') {
// Clone
if ($user->rights->contrat->creer) {
- print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&token='.newToken(), '', true, $params);
+ print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&token='.newToken(), '', true, $params);
}
// On peut supprimer entite si
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 3fe5578bfd3..48e6eab2484 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -648,19 +648,9 @@ class FormMail extends Form
}
}
- // Set the default "From"
- $defaultfrom = '';
- $reshook = $hookmanager->executeHooks('getDefaultFromEmail', $parameters, $this);
- if (empty($reshook)) {
- $defaultfrom = $this->fromtype;
- }
- if (!empty($hookmanager->resArray['defaultfrom'])) {
- $defaultfrom = $hookmanager->resArray['defaultfrom'];
- }
-
// Using combo here make the '' no more visible on list.
//$out.= ' '.$form->selectarray('fromtype', $liste, $this->fromtype, 0, 0, 0, '', 0, 0, 0, '', 'fromforsendingprofile maxwidth200onsmartphone', 1, '', $disablebademails);
- $out .= ' '.$form->selectarray('fromtype', $liste, $defaultfrom, 0, 0, 0, '', 0, 0, 0, '', 'fromforsendingprofile maxwidth200onsmartphone', 0, '', $disablebademails);
+ $out .= ' '.$form->selectarray('fromtype', $liste, $this->fromtype, 0, 0, 0, '', 0, 0, 0, '', 'fromforsendingprofile maxwidth200onsmartphone', 0, '', $disablebademails);
}
$out .= "\n";
@@ -920,6 +910,9 @@ class FormMail extends Form
if (strpos($defaultmessage, '__USER_SIGNATURE__') !== false && dol_textishtml($this->substit['__USER_SIGNATURE__'])) {
$atleastonecomponentishtml++;
}
+ if (strpos($defaultmessage, '__SENDEREMAIL_SIGNATURE__') !== false && dol_textishtml($this->substit['__SENDEREMAIL_SIGNATURE__'])) {
+ $atleastonecomponentishtml++;
+ }
if (strpos($defaultmessage, '__ONLINE_PAYMENT_TEXT_AND_URL__') !== false && dol_textishtml($this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'])) {
$atleastonecomponentishtml++;
}
@@ -933,6 +926,9 @@ class FormMail extends Form
if (!dol_textishtml($this->substit['__USER_SIGNATURE__'])) {
$this->substit['__USER_SIGNATURE__'] = dol_nl2br($this->substit['__USER_SIGNATURE__']);
}
+ if (!dol_textishtml($this->substit['__SENDEREMAIL_SIGNATURE__'])) {
+ $this->substit['__SENDEREMAIL_SIGNATURE__'] = dol_nl2br($this->substit['__SENDEREMAIL_SIGNATURE__']);
+ }
if (!dol_textishtml($this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'])) {
$this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'] = dol_nl2br($this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']);
}
@@ -1612,7 +1608,8 @@ class FormMail extends Form
$tmparray['__OTHER3__'] = 'Other3';
$tmparray['__OTHER4__'] = 'Other4';
$tmparray['__OTHER5__'] = 'Other5';
- $tmparray['__USER_SIGNATURE__'] = 'TagSignature';
+ $tmparray['__USER_SIGNATURE__'] = 'TagUserSignature';
+ $tmparray['__SENDEREMAIL_SIGNATURE__'] = 'TagEmailSenderSignature';
$tmparray['__CHECK_READ__'] = 'TagCheckMail';
$tmparray['__UNSUBSCRIBE__'] = 'TagUnsubscribe';
//,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet in mass emailing
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index b27553b17f2..a4ee4e5b802 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -7295,9 +7295,12 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
if (empty($exclude) || !in_array('user', $exclude)) {
// Add SIGNATURE into substitutionarray first, so, when we will make the substitution,
// this will include signature content first and then replace var found into content of signature
- $signature = $user->signature;
+ //var_dump($onlykey);
+ $emailsendersignature = $user->signature; // dy default, we use the signature of current user. We must complete substitution with signature in c_email_senderprofile of array after calling getCommonSubstitutionArray()
+ $usersignature = $user->signature;
$substitutionarray = array_merge($substitutionarray, array(
- '__USER_SIGNATURE__' => (string) (($signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($signature), 30) : $signature) : '')
+ '__SENDEREMAIL_SIGNATURE__' => (string) ((empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc('SignatureFromTheSelectedSenderProfile', 30) : $emailsendersignature) : ''),
+ '__USER_SIGNATURE__' => (string) (($usersignature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($usersignature), 30) : $usersignature) : '')
));
if (is_object($user)) {
@@ -7928,13 +7931,13 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null, $con
}
}
- // Make substitition for array $substitutionarray
+ // Make substitution for array $substitutionarray
foreach ($substitutionarray as $key => $value) {
if (!isset($value)) {
continue; // If value is null, it same than not having substitution key at all into array, we do not replace.
}
- if ($key == '__USER_SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) {
+ if (($key == '__USER_SIGNATURE__' || $key == '__SENDEREMAIL_SIGNATURE__') && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) {
$value = ''; // Protection
}
diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php
index 826a8e0a12a..7e55b5b20f0 100644
--- a/htdocs/core/tpl/card_presend.tpl.php
+++ b/htdocs/core/tpl/card_presend.tpl.php
@@ -156,6 +156,22 @@ if ($action == 'presend') {
$formmail->fromtype = 'special';
}
+ // Set the default "From"
+ $defaultfrom = '';
+ if (GETPOSTISSET('fromtype')) {
+ $defaultfrom = GETPOST('fromtype');
+ } else {
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('getDefaultFromEmail', $parameters, $formmail);
+ if (empty($reshook)) {
+ $defaultfrom = $formmail->fromtype;
+ }
+ if (!empty($hookmanager->resArray['defaultfrom'])) {
+ $defaultfrom = $hookmanager->resArray['defaultfrom'];
+ }
+ }
+ $formmail->fromtype = $defaultfrom;
+
$formmail->trackid = empty($trackid) ? '' : $trackid;
$formmail->inreplyto = empty($inreplyto) ? '' : $inreplyto;
$formmail->withfrom = 1;
@@ -212,11 +228,33 @@ if ($action == 'presend') {
}
// Make substitution in email content
- if ($object) {
+ if (!empty($object)) {
// First we set ->substit (useless, it will be erased later) and ->substit_lines
$formmail->setSubstitFromObject($object, $langs);
}
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object);
+
+ // Overwrite __SENDEREMAIL_SIGNATURE__ with value select into form
+ if ($formmail->fromtype) {
+ $reg = array();
+ if (preg_match('/user/', $formmail->fromtype, $reg)) {
+ $emailsendersignature = $user->signature;
+ } elseif (preg_match('/company/', $formmail->fromtype, $reg)) {
+ $emailsendersignature = '';
+ } elseif (preg_match('/senderprofile_(\d+)/', $formmail->fromtype, $reg)) {
+ $sql = "SELECT rowid, label, email FROM ".$db->prefix()."c_email_senderprofile";
+ $sql .= " WHERE rowid = ".((int) $reg[1]);
+ $resql = $db->query($sql);
+ if ($resql) {
+ $obj = $db->fetch_object($resql);
+ if ($obj) {
+ $emailsendersignature = $obj->label;
+ }
+ }
+ }
+ }
+ $substitutionarray['__SENDEREMAIL_SIGNATURE__'] = $emailsendersignature;
+
$substitutionarray['__CHECK_READ__'] = "";
if (is_object($object) && is_object($object->thirdparty)) {
$checkRead= '