diff --git a/create_classic_poll.php b/create_classic_poll.php index 5c8be305bb4905b59f1d722c7f5553cbfbf45970..15966ad28ca52259e30dc16c3f72bc4381f4acb3 100644 --- a/create_classic_poll.php +++ b/create_classic_poll.php @@ -21,6 +21,7 @@ use Framadate\Form; use Framadate\Services\InputService; use Framadate\Services\LogService; use Framadate\Services\MailService; +use Framadate\Services\NotificationService; use Framadate\Services\PollService; use Framadate\Services\PurgeService; use Framadate\Services\SessionService; @@ -33,6 +34,7 @@ include_once __DIR__ . '/app/inc/init.php'; $logService = new LogService(); $pollService = new PollService($connect, $logService); $mailService = new MailService($config['use_smtp'], $config['smtp_options'], $config['use_sendmail']); +$notificationService = new NotificationService($mailService, $smarty); $purgeService = new PurgeService($connect, $logService); $sessionService = new SessionService(); @@ -185,15 +187,7 @@ switch ($step) { // Send confirmation by mail if enabled if ($config['use_smtp'] === true && $mailService->isValidEmail($form->admin_mail)) { - $smarty->assign('poll_creator_name', Utils::htmlMailEscape($form->admin_name)); - $smarty->assign('poll_name', Utils::htmlMailEscape($form->title)); - $smarty->assign('poll_url', Utils::getUrlSondage($poll_id)); - $message_participants = $smarty->fetch('mail/participants_forward_email.html.tpl'); - $mailService->send($form->admin_mail, '[' . NOMAPPLICATION . '][' . __('Mail', 'Participant link') . '] ' . __('Generic', 'Poll') . ': ' . $form->title, $message_participants); - - $smarty->assign('poll_admin_url', Utils::getUrlSondage($admin_poll_id, true)); - $message_admin = $smarty->fetch('mail/creation_notification_email.html.tpl'); - $mailService->send($form->admin_mail, '[' . NOMAPPLICATION . '][' . __('Mail', 'Message for the author') . '] ' . __('Generic', 'Poll') . ': ' . $form->title, $message_admin); + $notificationService->sendPollCreationMails($form->admin_mail, $form->admin_name, $form->title, $poll_id, $admin_poll_id); } // Clean Form data in $_SESSION diff --git a/create_date_poll.php b/create_date_poll.php index af3378ca28f18ee24d41b710cd3012413b5aad67..998653f1d4a8b529418e52005098d0ce9d426a26 100644 --- a/create_date_poll.php +++ b/create_date_poll.php @@ -21,6 +21,7 @@ use Framadate\Form; use Framadate\Services\InputService; use Framadate\Services\LogService; use Framadate\Services\MailService; +use Framadate\Services\NotificationService; use Framadate\Services\PollService; use Framadate\Services\PurgeService; use Framadate\Services\SessionService; @@ -33,6 +34,7 @@ include_once __DIR__ . '/app/inc/init.php'; $logService = new LogService(); $pollService = new PollService($connect, $logService); $mailService = new MailService($config['use_smtp'], $config['smtp_options'], $config['use_sendmail']); +$notificationService = new NotificationService($mailService, $smarty); $purgeService = new PurgeService($connect, $logService); $inputService = new InputService(); $sessionService = new SessionService(); @@ -223,22 +225,8 @@ switch ($step) { $admin_poll_id = $ids[1]; // Send confirmation by mail if enabled - if ($config['use_smtp'] === true) { - $message = __('Mail', "This is the message to forward to the poll participants."); - $message .= '<br/><br/>'; - $message .= Utils::htmlEscape($form->admin_name) . ' ' . __('Mail', 'has just created a poll called') . ' : "' . Utils::htmlEscape($form->title) . '".<br/>'; - $message .= __('Mail', 'Thank you for participating in the poll at the following link') . ' :<br/><br/><a href="%1$s">%1$s</a>'; - - $message_admin = __('Mail', "This message should NOT be sent to the poll participants. You should keep it private. <br/><br/>You can modify your poll at the following link"); - $message_admin .= ' :<br/><br/><a href="%1$s">%1$s</a>'; - - $message = sprintf($message, Utils::getUrlSondage($poll_id)); - $message_admin = sprintf($message_admin, Utils::getUrlSondage($admin_poll_id, true)); - - if ($mailService->isValidEmail($form->admin_mail)) { - $mailService->send($form->admin_mail, '[' . NOMAPPLICATION . '][' . __('Mail', 'Message for the author') . '] ' . __('Generic', 'Poll') . ': ' . $form->title, $message_admin); - $mailService->send($form->admin_mail, '[' . NOMAPPLICATION . '][' . __('Mail', 'Participant link') . '] ' . __('Generic', 'Poll') . ': ' . $form->title, $message); - } + if ($config['use_smtp'] === true && $mailService->isValidEmail($form->admin_mail)) { + $notificationService->sendPollCreationMails($form->admin_mail, $form->admin_name, $form->title, $poll_id, $admin_poll_id); } // Clean Form data in $_SESSION