2006-02-20 23:32:07 +01:00
|
|
|
<?php
|
2012-03-29 18:04:10 +02:00
|
|
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2013-11-16 13:00:21 +01:00
|
|
|
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.org>
|
2013-08-14 12:48:00 +02:00
|
|
|
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
|
2006-02-20 23:32:07 +01:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2006-02-20 23:32:07 +01:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2011-08-01 00:21:57 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-02-20 23:32:07 +01:00
|
|
|
*/
|
2009-12-29 21:32:59 +01:00
|
|
|
|
2006-02-20 23:32:07 +01:00
|
|
|
/**
|
2009-12-29 21:32:59 +01:00
|
|
|
* \file htdocs/admin/mailing.php
|
|
|
|
|
* \ingroup mailing
|
|
|
|
|
* \brief Page to setup emailing module
|
|
|
|
|
*/
|
|
|
|
|
|
2012-08-22 23:24:21 +02:00
|
|
|
require '../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
2006-02-20 23:32:07 +01:00
|
|
|
|
2018-05-26 18:41:16 +02:00
|
|
|
// Load translation files required by the page
|
2018-05-03 21:27:52 +02:00
|
|
|
$langs->loadLangs(array("admin", "mails"));
|
2006-02-20 23:32:07 +01:00
|
|
|
|
2012-05-09 02:39:30 +02:00
|
|
|
if (!$user->admin) accessforbidden();
|
2006-02-20 23:32:07 +01:00
|
|
|
|
2012-03-29 18:04:10 +02:00
|
|
|
$action = GETPOST('action','alpha');
|
2006-02-20 23:32:07 +01:00
|
|
|
|
2012-05-09 02:39:30 +02:00
|
|
|
|
2012-04-30 13:49:29 +02:00
|
|
|
|
2009-10-14 13:04:09 +02:00
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
|
|
|
|
|
2012-11-18 18:36:50 +01:00
|
|
|
if ($action == 'setvalue')
|
2006-02-20 23:32:07 +01:00
|
|
|
{
|
2011-09-03 14:56:42 +02:00
|
|
|
$db->begin();
|
2012-04-28 15:50:52 +02:00
|
|
|
|
2012-03-29 18:04:10 +02:00
|
|
|
$mailfrom = GETPOST('MAILING_EMAIL_FROM','alpha');
|
|
|
|
|
$mailerror = GETPOST('MAILING_EMAIL_ERRORSTO','alpha');
|
2012-04-10 14:32:54 +02:00
|
|
|
$checkread = GETPOST('value','alpha');
|
2012-04-30 13:49:29 +02:00
|
|
|
$checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY','alpha');
|
2015-01-18 16:26:26 +01:00
|
|
|
$mailingdelay = GETPOST('MAILING_DELAY', 'int');
|
2012-04-30 13:49:29 +02:00
|
|
|
|
2011-09-03 14:56:42 +02:00
|
|
|
$res=dolibarr_set_const($db, "MAILING_EMAIL_FROM",$mailfrom,'chaine',0,'',$conf->entity);
|
|
|
|
|
if (! $res > 0) $error++;
|
|
|
|
|
$res=dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO",$mailerror,'chaine',0,'',$conf->entity);
|
|
|
|
|
if (! $res > 0) $error++;
|
2015-01-18 16:26:26 +01:00
|
|
|
$res=dolibarr_set_const($db, "MAILING_DELAY",$mailingdelay,'chaine',0,'',$conf->entity);
|
|
|
|
|
if (! $res > 0) $error++;
|
2013-11-16 13:00:21 +01:00
|
|
|
|
|
|
|
|
// Create temporary encryption key if nedded
|
2012-04-30 13:49:29 +02:00
|
|
|
$res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY",$checkread_key,'chaine',0,'',$conf->entity);
|
|
|
|
|
if (! $res > 0) $error++;
|
2018-05-21 10:58:16 +02:00
|
|
|
|
2013-08-14 12:48:00 +02:00
|
|
|
if (! $error)
|
2011-09-03 14:56:42 +02:00
|
|
|
{
|
|
|
|
|
$db->commit();
|
2015-10-28 19:28:18 +01:00
|
|
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
2011-09-03 14:56:42 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$db->rollback();
|
2015-10-28 19:28:18 +01:00
|
|
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
2006-02-20 23:32:07 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-10-14 13:04:09 +02:00
|
|
|
* View
|
2006-02-20 23:32:07 +01:00
|
|
|
*/
|
|
|
|
|
|
2011-09-02 20:25:11 +02:00
|
|
|
llxHeader('',$langs->trans("MailingSetup"));
|
2006-02-20 23:32:07 +01:00
|
|
|
|
2018-02-26 09:20:05 +01:00
|
|
|
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
2015-09-24 18:33:48 +02:00
|
|
|
print load_fiche_titre($langs->trans("MailingSetup"),$linkback,'title_setup');
|
2006-02-20 23:32:07 +01:00
|
|
|
|
2013-02-14 14:57:37 +01:00
|
|
|
if (! empty($conf->use_javascript_ajax))
|
|
|
|
|
{
|
|
|
|
|
print "\n".'<script type="text/javascript">';
|
|
|
|
|
print '$(document).ready(function () {
|
|
|
|
|
$("#generate_token").click(function() {
|
|
|
|
|
$.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
|
|
|
|
|
action: \'getrandompassword\',
|
|
|
|
|
generic: true
|
|
|
|
|
},
|
|
|
|
|
function(token) {
|
|
|
|
|
$("#MAILING_EMAIL_UNSUBSCRIBE_KEY").val(token);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});';
|
|
|
|
|
print '</script>';
|
|
|
|
|
}
|
|
|
|
|
|
2006-02-20 23:32:07 +01:00
|
|
|
print '<br>';
|
|
|
|
|
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
2009-05-17 10:01:54 +02:00
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
2006-02-20 23:32:07 +01:00
|
|
|
print '<input type="hidden" name="action" value="setvalue">';
|
|
|
|
|
|
2012-09-03 10:27:31 +02:00
|
|
|
print '<table class="noborder" width="100%">';
|
2006-02-20 23:32:07 +01:00
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
print '<td>'.$langs->trans("Parameter").'</td>';
|
|
|
|
|
print '<td>'.$langs->trans("Value").'</td>';
|
|
|
|
|
print "</tr>\n";
|
2009-12-29 21:32:59 +01:00
|
|
|
|
2017-04-14 13:02:29 +02:00
|
|
|
print '<tr class="oddeven"><td>';
|
2006-02-20 23:32:07 +01:00
|
|
|
print $langs->trans("MailingEMailFrom").'</td><td>';
|
2009-12-29 21:32:59 +01:00
|
|
|
print '<input size="32" type="text" name="MAILING_EMAIL_FROM" value="'.$conf->global->MAILING_EMAIL_FROM.'">';
|
2011-09-02 20:25:11 +02:00
|
|
|
if (!empty($conf->global->MAILING_EMAIL_FROM) && ! isValidEmail($conf->global->MAILING_EMAIL_FROM)) print ' '.img_warning($langs->trans("BadEMail"));
|
2009-12-29 21:32:59 +01:00
|
|
|
print '</td></tr>';
|
|
|
|
|
|
2017-04-14 13:02:29 +02:00
|
|
|
print '<tr class="oddeven"><td>';
|
2009-12-29 21:32:59 +01:00
|
|
|
print $langs->trans("MailingEMailError").'</td><td>';
|
|
|
|
|
print '<input size="32" type="text" name="MAILING_EMAIL_ERRORSTO" value="'.$conf->global->MAILING_EMAIL_ERRORSTO.'">';
|
2011-09-02 20:25:11 +02:00
|
|
|
if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && ! isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) print ' '.img_warning($langs->trans("BadEMail"));
|
2006-02-20 23:32:07 +01:00
|
|
|
print '</td></tr>';
|
|
|
|
|
|
2017-04-14 13:02:29 +02:00
|
|
|
print '<tr class="oddeven"><td>';
|
2015-01-18 16:26:26 +01:00
|
|
|
print $langs->trans("MailingDelay").'</td><td>';
|
|
|
|
|
print '<input size="32" type="text" name="MAILING_DELAY" value="'.$conf->global->MAILING_DELAY.'">';
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
2018-05-21 10:58:16 +02:00
|
|
|
|
2013-11-16 13:00:21 +01:00
|
|
|
// Constant to add salt into the unsubscribe and check read tag.
|
|
|
|
|
// It is also used as a security key parameter.
|
2017-04-14 11:22:48 +02:00
|
|
|
|
2017-04-14 13:02:29 +02:00
|
|
|
print '<tr class="oddeven"><td>';
|
2012-04-30 13:49:29 +02:00
|
|
|
print $langs->trans("ActivateCheckReadKey").'</td><td>';
|
2013-11-16 13:00:21 +01:00
|
|
|
print '<input size="32" type="text" name="MAILING_EMAIL_UNSUBSCRIBE_KEY" id="MAILING_EMAIL_UNSUBSCRIBE_KEY" value="'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY.'">';
|
|
|
|
|
if (! empty($conf->use_javascript_ajax)) print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
|
2012-04-30 13:49:29 +02:00
|
|
|
print '</td></tr>';
|
2012-04-10 14:32:54 +02:00
|
|
|
|
2018-05-21 10:58:16 +02:00
|
|
|
if (!empty($conf->use_javascript_ajax) && $conf->global->MAIN_FEATURES_LEVEL >=1) {
|
|
|
|
|
print '<tr class="oddeven"><td>';
|
|
|
|
|
print $langs->trans("MailAdvTargetRecipients").'</td><td>';
|
|
|
|
|
print ajax_constantonoff('EMAILING_USE_ADVANCED_SELECTOR');
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-18 18:36:50 +01:00
|
|
|
print '</table>';
|
2006-02-20 23:32:07 +01:00
|
|
|
|
2012-09-03 10:27:31 +02:00
|
|
|
print '<br>';
|
2012-09-07 17:23:16 +02:00
|
|
|
print '<div align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
|
2006-02-20 23:32:07 +01:00
|
|
|
|
2012-11-18 18:36:50 +01:00
|
|
|
print '</form>';
|
|
|
|
|
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2006-02-20 23:32:07 +01:00
|
|
|
|
2012-09-03 10:27:31 +02:00
|
|
|
$db->close();
|