dolibarr  19.0.0-dev
setupmail.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
4  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
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 // Load Dolibarr environment
27 require '../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
29 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/datapolicy/lib/datapolicy.lib.php';
32 
33 // Translations
34 $langs->loadLangs(array('admin', 'companies', 'members', 'datapolicy'));
35 
36 
37 // Parameters
38 $action = GETPOST('action', 'aZ09');
39 $backtopage = GETPOST('backtopage', 'alpha');
40 
41 if (GETPOST('l')) {
42  $l = GETPOST('l');
43 } else {
44  $l = $langs->defaultlang;
45 }
46 
47 // Security
48 if (!isModEnabled("datapolicy")) {
50 }
51 if (!$user->admin) {
53 }
54 
55 
56 /*
57  * Actions
58  */
59 
60 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
61 
62 if ($action == 'setvalue' && $user->admin) {
63  $db->begin();
64  $sub = "DATAPOLICYSUBJECT_".$l;
65  $result = dolibarr_set_const($db, $sub, GETPOST($sub), 'chaine', 0, '', $conf->entity);
66  $cont = "DATAPOLICYCONTENT_".$l;
67  $result = dolibarr_set_const($db, $cont, GETPOST($cont), 'chaine', 0, '', $conf->entity);
68  $cont = "TXTLINKDATAPOLICYACCEPT_".$l;
69  $result = dolibarr_set_const($db, $cont, GETPOST($cont), 'chaine', 0, '', $conf->entity);
70  $cont = "TXTLINKDATAPOLICYREFUSE_".$l;
71  $result = dolibarr_set_const($db, $cont, GETPOST($cont), 'chaine', 0, '', $conf->entity);
72  $sub = "DATAPOLICYACCEPT_".$l;
73  $result = dolibarr_set_const($db, $sub, GETPOST($sub), 'chaine', 0, '', $conf->entity);
74  $sub = "DATAPOLICYREFUSE_".$l;
75  $result = dolibarr_set_const($db, $sub, GETPOST($sub), 'chaine', 0, '', $conf->entity);
76  if (!($result > 0)) {
77  $error++;
78  }
79  if (!$error) {
80  $db->commit();
81  setEventMessage($langs->trans("SetupSaved"));
82  } else {
83  $db->rollback();
84  dol_print_error($db);
85  }
86 }
87 
88 
89 /*
90  * View
91  */
92 
93 $formadmin = new FormAdmin($db);
94 
95 $page_name = "datapolicySetup";
96 llxHeader('', $langs->trans($page_name));
97 
98 // Subheader
99 $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
100 
101 print load_fiche_titre($langs->trans($page_name), $linkback, 'generic');
102 
103 // Configuration header
105 print dol_get_fiche_head($head, 'emailing', '', -1, '');
106 
107 
108 print "<script type='text/javascript'>
109  $(document).ready(function(){
110  $('#default_lang').change(function(){
111  lang=$('#default_lang').val();
112  window.location.replace('" . $_SERVER['PHP_SELF']."?l='+lang);
113  });
114  });
115 </script>";
116 
117 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?l='.$l.'">';
118 print '<input type="hidden" name="token" value="'.newToken().'">';
119 print '<input type="hidden" name="action" value="setvalue">';
120 print '<table>';
121 if (getDolGlobalInt('MAIN_MULTILANGS')) {
122  print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', null, 0).'</td><td colspan="3" class="maxwidthonsmartphone">'."\n";
123  print img_picto('', 'language', 'class="pictofixedwidth"');
124  print $formadmin->select_language((GETPOST('l') ? GETPOST('l') : $langs->defaultlang), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone');
125  print '</tr>';
126 }
127 $subject = 'DATAPOLICYSUBJECT_'.$l;
128 $linka = 'TXTLINKDATAPOLICYACCEPT_'.$l;
129 $linkr = 'TXTLINKDATAPOLICYREFUSE_'.$l;
130 $content = 'DATAPOLICYCONTENT_'.$l;
131 $acc = 'DATAPOLICYACCEPT_'.$l;
132 $ref = 'DATAPOLICYREFUSE_'.$l;
133 print '<tr class"oddeven"><td class="fieldrequired">';
134 print $langs->trans('DATAPOLICYSUBJECTMAIL').'</td><td>';
135 print '<input type="text" name="'.$subject.'" value="'.$conf->global->$subject.'" />';
136 print '</td><tr>';
137 print '<tr class"oddeven"><td class="fieldrequired">';
138 print $langs->trans('DATAPOLICYCONTENTMAIL').'</td><td>';
139 print '<span class="opacitymedium">';
140 print $langs->trans('DATAPOLICYSUBSITUTION');
141 print '__LINKACCEPT__,__LINKREFUSED__,__FIRSTNAME__,__NAME__,__CIVILITY__';
142 print '</span>';
143 $doleditor = new DolEditor($content, $conf->global->$content, '', 250, 'Full', '', false, true, 1, 200, 70);
144 $doleditor->Create();
145 print '</td><tr>';
146 print '<tr class"oddeven"><td class="fieldrequired">';
147 print $langs->trans('TXTLINKDATAPOLICYACCEPT').'</td><td>';
148 print '<input type="text" name="'.$linka.'" value="'.$conf->global->$linka.'" />';
149 print '</td><tr>';
150 print '<tr class"oddeven"><td class="fieldrequired">';
151 print $langs->trans('TXTLINKDATAPOLICYREFUSE').'</td><td>';
152 print '<input type="text" name="'.$linkr.'" value="'.$conf->global->$linkr.'" />';
153 print '</td><tr>';
154 print '<tr class"oddeven"><td class="fieldrequired">';
155 
156 print $langs->trans('DATAPOLICYACCEPT').'</td><td>';
157 
158 $doleditor = new DolEditor($acc, getDolGlobalString($acc), '', 250, 'Full', '', false, true, 1, 200, 70);
159 $doleditor->Create();
160 print '</td><tr>';
161 print '<tr class"oddeven"><td class="fieldrequired">';
162 print $langs->trans('DATAPOLICYREFUSE').'</td><td>';
163 
164 print $langs->trans('');
165 $doleditor = new DolEditor($ref, getDolGlobalString($ref), '', 250, 'Full', '', false, true, 1, 200, 70);
166 $doleditor->Create();
167 print '</td><tr>';
168 print '</table>';
169 
170 print '<br><center><input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'"></center>';
171 
172 print '</form>';
173 
174 print dol_get_fiche_end();
175 
176 llxFooter();
177 $db->close();
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:638
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage a WYSIWYG editor.
Class to generate html code for admin pages.
datapolicyAdminPrepareHead()
Prepare admin pages header.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.