FIX option "Default value for field 'Refuse bulk emailings'"

This commit is contained in:
Laurent Destailleur 2021-09-01 22:37:15 +02:00
parent 1bce356efa
commit c762840dec
5 changed files with 25 additions and 18 deletions

View File

@ -132,6 +132,7 @@ print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print '<td>'.$langs->trans("Example").'</td>';
print "</tr>\n";
print '<tr class="oddeven"><td>';
@ -140,7 +141,8 @@ print '<input size="32" type="text" name="MAILING_EMAIL_FROM" value="'.$conf->gl
if (!empty($conf->global->MAILING_EMAIL_FROM) && !isValidEmail($conf->global->MAILING_EMAIL_FROM)) {
print ' '.img_warning($langs->trans("BadEMail"));
}
print '</td></tr>';
print '</td><td><span class="opacitymedium">'.dol_escape_htmltag(($mysoc->name ? $mysoc->name : 'MyName').' <noreply@example.com>').'</span></td>';
print '</tr>';
print '<tr class="oddeven"><td>';
print $langs->trans("MailingEMailError").'</td><td>';
@ -148,12 +150,14 @@ print '<input size="32" type="text" name="MAILING_EMAIL_ERRORSTO" value="'.$conf
if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && !isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) {
print ' '.img_warning($langs->trans("BadEMail"));
}
print '</td></tr>';
print '</td><td><span class="opacitymedium">webmaster@example.com></span></td>';
print '</tr>';
print '<tr class="oddeven"><td>';
print $langs->trans("MailingDelay").'</td><td>';
print '<input class="width75" type="text" name="MAILING_DELAY" value="'.$conf->global->MAILING_DELAY.'">';
print '</td></tr>';
print '</td><td></td>';
print '</tr>';
// Constant to add salt into the unsubscribe and check read tag.
@ -165,15 +169,17 @@ print '<input size="32" type="text" name="MAILING_EMAIL_UNSUBSCRIBE_KEY" id="MAI
if (!empty($conf->use_javascript_ajax)) {
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
}
print '</td></tr>';
print '</td><td></td>';
print '</tr>';
// default blacklist from mailing
print '<tr class="oddeven">';
print '<td>' . $langs->trans("DefaultBlacklistMailingStatus") . '</td>';
print '<td>' . $langs->trans("DefaultBlacklistMailingStatus", $langs->transnoentitiesnoconv("No_Email")) . '</td>';
print '<td>';
$blacklist_setting=array(0=>$langs->trans('No'),1=>$langs->trans('Yes'),-1=>$langs->trans('DefaultStatusEmptyMandatory'));
$blacklist_setting=array(0=>$langs->trans('No'), 1=>$langs->trans('Yes'), 2=>$langs->trans('DefaultStatusEmptyMandatory'));
print $form->selectarray("MAILING_CONTACT_DEFAULT_BULK_STATUS", $blacklist_setting, $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS);
print '</td>';
print '<td></td>';
print '</tr>';
@ -181,7 +187,8 @@ if (!empty($conf->use_javascript_ajax) && $conf->global->MAIN_FEATURES_LEVEL >=
print '<tr class="oddeven"><td>';
print $langs->trans("MailAdvTargetRecipients").'</td><td>';
print ajax_constantonoff('EMAILING_USE_ADVANCED_SELECTOR');
print '</td></tr>';
print '</td><td></td>';
print '</tr>';
}
print '</table>';

View File

@ -242,7 +242,7 @@ if (empty($reshook)) {
$action = 'create';
}
if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == -1 && $object->no_email == -1 && !empty($object->email)) {
if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 && $object->no_email == -1 && !empty($object->email)) {
$error++;
$errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email"));
$action = 'create';
@ -334,7 +334,7 @@ if (empty($reshook)) {
$action = 'edit';
}
if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == -1 && GETPOST("no_email", "int") == -1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) {
if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 && GETPOST("no_email", "int") == -1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) {
$error++;
$errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email"));
$action = 'edit';
@ -797,7 +797,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Unsubscribe
if (!empty($conf->mailing->enabled)) {
if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == -1) {
if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
print "\n".'<script type="text/javascript" language="javascript">'."\n";
print '$(document).ready(function () {
$("#email").keyup(function() {
@ -818,7 +818,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
}
print '<tr>';
print '<td class="noemail"><label for="no_email">'.$langs->trans("No_Email").'</label></td>';
print '<td>'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'int') : $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS), 1, false, ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == -1)).'</td>';
print '<td>'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'int') : $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS), 1, false, ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2)).'</td>';
print '</tr>';
}
@ -1068,7 +1068,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Unsubscribe
if (!empty($conf->mailing->enabled)) {
if ($conf->use_javascript_ajax && isset($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == -1) {
if ($conf->use_javascript_ajax && isset($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
print "\n".'<script type="text/javascript" language="javascript">'."\n";
print '
@ -1095,7 +1095,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
}
print '<tr>';
print '<td class="noemail"><label for="no_email">'.$langs->trans("No_Email").'</label></td>';
$useempty = (isset($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == -1));
$useempty = (isset($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2));
print '<td>'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'int') : $object->no_email), 1, false, $useempty).'</td>';
print '</tr>';
}

View File

@ -79,7 +79,7 @@ class modMailing extends DolibarrModules
$this->const[$r][0] = "MAILING_CONTACT_DEFAULT_BULK_STATUS";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "0";
$this->const[$r][3] = 'Default black list mailing';
$this->const[$r][3] = 'Default value for field "Refuse bulk email" when creating a contact';
$this->const[$r][4] = 0;
$r++;

View File

@ -175,5 +175,5 @@ Answered=Answered
IsNotAnAnswer=Is not answer (initial email)
IsAnAnswer=Is an answer of an initial email
RecordCreatedByEmailCollector=Record created by the Email Collector %s from email %s
DefaultBlacklistMailingStatus=Default contact status for refuse bulk emailing
DefaultBlacklistMailingStatus=Default value for field '%s' when creating a new contact
DefaultStatusEmptyMandatory=Empty but mandatory

View File

@ -418,12 +418,12 @@ if (empty($reshook)) {
$error++;
}
if (!empty($conf->mailing->enabled) && !empty($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1 && GETPOST('contact_no_email', 'int')==-1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) {
if (!empty($conf->mailing->enabled) && !empty($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 && GETPOST('contact_no_email', 'int')==-1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email")), null, 'errors');
}
if (!empty($conf->mailing->enabled) && GETPOST("private", 'int') == 1 && !empty($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1 && GETPOST('contact_no_email', 'int')==-1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) {
if (!empty($conf->mailing->enabled) && GETPOST("private", 'int') == 1 && !empty($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 && GETPOST('contact_no_email', 'int')==-1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email")), null, 'errors');
}
@ -1206,7 +1206,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
document.formsoc.action.value="create";
document.formsoc.submit();
});';
if ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1) {
if ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
print '
function init_check_no_email(input) {
if (input.val()!="") {