Merge branch 'mail/templates' into 'develop'
Extract mail content creation and sending into the NotificationService See merge request framasoft/framadate/framadate!382
This commit is contained in:
commit
93d9f44bb1
|
@ -43,7 +43,7 @@ $logService = new LogService();
|
|||
$pollService = new PollService($connect, $logService);
|
||||
$inputService = new InputService();
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options'], $config['use_sendmail']);
|
||||
$notificationService = new NotificationService($mailService);
|
||||
$notificationService = new NotificationService($mailService, $smarty);
|
||||
$securityService = new SecurityService();
|
||||
|
||||
/* PAGE */
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
use Framadate\Message;
|
||||
use Framadate\Services\LogService;
|
||||
use Framadate\Services\MailService;
|
||||
use Framadate\Services\NotificationService;
|
||||
use Framadate\Services\PollService;
|
||||
use Framadate\Services\SessionService;
|
||||
use Framadate\Utils;
|
||||
|
@ -29,6 +30,7 @@ include_once __DIR__ . '/../app/inc/init.php';
|
|||
$logService = new LogService();
|
||||
$sessionService = new SessionService();
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options'], $config['use_sendmail']);
|
||||
$notificationService = new NotificationService($mailService, $smarty);
|
||||
$pollService = new PollService($connect, $logService);
|
||||
|
||||
$result = false;
|
||||
|
@ -70,16 +72,7 @@ if (is_null($message)) {
|
|||
}
|
||||
|
||||
if (is_null($message)) {
|
||||
$url = Utils::getUrlSondage($poll_id, false, $editedVoteUniqueId);
|
||||
|
||||
$smarty->assign('poll', $poll);
|
||||
$smarty->assign('poll_id', $poll_id);
|
||||
$smarty->assign('editedVoteUniqueId', $editedVoteUniqueId);
|
||||
$body = $smarty->fetch('mail/remember_edit_link.tpl');
|
||||
|
||||
$subject = '[' . NOMAPPLICATION . '][' . __('EditLink', 'REMINDER') . '] ' . __f('EditLink', 'Edit link for poll "%s"', $poll->title);
|
||||
|
||||
$mailService->send($email, $subject, $body);
|
||||
$notificationService->sendEditedVoteNotification($email, $poll, $poll_id, $editedVoteUniqueId);
|
||||
$sessionService->remove("Common", SESSION_EDIT_LINK_TOKEN);
|
||||
$sessionService->set("Common", SESSION_EDIT_LINK_TIME, time());
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ $pollService = new PollService($connect, $logService);
|
|||
$adminPollService = new AdminPollService($connect, $pollService, $logService);
|
||||
$inputService = new InputService();
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options'], $config['use_sendmail']);
|
||||
$notificationService = new NotificationService($mailService);
|
||||
$notificationService = new NotificationService($mailService, $smarty);
|
||||
$sessionService = new SessionService();
|
||||
|
||||
/* PAGE */
|
||||
|
|
|
@ -15,9 +15,11 @@ class NotificationService {
|
|||
const DELETED_POLL = 11;
|
||||
|
||||
private $mailService;
|
||||
private $smarty;
|
||||
|
||||
function __construct(MailService $mailService) {
|
||||
function __construct(MailService $mailService, \Smarty $smarty) {
|
||||
$this->mailService = $mailService;
|
||||
$this->smarty = $smarty;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,4 +85,36 @@ class NotificationService {
|
|||
{
|
||||
return $type >= self::UPDATE_POLL;
|
||||
}
|
||||
|
||||
function sendPollCreationMails($creator_mail, $creator_name, $poll_name, $poll_id, $admin_poll_id) {
|
||||
$this->smarty->assign('poll_creator_name', Utils::htmlMailEscape($creator_name));
|
||||
$this->smarty->assign('poll_name', Utils::htmlMailEscape($poll_name));
|
||||
$this->smarty->assign('poll_url', Utils::getUrlSondage($poll_id));
|
||||
$message_participants = $this->smarty->fetch('mail/participants_forward_email.html.tpl');
|
||||
$this->mailService->send($creator_mail, '[' . NOMAPPLICATION . '][' . __('Mail', 'Participant link') . '] ' . __('Generic', 'Poll') . ': ' . $poll_name, $message_participants);
|
||||
|
||||
$this->smarty->assign('poll_admin_url', Utils::getUrlSondage($admin_poll_id, true));
|
||||
$message_admin = $this->smarty->fetch('mail/creation_notification_email.html.tpl');
|
||||
$this->mailService->send($creator_mail, '[' . NOMAPPLICATION . '][' . __('Mail', 'Message for the author') . '] ' . __('Generic', 'Poll') . ': ' . $poll_name, $message_admin);
|
||||
}
|
||||
|
||||
function sendEditedVoteNotification($email, &$poll, $poll_id, $edited_vote_id) {
|
||||
$url = Utils::getUrlSondage($poll_id, false, $edited_vote_id);
|
||||
|
||||
$this->smarty->assign('poll', $poll);
|
||||
$this->smarty->assign('poll_id', $poll_id);
|
||||
$this->smarty->assign('editedVoteUniqueId', $edited_vote_id);
|
||||
$body = $this->smarty->fetch('mail/remember_edit_link.tpl');
|
||||
|
||||
$subject = '[' . NOMAPPLICATION . '][' . __('EditLink', 'REMINDER') . '] ' . __f('EditLink', 'Edit link for poll "%s"', $poll->title);
|
||||
|
||||
$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');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
@ -184,19 +186,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::htmlMailEscape($form->admin_name) . ' ' . __('Mail', 'has just created a poll called') . ' : "' . Utils::htmlMailEscape($form->title) . '".<br/>';
|
||||
$message .= sprintf(__('Mail', 'Thank you for participating in the poll at the following link') . ' :<br/><br/><a href="%1$s">%1$s</a>', Utils::getUrlSondage($poll_id));
|
||||
|
||||
$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 .= sprintf(' :<br/><br/><a href="%1$s">%1$s</a>', 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'));
|
||||
|
|
|
@ -59,7 +59,7 @@ $logService = new LogService();
|
|||
$pollService = new PollService($connect, $logService);
|
||||
$inputService = new InputService();
|
||||
$mailService = new MailService($config['use_smtp'], $config['smtp_options'], $config['use_sendmail']);
|
||||
$notificationService = new NotificationService($mailService);
|
||||
$notificationService = new NotificationService($mailService, $smarty);
|
||||
$securityService = new SecurityService();
|
||||
$sessionService = new SessionService();
|
||||
|
||||
|
|
4
tpl/mail/creation_notification_email.html.tpl
Normal file
4
tpl/mail/creation_notification_email.html.tpl
Normal file
|
@ -0,0 +1,4 @@
|
|||
{__('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")}:
|
||||
<br/>
|
||||
<br/>
|
||||
<a href="{$poll_admin_url}">{$poll_admin_url}</a>
|
1
tpl/mail/participants_forward_email.html.tpl
Normal file
1
tpl/mail/participants_forward_email.html.tpl
Normal file
|
@ -0,0 +1 @@
|
|||
{__('Mail', "This is the message to forward to the poll participants.")}<br/><br/>{$poll_creator_name} {__('Mail', 'has just created a poll called')} {$poll_name}<br/>{__('Mail', 'Thank you for participating in the poll at the following link')}:<br/><br/><a href="{$poll_url}">{$poll_url}</a>
|
Loading…
Reference in New Issue
Block a user