|
3 | 3 | * Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.org> |
4 | 4 | * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es> |
5 | 5 | * Copyright (C) 2024 Frédéric France <frederic.france@free.fr> |
| 6 | + * Copyright (C) 2025 Benjamin Falière <benjamin@faliere.com> |
6 | 7 | * |
7 | 8 | * This program is free software; you can redistribute it and/or modify |
8 | 9 | * it under the terms of the GNU General Public License as published by |
|
26 | 27 |
|
27 | 28 | // Load Dolibarr environment |
28 | 29 | require '../main.inc.php'; |
29 | | -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; |
30 | | -require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; |
| 30 | +require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; |
| 31 | +require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; |
31 | 32 |
|
32 | 33 | /** |
33 | 34 | * @var Conf $conf |
|
63 | 64 | $checkread = GETPOST('value', 'alpha'); |
64 | 65 | $checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY', 'alpha'); |
65 | 66 | $contactbulkdefault = GETPOSTINT('MAILING_CONTACT_DEFAULT_BULK_STATUS'); |
| 67 | + $batchlimit = GETPOSTINT('MAILING_LIMIT_SENDBYWEB'); |
| 68 | + |
66 | 69 | if (GETPOST('MAILING_DELAY', 'alpha') != '') { |
67 | 70 | $mailingdelay = price2num(GETPOST('MAILING_DELAY', 'alpha'), 3); // Not less than 1 millisecond. |
68 | 71 | } else { |
69 | 72 | $mailingdelay = ''; |
70 | 73 | } |
| 74 | + |
71 | 75 | // Clean data |
72 | 76 | if ((float) $mailingdelay > 10) { |
73 | 77 | $mailingdelay = 10; |
|
92 | 96 | if (!($res > 0)) { |
93 | 97 | $error++; |
94 | 98 | } |
| 99 | + $res = dolibarr_set_const($db, "MAILING_LIMIT_SENDBYWEB", $batchlimit, 'chaine', 1, '', 0); |
| 100 | + if (!($res > 0)) { |
| 101 | + $error++; |
| 102 | + } |
95 | 103 |
|
96 | 104 | // Create temporary encryption key if needed |
97 | 105 | $res = dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY", $checkread_key, 'chaine', 0, '', $conf->entity); |
|
127 | 135 |
|
128 | 136 | llxHeader('', $langs->trans("MailingSetup"), '', '', 0, 0, '', '', '', 'mod-admin page-mailing'); |
129 | 137 |
|
130 | | -$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
| 138 | +$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>'; |
131 | 139 | print load_fiche_titre($langs->trans("MailingSetup"), $linkback, 'title_setup'); |
132 | 140 |
|
133 | 141 | $constname = 'MAILING_EMAIL_UNSUBSCRIBE_KEY'; |
134 | 142 |
|
135 | 143 | // Add button to autosuggest a key |
136 | | -include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; |
| 144 | +include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; |
137 | 145 | print dolJSToSetRandomPassword($constname); |
138 | 146 |
|
139 | 147 | print '<br>'; |
140 | | -print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; |
141 | | -print '<input type="hidden" name="token" value="'.newToken().'">'; |
| 148 | +print '<form method="post" action="' . $_SERVER["PHP_SELF"] . '">'; |
| 149 | +print '<input type="hidden" name="token" value="' . newToken() . '">'; |
142 | 150 | print '<input type="hidden" name="action" value="setvalue">'; |
143 | 151 |
|
144 | 152 | print '<table class="noborder centpercent">'; |
145 | 153 | print '<tr class="liste_titre">'; |
146 | 154 | print '<td>'.$langs->trans("Parameter").'</td>'; |
147 | 155 | print '<td></td>'; |
148 | 156 | print '<td class="hideonsmartphone">'.$langs->trans("Example").'</td>'; |
| 157 | + |
149 | 158 | print "</tr>\n"; |
150 | 159 |
|
151 | 160 | print '<tr class="oddeven"><td>'; |
152 | 161 | $help = img_help(1, $langs->trans("EMailHelpMsgSPFDKIM")); |
153 | | -print $langs->trans("MailingEMailFrom").' '.$help.'</td><td>'; |
154 | | -print '<input class="minwidth100" type="text" name="MAILING_EMAIL_FROM" value="' . getDolGlobalString('MAILING_EMAIL_FROM').'">'; |
| 162 | +print $langs->trans("MailingEMailFrom") . ' ' . $help . '</td><td>'; |
| 163 | +print '<input class="minwidth100" type="text" name="MAILING_EMAIL_FROM" value="' . getDolGlobalString('MAILING_EMAIL_FROM') . '">'; |
155 | 164 | if (getDolGlobalString('MAILING_EMAIL_FROM') && !isValidEmail($conf->global->MAILING_EMAIL_FROM)) { |
156 | | - print ' '.img_warning($langs->trans("BadEMail")); |
| 165 | + print ' ' . img_warning($langs->trans("BadEMail")); |
157 | 166 | } |
158 | 167 | print '</td>'; |
159 | | -print '<td class="hideonsmartphone"><span class="opacitymedium">'.dol_escape_htmltag(($mysoc->name ? $mysoc->name : 'MyName').' <noreply@example.com>').'</span></td>'; |
| 168 | +print '<td class="hideonsmartphone"><span class="opacitymedium">' . dol_escape_htmltag(($mysoc->name ? $mysoc->name : 'MyName') . ' <noreply@example.com>') . '</span></td>'; |
160 | 169 | print '</tr>'; |
161 | 170 |
|
162 | 171 | print '<tr class="oddeven"><td>'; |
163 | | -print $langs->trans("MailingEMailError").'</td><td>'; |
164 | | -print '<input class="minwidth100" type="text" name="MAILING_EMAIL_ERRORSTO" value="'.getDolGlobalString('MAILING_EMAIL_ERRORSTO').'">'; |
| 172 | +print $langs->trans("MailingEMailError") . '</td><td>'; |
| 173 | +print '<input class="minwidth100" type="text" name="MAILING_EMAIL_ERRORSTO" value="' . getDolGlobalString('MAILING_EMAIL_ERRORSTO') . '">'; |
165 | 174 | if (getDolGlobalString('MAILING_EMAIL_ERRORSTO') && !isValidEmail(getDolGlobalString('MAILING_EMAIL_ERRORSTO'))) { |
166 | | - print ' '.img_warning($langs->trans("BadEMail")); |
| 175 | + print ' ' . img_warning($langs->trans("BadEMail")); |
167 | 176 | } |
168 | 177 | print '</td>'; |
169 | | -print '<td class="hideonsmartphone"><span class="opacitymedium">'.dol_escape_htmltag('<webmaster@example.com>').'</span></td>'; |
| 178 | +print '<td class="hideonsmartphone"><span class="opacitymedium">' . dol_escape_htmltag('<webmaster@example.com>') . '</span></td>'; |
170 | 179 | print '</tr>'; |
171 | 180 |
|
172 | 181 | print '<tr class="oddeven"><td>'; |
173 | | -print $form->textwithpicto($langs->trans("MailingDelay"), $langs->trans("IfDefinedUseAValueBeetween", '0.001', '10')).'</td><td>'; |
174 | | -print '<input class="width75" type="text" name="MAILING_DELAY" value="'.getDolGlobalString('MAILING_DELAY').'">'; |
| 182 | +print $form->textwithpicto($langs->trans("MailingDelay"), $langs->trans("IfDefinedUseAValueBeetween", '0.001', '10')) . '</td><td>'; |
| 183 | +print '<input class="width75" type="text" name="MAILING_DELAY" value="' . getDolGlobalString('MAILING_DELAY') . '">'; |
175 | 184 | print '</td>'; |
176 | 185 | print '<td class="hideonsmartphone"></td>'; |
177 | 186 | print '</tr>'; |
|
181 | 190 | // It is also used as a security key parameter. |
182 | 191 |
|
183 | 192 | print '<tr class="oddeven"><td>'; |
184 | | -print $langs->trans("ActivateCheckReadKey").'</td><td>'; |
185 | | -print '<input class="minwidth100 maxwdith250 widthcentpercentminusx" type="text" name="MAILING_EMAIL_UNSUBSCRIBE_KEY" id="MAILING_EMAIL_UNSUBSCRIBE_KEY" value="'.getDolGlobalString('MAILING_EMAIL_UNSUBSCRIBE_KEY').'">'; |
| 193 | +print $langs->trans("ActivateCheckReadKey") . '</td><td>'; |
| 194 | +print '<input class="minwidth100 maxwdith250 widthcentpercentminusx" type="text" name="MAILING_EMAIL_UNSUBSCRIBE_KEY" id="MAILING_EMAIL_UNSUBSCRIBE_KEY" value="' . getDolGlobalString('MAILING_EMAIL_UNSUBSCRIBE_KEY') . '">'; |
186 | 195 | if (!empty($conf->use_javascript_ajax)) { |
187 | | - print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); |
| 196 | + print ' ' . img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); |
188 | 197 | } |
189 | 198 | print '</td>'; |
190 | 199 | print '<td class="hideonsmartphone"></td>'; |
|
194 | 203 | print '<tr class="oddeven">'; |
195 | 204 | print '<td>' . $langs->trans("DefaultBlacklistMailingStatus", $langs->transnoentitiesnoconv("No_Email")) . '</td>'; |
196 | 205 | print '<td>'; |
197 | | -$blacklist_setting=array(0=>$langs->trans('No'), 1=>$langs->trans('Yes'), 2=>$langs->trans('DefaultStatusEmptyMandatory')); |
| 206 | +$blacklist_setting = array(0 => $langs->trans('No'), 1 => $langs->trans('Yes'), 2 => $langs->trans('DefaultStatusEmptyMandatory')); |
198 | 207 | print $form->selectarray("MAILING_CONTACT_DEFAULT_BULK_STATUS", $blacklist_setting, getDolGlobalString('MAILING_CONTACT_DEFAULT_BULK_STATUS')); |
199 | 208 | print '</td>'; |
200 | 209 | print '<td class="hideonsmartphone"></td>'; |
201 | 210 | print '</tr>'; |
202 | 211 |
|
| 212 | +// Limit number for each mailing batch, displayed only if this value is not defined in the conf.php file |
| 213 | +if (empty($conf->file->mailing_limit_sendbyweb)) { |
| 214 | + print '<tr class="oddeven">'; |
| 215 | + $help = img_help(1, $langs->trans("MailingNumberOfEmailsPerBatchHelp")); |
| 216 | + print '<td>' . $langs->trans("MailingNumberOfEmailsPerBatch") . ' ' . $help . '</td>'; |
| 217 | + print '<td>'; |
| 218 | + print '<input class="minwidth100 maxwdith250 widthcentpercentminusx" type="text" name="MAILING_LIMIT_SENDBYWEB" id="MAILING_LIMIT_SENDBYWEB" value="' . getDolGlobalString('MAILING_LIMIT_SENDBYWEB') . '">'; |
| 219 | + print '</td>'; |
| 220 | + print '<td class="hideonsmartphone"></td>'; |
| 221 | + print '</tr>'; |
| 222 | +} |
203 | 223 |
|
204 | 224 | if (!empty($conf->use_javascript_ajax) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1) { |
205 | 225 | print '<tr class="oddeven"><td>'; |
206 | | - print $langs->trans("MailAdvTargetRecipients").'</td><td>'; |
| 226 | + print $langs->trans("MailAdvTargetRecipients") . '</td><td>'; |
207 | 227 | print ajax_constantonoff('EMAILING_USE_ADVANCED_SELECTOR'); |
208 | 228 | print '</td>'; |
209 | 229 | print '<td class="hideonsmartphone"></td>'; |
|
0 commit comments