/** * @test */ function should_not_send_2_mails_in_a_short_interval() { // Given $mailService = new MailService(true); $_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time()]; // When $canSendMsg = $mailService->canSendMsg(self::MSG_KEY); // Then $this->assertEquals(false, $canSendMsg); }
/** * Send a notification to the poll admin to notify him about an update. * * @param stdClass $poll The poll * @param MailService $mailService The mail service * @param int $type cf: Constants on the top of this page */ function sendUpdateNotification($poll, $mailService, $type) { if (!isset($_SESSION['mail_sent'])) { $_SESSION['mail_sent'] = []; } if ($poll->receiveNewVotes) { $subject = '[' . NOMAPPLICATION . '] ' . __f('Mail', 'Notification of poll: %s', $poll->title); $message = ''; switch ($type) { case UPDATE_POLL: $message = __f('Mail', 'Someone just change your poll available at the following link %s.', Utils::getUrlSondage($poll->admin_id, true)) . "\n\n"; break; case DELETED_POLL: $message = __f('Mail', 'Someone just delete your poll %s.', Utils::htmlEscape($poll->title)) . "\n\n"; break; } $messageTypeKey = $type . '-' . $poll->id; $mailService->send($poll->admin_mail, $subject, $message, $messageTypeKey); } }
* * Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ * Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft) */ use Framadate\Services\LogService; use Framadate\Services\PollService; use Framadate\Services\MailService; use Framadate\Services\PurgeService; use Framadate\Utils; use Framadate\Choice; include_once __DIR__ . '/app/inc/init.php'; /* Service */ /*---------*/ $logService = new LogService(); $pollService = new PollService($connect, $logService); $mailService = new MailService($config['use_smtp']); $purgeService = new PurgeService($connect, $logService); if (is_file('bandeaux_local.php')) { include_once 'bandeaux_local.php'; } else { include_once 'bandeaux.php'; } // Step 1/4 : error if $_SESSION from info_sondage are not valid if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || ($config['use_smtp'] ? empty($_SESSION['form']->admin_mail) : false)) { Utils::print_header(__('Error', 'Error!')); bandeau_titre(__('Error', 'Error!')); echo ' <div class="alert alert-danger"> <h3>' . __('Error', 'You haven\'t filled the first section of the poll creation.') . ' !</h3> <p>' . __('Generic', 'Back to the homepage of') . ' <a href="' . Utils::get_server_name() . '"> ' . NOMAPPLICATION . '</a></p> </div>' . "\n";
* ne se trouve pas avec ce fichier vous pouvez l'obtenir sur * http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt * * Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ * Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft) */ use Framadate\Message; use Framadate\Services\LogService; use Framadate\Services\MailService; use Framadate\Services\PollService; include_once __DIR__ . '/app/inc/init.php'; /* SERVICES */ /* -------- */ $logService = new LogService(); $pollService = new PollService($connect, $logService); $mailService = new MailService($config['use_smtp']); /* PAGE */ /* ---- */ $message = null; if (!empty($_POST['mail'])) { $mail = filter_input(INPUT_POST, 'mail', FILTER_VALIDATE_EMAIL); if ($mail) { $polls = $pollService->findAllByAdminMail($mail); if (count($polls) > 0) { $smarty->assign('polls', $polls); $body = $smarty->fetch('mail/find_polls.tpl'); $mailService->send($mail, __('Homepage', 'Where are my polls'), $body, 'SEND_POLLS'); $message = new Message('success', __('FindPolls', 'Polls sent')); } else { $message = new Message('warning', __('Error', 'No polls found')); }