* Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2011-2012 Juanjo Menent * * 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 2 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 * along with this program. If not, see . */ /** * \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"); $langs->load("admin"); $langs->load("mails"); if (!$user->admin) accessforbidden(); $action = GETPOST('action','alpha'); /* * Actions */ if ($action == 'setvalue' && $user->admin) { $db->begin(); $mailfrom = GETPOST('MAILING_EMAIL_FROM','alpha'); $mailerror = GETPOST('MAILING_EMAIL_ERRORSTO','alpha'); $checkread = GETPOST('value','alpha'); $checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY','alpha'); $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++; if ($checkread=='on') { $res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE",1,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; } else if ($checkread=='off') { $res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE",0,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; } //Create temporary encryption key if nedded if (($conf->global->MAILING_EMAIL_UNSUBSCRIBE==1) && (empty($checkread_key))) { $checkread_key=getRandomPassword(true); } $res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY",$checkread_key,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; if (! $error) { $db->commit(); $mesg = "".$langs->trans("SetupSaved").""; } else { $db->rollback(); $mesg = "".$langs->trans("Error").""; } } /* * View */ llxHeader('',$langs->trans("MailingSetup")); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("MailingSetup"),$linkback,'setup'); dol_htmloutput_mesg($mesg); print '
'; print '
'; print ''; print ''; $var=true; print ''; print ''; print ''; print ''; print "\n"; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; $var=!$var; print ''; print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $langs->trans("MailingEMailFrom").''; print ''; if (!empty($conf->global->MAILING_EMAIL_FROM) && ! isValidEmail($conf->global->MAILING_EMAIL_FROM)) print ' '.img_warning($langs->trans("BadEMail")); print '
'; print $langs->trans("MailingEMailError").''; print ''; if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && ! isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) print ' '.img_warning($langs->trans("BadEMail")); print '
'; print $langs->trans("ActivateCheckRead").''; if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE==1) { print ''; print img_picto($langs->trans("Enabled"),'switch_on'); print ''; $readonly=''; } else { print ''; print img_picto($langs->trans("Disabled"),'switch_off'); print ''; $readonly='disabled="disabled"'; } print '
'; print $langs->trans("ActivateCheckReadKey").''; print ''; print '
'; $db->close(); llxFooter(); ?>