* Copyright (C) 2005-2013 Laurent Destailleur * Copyright (C) 2011-2013 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 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 * along with this program. If not, see . */ /** * \file htdocs/admin/mailing.php * \ingroup mailing * \brief Page to setup emailing module */ // Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "mails")); if (!$user->admin) { accessforbidden(); } $action = GETPOST('action', 'aZ09'); $form = new Form($db); /* * Actions */ if ($action == 'setvalue') { $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'); $contactbulkdefault = GETPOSTINT('MAILING_CONTACT_DEFAULT_BULK_STATUS'); if (GETPOST('MAILING_DELAY', 'alpha') != '') { $mailingdelay = price2num(GETPOST('MAILING_DELAY', 'alpha'), 3); // Not less than 1 millisecond. } else { $mailingdelay = ''; } // Clean data if ((float) $mailingdelay > 10) { $mailingdelay = 10; } if (GETPOST('MAILING_DELAY', 'alpha') != '' && GETPOST('MAILING_DELAY', 'alpha') != '0' && (float) $mailingdelay < 0.001) { $mailingdelay = 0.001; } $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++; } $res = dolibarr_set_const($db, "MAILING_CONTACT_DEFAULT_BULK_STATUS", $contactbulkdefault, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; } // Create temporary encryption key if needed $res = dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY", $checkread_key, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; } if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { $db->rollback(); setEventMessages($langs->trans("Error"), null, 'errors'); } } if ($action == 'setonsearchandlistgooncustomerorsuppliercard') { $setonsearchandlistgooncustomerorsuppliercard = GETPOSTINT('value'); $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity); if (!($res > 0)) { $error++; } if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } } /* * View */ llxHeader('', $langs->trans("MailingSetup"), '', '', 0, 0, '', '', '', 'mod-admin page-mailing'); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("MailingSetup"), $linkback, 'title_setup'); $constname = 'MAILING_EMAIL_UNSUBSCRIBE_KEY'; // Add button to autosuggest a key include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; print dolJSToSetRandomPassword($constname); print '
'; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // Constant to add salt into the unsubscribe and check read tag. // It is also used as a security key parameter. print ''; print ''; print ''; // default blacklist from mailing print ''; print ''; print ''; print ''; print ''; if (!empty($conf->use_javascript_ajax) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1) { print ''; print ''; print ''; } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").''.$langs->trans("Example").'
'; $help = img_help(1, $langs->trans("EMailHelpMsgSPFDKIM")); print $langs->trans("MailingEMailFrom").' '.$help.''; print ''; if (getDolGlobalString('MAILING_EMAIL_FROM') && !isValidEmail($conf->global->MAILING_EMAIL_FROM)) { print ' '.img_warning($langs->trans("BadEMail")); } print ''.dol_escape_htmltag(($mysoc->name ? $mysoc->name : 'MyName').' ').'
'; print $langs->trans("MailingEMailError").''; print ''; if (getDolGlobalString('MAILING_EMAIL_ERRORSTO') && !isValidEmail(getDolGlobalString('MAILING_EMAIL_ERRORSTO'))) { print ' '.img_warning($langs->trans("BadEMail")); } print ''.dol_escape_htmltag('').'
'; print $form->textwithpicto($langs->trans("MailingDelay"), $langs->trans("IfDefinedUseAValueBeetween", '0.001', '10')).''; print ''; print '
'; print $langs->trans("ActivateCheckReadKey").''; print ''; if (!empty($conf->use_javascript_ajax)) { print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); } print '
' . $langs->trans("DefaultBlacklistMailingStatus", $langs->transnoentitiesnoconv("No_Email")) . ''; $blacklist_setting=array(0=>$langs->trans('No'), 1=>$langs->trans('Yes'), 2=>$langs->trans('DefaultStatusEmptyMandatory')); print $form->selectarray("MAILING_CONTACT_DEFAULT_BULK_STATUS", $blacklist_setting, getDolGlobalString('MAILING_CONTACT_DEFAULT_BULK_STATUS')); print '
'; print $langs->trans("MailAdvTargetRecipients").''; print ajax_constantonoff('EMAILING_USE_ADVANCED_SELECTOR'); print '
'; print $form->buttonsSaveCancel("Modify", ''); print '
'; // End of page llxFooter(); $db->close();