dolibarr/htdocs/admin/mailing.php

158 lines
5.4 KiB
PHP
Raw Normal View History

<?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>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (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/>.
*/
/**
* \file htdocs/admin/mailing.php
* \ingroup mailing
* \brief Page to setup emailing module
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
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"));
2012-05-09 02:39:30 +02:00
if (!$user->admin) accessforbidden();
2012-03-29 18:04:10 +02:00
$action = GETPOST('action','alpha');
2012-05-09 02:39:30 +02:00
2009-10-14 13:04:09 +02:00
/*
* Actions
*/
if ($action == 'setvalue')
{
2011-09-03 14:56:42 +02:00
$db->begin();
2012-03-29 18:04:10 +02:00
$mailfrom = GETPOST('MAILING_EMAIL_FROM','alpha');
$mailerror = GETPOST('MAILING_EMAIL_ERRORSTO','alpha');
$checkread = GETPOST('value','alpha');
$checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY','alpha');
$mailingdelay = GETPOST('MAILING_DELAY', 'int');
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++;
$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
$res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY",$checkread_key,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
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');
}
}
/*
2009-10-14 13:04:09 +02:00
* View
*/
2011-09-02 20:25:11 +02:00
llxHeader('',$langs->trans("MailingSetup"));
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>';
print load_fiche_titre($langs->trans("MailingSetup"),$linkback,'title_setup');
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>';
}
print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setvalue">';
2012-09-03 10:27:31 +02:00
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print "</tr>\n";
print '<tr class="oddeven"><td>';
print $langs->trans("MailingEMailFrom").'</td><td>';
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"));
print '</td></tr>';
print '<tr class="oddeven"><td>';
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"));
print '</td></tr>';
print '<tr class="oddeven"><td>';
print $langs->trans("MailingDelay").'</td><td>';
print '<input size="32" type="text" name="MAILING_DELAY" value="'.$conf->global->MAILING_DELAY.'">';
print '</td></tr>';
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.
print '<tr class="oddeven"><td>';
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 '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
print '</td></tr>';
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>';
}
print '</table>';
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>';
print '</form>';
llxFooter();
2012-09-03 10:27:31 +02:00
$db->close();