dolibarr  16.0.5
mailing.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.org>
4  * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
29 
30 // Load translation files required by the page
31 $langs->loadLangs(array("admin", "mails"));
32 
33 if (!$user->admin) {
35 }
36 
37 $action = GETPOST('action', 'aZ09');
38 
39 $form = new Form($db);
40 
41 
42 /*
43  * Actions
44  */
45 
46 if ($action == 'setvalue') {
47  $db->begin();
48 
49  $mailfrom = GETPOST('MAILING_EMAIL_FROM', 'alpha');
50  $mailerror = GETPOST('MAILING_EMAIL_ERRORSTO', 'alpha');
51  $checkread = GETPOST('value', 'alpha');
52  $checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY', 'alpha');
53  $mailingdelay = GETPOST('MAILING_DELAY', 'int');
54  $contactbulkdefault = GETPOST('MAILING_CONTACT_DEFAULT_BULK_STATUS', 'int');
55 
56  $res = dolibarr_set_const($db, "MAILING_EMAIL_FROM", $mailfrom, 'chaine', 0, '', $conf->entity);
57  if (!($res > 0)) {
58  $error++;
59  }
60  $res = dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO", $mailerror, 'chaine', 0, '', $conf->entity);
61  if (!($res > 0)) {
62  $error++;
63  }
64  $res = dolibarr_set_const($db, "MAILING_DELAY", $mailingdelay, 'chaine', 0, '', $conf->entity);
65  if (!($res > 0)) {
66  $error++;
67  }
68  $res = dolibarr_set_const($db, "MAILING_CONTACT_DEFAULT_BULK_STATUS", $contactbulkdefault, 'chaine', 0, '', $conf->entity);
69  if (!($res > 0)) {
70  $error++;
71  }
72 
73  // Create temporary encryption key if nedded
74  $res = dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY", $checkread_key, 'chaine', 0, '', $conf->entity);
75  if (!($res > 0)) {
76  $error++;
77  }
78 
79 
80  if (!$error) {
81  $db->commit();
82  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
83  } else {
84  $db->rollback();
85  setEventMessages($langs->trans("Error"), null, 'errors');
86  }
87 }
88 if ($action == 'setonsearchandlistgooncustomerorsuppliercard') {
89  $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int');
90  $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity);
91  if (!($res > 0)) {
92  $error++;
93  }
94  if (!$error) {
95  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
96  } else {
97  setEventMessages($langs->trans("Error"), null, 'errors');
98  }
99 }
100 
101 /*
102  * View
103  */
104 
105 llxHeader('', $langs->trans("MailingSetup"));
106 
107 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
108 print load_fiche_titre($langs->trans("MailingSetup"), $linkback, 'title_setup');
109 
110 if (!empty($conf->use_javascript_ajax)) {
111  print "\n".'<script type="text/javascript">';
112  print '$(document).ready(function () {
113  $("#generate_token").click(function() {
114  $.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
115  action: \'getrandompassword\',
116  generic: true
117  },
118  function(token) {
119  $("#MAILING_EMAIL_UNSUBSCRIBE_KEY").val(token);
120  });
121  });
122  });';
123  print '</script>';
124 }
125 
126 print '<br>';
127 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
128 print '<input type="hidden" name="token" value="'.newToken().'">';
129 print '<input type="hidden" name="action" value="setvalue">';
130 
131 print '<table class="noborder centpercent">';
132 print '<tr class="liste_titre">';
133 print '<td>'.$langs->trans("Parameter").'</td>';
134 print '<td>'.$langs->trans("Value").'</td>';
135 print '<td>'.$langs->trans("Example").'</td>';
136 print "</tr>\n";
137 
138 print '<tr class="oddeven"><td>';
139 $help = img_help(1, $langs->trans("EMailHelpMsgSPFDKIM"));
140 print $langs->trans("MailingEMailFrom").' '.$help.'</td><td>';
141 print '<input size="32" type="text" name="MAILING_EMAIL_FROM" value="'.$conf->global->MAILING_EMAIL_FROM.'">';
142 if (!empty($conf->global->MAILING_EMAIL_FROM) && !isValidEmail($conf->global->MAILING_EMAIL_FROM)) {
143  print ' '.img_warning($langs->trans("BadEMail"));
144 }
145 print '</td><td><span class="opacitymedium">'.dol_escape_htmltag(($mysoc->name ? $mysoc->name : 'MyName').' <noreply@example.com>').'</span></td>';
146 print '</tr>';
147 
148 print '<tr class="oddeven"><td>';
149 print $langs->trans("MailingEMailError").'</td><td>';
150 print '<input size="32" type="text" name="MAILING_EMAIL_ERRORSTO" value="'.$conf->global->MAILING_EMAIL_ERRORSTO.'">';
151 if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && !isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) {
152  print ' '.img_warning($langs->trans("BadEMail"));
153 }
154 print '</td><td><span class="opacitymedium">webmaster@example.com></span></td>';
155 print '</tr>';
156 
157 print '<tr class="oddeven"><td>';
158 print $langs->trans("MailingDelay").'</td><td>';
159 print '<input class="width75" type="text" name="MAILING_DELAY" value="'.$conf->global->MAILING_DELAY.'">';
160 print '</td><td></td>';
161 print '</tr>';
162 
163 
164 // Constant to add salt into the unsubscribe and check read tag.
165 // It is also used as a security key parameter.
166 
167 print '<tr class="oddeven"><td>';
168 print $langs->trans("ActivateCheckReadKey").'</td><td>';
169 print '<input size="32" type="text" name="MAILING_EMAIL_UNSUBSCRIBE_KEY" id="MAILING_EMAIL_UNSUBSCRIBE_KEY" value="'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY.'">';
170 if (!empty($conf->use_javascript_ajax)) {
171  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
172 }
173 print '</td><td></td>';
174 print '</tr>';
175 
176 // default blacklist from mailing
177 print '<tr class="oddeven">';
178 print '<td>' . $langs->trans("DefaultBlacklistMailingStatus", $langs->transnoentitiesnoconv("No_Email")) . '</td>';
179 print '<td>';
180 $blacklist_setting=array(0=>$langs->trans('No'), 1=>$langs->trans('Yes'), 2=>$langs->trans('DefaultStatusEmptyMandatory'));
181 print $form->selectarray("MAILING_CONTACT_DEFAULT_BULK_STATUS", $blacklist_setting, $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS);
182 print '</td>';
183 print '<td></td>';
184 print '</tr>';
185 
186 
187 if (!empty($conf->use_javascript_ajax) && $conf->global->MAIN_FEATURES_LEVEL >= 1) {
188  print '<tr class="oddeven"><td>';
189  print $langs->trans("MailAdvTargetRecipients").'</td><td>';
190  print ajax_constantonoff('EMAILING_USE_ADVANCED_SELECTOR');
191  print '</td><td></td>';
192  print '</tr>';
193 }
194 
195 print '</table>';
196 
197 print $form->buttonsSaveCancel("Modify", '');
198 
199 print '</form>';
200 
201 // End of page
202 llxFooter();
203 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
img_help
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
Definition: functions.lib.php:4481
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
isValidEmail
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
Definition: functions.lib.php:3681
ajax_constantonoff
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='')
On/off button for constant.
Definition: ajax.lib.php:573
dolibarr_set_const
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:627
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59