Extract mail creation for FindPollsByMail into NotificationService

This commit is contained in:
Liquidsoul 2019-04-17 17:39:33 +02:00
parent 26d3552276
commit c72dfa17b8
No known key found for this signature in database
GPG Key ID: 15983D72D696931D
2 changed files with 10 additions and 4 deletions

View File

@ -110,4 +110,11 @@ class NotificationService {
$this->mailService->send($email, $subject, $body);
}
function sendFindPollsByMailNotification($mail, &$polls) {
$this->smarty->assign('polls', $polls);
$body = $this->smarty->fetch('mail/find_polls.tpl');
$this->mailService->send($mail, __('FindPolls', 'List of your polls') . ' - ' . NOMAPPLICATION, $body, 'SEND_POLLS');
}
}

View File

@ -20,6 +20,7 @@
use Framadate\Message;
use Framadate\Services\LogService;
use Framadate\Services\MailService;
use Framadate\Services\NotificationService;
use Framadate\Services\PollService;
include_once __DIR__ . '/app/inc/init.php';
@ -29,6 +30,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);
/* PAGE */
/* ---- */
@ -40,10 +42,7 @@ if (!empty($_POST['mail'])) {
$polls = $pollService->findAllByAdminMail($mail);
if (count($polls) > 0) {
$smarty->assign('polls', $polls);
$body = $smarty->fetch('mail/find_polls.tpl');
$mailService->send($mail, __('FindPolls', 'List of your polls') . ' - ' . NOMAPPLICATION, $body, 'SEND_POLLS');
$notificationService->sendFindPollsByMailNotification($mail, $polls);
$message = new Message('success', __('FindPolls', 'Polls sent'));
} else {
$message = new Message('warning', __('Error', 'No polls found'));