Commit 87150cc9 authored by Olivier PEREZ's avatar Olivier PEREZ
Browse files

Add column receiveNewComments to poll table, to send notification when a user wrote a comment.

parent e9b456ad
<?php
use Framadate\Migration\From_0_0_to_0_8_Migration;
use Framadate\Migration\From_0_8_to_0_9_Migration;
use Framadate\Migration\From_0_9_to_0_9_1_Migration;
use Framadate\Migration\Migration;
use Framadate\Utils;
......@@ -9,7 +10,8 @@ include_once __DIR__ . '/../app/inc/init.php';
// List a Migration sub classes to execute
$migrations = [
new From_0_0_to_0_8_Migration(),
new From_0_8_to_0_9_Migration()
new From_0_8_to_0_9_Migration(),
new From_0_9_to_0_9_1_Migration()
];
// ---------------------------------------
......@@ -28,8 +30,6 @@ CREATE TABLE IF NOT EXISTS `' . $prefixedMigrationTable . '` (
)
ENGINE = MyISAM
DEFAULT CHARSET = utf8;');
output('Table ' . $prefixedMigrationTable . ' created.');
}
$selectStmt = $pdo->prepare('SELECT id FROM ' . $prefixedMigrationTable . ' WHERE name=?');
......
......@@ -39,6 +39,11 @@ class Form
*/
public $receiveNewVotes;
/**
* If true, notify poll administrator when new comment is posted.
*/
public $receiveNewComments;
/**
* List of available choices
*/
......
......@@ -75,4 +75,3 @@ CREATE TABLE IF NOT EXISTS `user_studs` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;');
}
}
\ No newline at end of file
......@@ -207,4 +207,3 @@ INSERT INTO `' . Utils::table('vote') . '`
}
}
\ No newline at end of file
<?php
namespace Framadate\Migration;
use Framadate\Utils;
/**
* This class executes the aciton in database to migrate data from version 0.9 to 0.9.1.
*
* @package Framadate\Migration
*/
class From_0_9_to_0_9_1_Migration implements Migration {
function __construct() {
}
/**
* This method could check if the execute method should be called.
* It is called before the execute method.
*
* @param \PDO $pdo The connection to database
* @return bool true is the Migration should be executed.
*/
function preCondition(\PDO $pdo) {
$stmt = $pdo->query('SHOW TABLES');
$tables = $stmt->fetchAll(\PDO::FETCH_COLUMN);
// Check if tables of v0.8 are presents
$diff = array_diff([Utils::table('poll'), Utils::table('slot'), Utils::table('vote'), Utils::table('comment')], $tables);
return count($diff) === 0;
}
/**
* This methode is called only one time in the migration page.
*
* @param \PDO $pdo The connection to database
* @return bool true is the execution succeeded
*/
function execute(\PDO $pdo) {
$this->alterPollTable($pdo);
return true;
}
private function alterPollTable(\PDO $pdo) {
$pdo->exec('
ALTER TABLE `' . Utils::table('poll') . '`
ADD `receiveNewComments` TINYINT(1) DEFAULT \'0\'
AFTER `receiveNewVotes`');
}
}
......@@ -138,10 +138,10 @@ class PollService {
// TODO Extract this to FramaDB (or repository layer)
$sql = 'INSERT INTO ' . Utils::table('poll') . '
(id, admin_id, title, description, admin_name, admin_mail, end_date, format, editable, receiveNewVotes)
VALUES (?,?,?,?,?,?,FROM_UNIXTIME(?),?,?,?)';
(id, admin_id, title, description, admin_name, admin_mail, end_date, format, editable, receiveNewVotes, receiveNewComments)
VALUES (?,?,?,?,?,?,FROM_UNIXTIME(?),?,?,?,?)';
$prepared = $this->connect->prepare($sql);
$prepared->execute(array($poll_id, $admin_poll_id, $form->title, $form->description, $form->admin_name, $form->admin_mail, $form->end_date, $form->format, $form->editable, $form->receiveNewVotes));
$prepared->execute(array($poll_id, $admin_poll_id, $form->title, $form->description, $form->admin_name, $form->admin_mail, $form->end_date, $form->format, $form->editable, $form->receiveNewVotes, $form->receiveNewComments));
$prepared = $this->connect->prepare('INSERT INTO ' . Utils::table('slot') . ' (poll_id, title, moments) VALUES (?, ?, ?)');
......
......@@ -18,7 +18,7 @@
*/
// FRAMADATE version
const VERSION = 0.9;
const VERSION = '0.9.1';
// Application name
const NOMAPPLICATION = '<Application name>';
......@@ -59,6 +59,7 @@ $ALLOWED_LANGUAGES = [
const POLL_REGEX = '/^[a-z0-9]+$/';
const CHOICE_REGEX = '/^[012]$/';
const NAME_REGEX = '/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9_ -]+$/i';
const BOOLEAN_REGEX = '/^(on|off|true|false|1|0)$/';
// Path to logo
const LOGOBANDEAU = '<relative path to the logo file>';
......
......@@ -42,12 +42,13 @@ if ((isset($_GET['choix_sondage']) && $_GET['choix_sondage'] == 'date') ||
// We clean the data
$poursuivre = filter_input(INPUT_POST, 'poursuivre', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^(creation_sondage_date|creation_sondage_autre)$/']]);
$titre = filter_input(INPUT_POST, 'titre', FILTER_SANITIZE_STRING);
$nom = filter_input(INPUT_POST, 'nom', FILTER_SANITIZE_STRING);
$adresse = filter_input(INPUT_POST, 'adresse', FILTER_VALIDATE_EMAIL);
$commentaires = filter_input(INPUT_POST, 'commentaires', FILTER_SANITIZE_STRING);
$editable = filter_input(INPUT_POST, 'editable', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^(on|off|true|false|1|0)$/']]);
$receiveNewVotes = filter_input(INPUT_POST, 'receiveNewVotes', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^(on|off|true|false|1|0)$/']]);
$title = filter_input(INPUT_POST, 'titre', FILTER_SANITIZE_STRING);
$name = filter_input(INPUT_POST, 'name', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => NAME_REGEX]]);
$address = filter_input(INPUT_POST, 'adresse', FILTER_VALIDATE_EMAIL);
$description = filter_input(INPUT_POST, 'commentaires', FILTER_SANITIZE_STRING);
$editable = filter_input(INPUT_POST, 'editable', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
$receiveNewVotes = filter_input(INPUT_POST, 'receiveNewVotes', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
$receiveNewComments = filter_input(INPUT_POST, 'receiveNewComments', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
// On initialise également les autres variables
......@@ -58,60 +59,61 @@ $erreur_injection_commentaires = false;
#tests
if (!empty($_POST['poursuivre'])){
$_SESSION['form']->title = $titre;
$_SESSION['form']->admin_name = $nom;
$_SESSION['form']->admin_mail = $adresse;
$_SESSION['form']->description = $commentaires;
$_SESSION['form']->title = $title;
$_SESSION['form']->admin_name = $name;
$_SESSION['form']->admin_mail = $address;
$_SESSION['form']->description = $description;
$_SESSION['form']->editable = ($editable !== null) ? true : false;
$_SESSION['form']->receiveNewVotes = ($receiveNewVotes !== null) ? true : false;
$_SESSION['form']->receiveNewComments = ($receiveNewComments !== null) ? true : false;
if ($config['use_smtp']==true){
if (Utils::isValidEmail($adresse) === false) {
if (Utils::isValidEmail($address) === false) {
$erreur_adresse = true;
}
}
if (preg_match(';<|>|";',$titre)) {
if (preg_match(';<|>|";',$title)) {
$erreur_injection_titre = true;
}
if (preg_match(';<|>|";',$nom)) {
if (preg_match(';<|>|";',$name)) {
$erreur_injection_nom = true;
}
if (preg_match(';<|>|";',$commentaires)) {
if (preg_match(';<|>|";',$description)) {
$erreur_injection_commentaires = true;
}
// Si pas d'erreur dans l'adresse alors on change de page vers date ou autre
if($config['use_smtp'] == true){
$email_OK = $adresse && !$erreur_adresse;
$email_OK = $address && !$erreur_adresse;
} else{
$email_OK = true;
}
if ($titre && $nom && $email_OK && ! $erreur_injection_titre && ! $erreur_injection_commentaires && ! $erreur_injection_nom) {
if ($title && $name && $email_OK && ! $erreur_injection_titre && ! $erreur_injection_commentaires && ! $erreur_injection_nom) {
if ( $poursuivre == "creation_sondage_date" ) {
header("Location:choix_date.php");
if ( $poursuivre == 'creation_sondage_date' ) {
header('Location:choix_date.php');
exit();
}
if ( $poursuivre == "creation_sondage_autre" ) {
header("Location:choix_autre.php");
if ( $poursuivre == 'creation_sondage_autre' ) {
header('Location:choix_autre.php');
exit();
}
} else {
// Title Erreur !
Utils::print_header( _("Error!").' - '._("Poll creation (1 on 3)") );
Utils::print_header( _('Error!').' - '._('Poll creation (1 on 3)') );
}
} else {
// Title OK (formulaire pas encore rempli)
Utils::print_header( _("Poll creation (1 on 3)") );
Utils::print_header( _('Poll creation (1 on 3)') );
}
bandeau_titre( _("Poll creation (1 on 3)") );
bandeau_titre( _('Poll creation (1 on 3)') );
/*
* Préparation des messages d'erreur
......@@ -141,32 +143,39 @@ $errors = array(
);
if (!$_SESSION['form']->title && !empty($_POST['poursuivre'])) {
$errors['title']['aria'] = 'aria-describeby="poll_title_error" '; $errors['title']['class'] = ' has-error';
$errors['title']['msg'] = '<div class="alert alert-danger" ><p id="poll_title_error">' . _("Enter a title") . '</p></div>';
$errors['title']['aria'] = 'aria-describeby="poll_title_error" ';
$errors['title']['class'] = ' has-error';
$errors['title']['msg'] = '<div class="alert alert-danger" ><p id="poll_title_error">' . _('Enter a title') . '</p></div>';
} elseif ($erreur_injection_titre) {
$errors['title']['aria'] = 'aria-describeby="poll_title_error" '; $errors['title']['class'] = ' has-error';
$errors['title']['inject'] = '<div class="alert alert-danger"><p id="poll_title_error">' . _("Characters < > and \" are not permitted") . '</p></div>';
$errors['title']['aria'] = 'aria-describeby="poll_title_error" ';
$errors['title']['class'] = ' has-error';
$errors['title']['inject'] = '<div class="alert alert-danger"><p id="poll_title_error">' . _('Characters < > and " are not permitted') . '</p></div>';
}
if ($erreur_injection_commentaires) {
$errors['description']['aria'] = 'aria-describeby="poll_comment_error" '; $errors['description']['class'] = ' has-error';
$errors['description']['msg'] = '<div class="alert alert-danger"><p id="poll_comment_error">' . _("Characters < > and \" are not permitted") . '</p></div>';
$errors['description']['aria'] = 'aria-describeby="poll_comment_error" ';
$errors['description']['class'] = ' has-error';
$errors['description']['msg'] = '<div class="alert alert-danger"><p id="poll_comment_error">' . _('Characters < > and " are not permitted') . '</p></div>';
}
if (!$_SESSION['form']->admin_name && !empty($_POST['poursuivre'])) {
$errors['name']['aria'] = 'aria-describeby="poll_name_error" '; $errors['name']['class'] = ' has-error';
$errors['name']['msg'] = '<div class="alert alert-danger"><p id="poll_name_error">' . _("Enter a name") . '</p></div>';
$errors['name']['aria'] = 'aria-describeby="poll_name_error" ';
$errors['name']['class'] = ' has-error';
$errors['name']['msg'] = '<div class="alert alert-danger"><p id="poll_name_error">' . _('Enter a name') . '</p></div>';
} elseif ($erreur_injection_nom) {
$errors['name']['aria'] = 'aria-describeby="poll_name_error" '; $errors['name']['class'] = ' has-error';
$errors['name']['msg'] = '<div class="alert alert-danger"><p id="poll_name_error">' . _("Characters < > and \" are not permitted") . '</p></div>';
$errors['name']['aria'] = 'aria-describeby="poll_name_error" ';
$errors['name']['class'] = ' has-error';
$errors['name']['msg'] = '<div class="alert alert-danger"><p id="poll_name_error">' . _('Characters < > and " are not permitted') . '</p></div>';
}
if (!$_SESSION['form']->admin_mail && !empty($_POST['poursuivre'])) {
$errors['email']['aria'] = 'aria-describeby="poll_name_error" '; $errors['email']['class'] = ' has-error';
$errors['email']['msg'] = '<div class="alert alert-danger"><p id="poll_email_error">' . _("Enter an email address") . '</p></div>';
$errors['email']['aria'] = 'aria-describeby="poll_name_error" ';
$errors['email']['class'] = ' has-error';
$errors['email']['msg'] = '<div class="alert alert-danger"><p id="poll_email_error">' . _('Enter an email address') . '</p></div>';
} elseif ($erreur_adresse && !empty($_POST['poursuivre'])) {
$errors['email']['aria'] = 'aria-describeby="poll_email_error" '; $errors['email']['class'] = ' has-error';
$errors['email']['msg'] = '<div class="alert alert-danger"><p id="poll_email_error">' . _("The address is not correct! You should enter a valid email address (like r.stallman@outlock.com) in order to receive the link to your poll.") . '</p></div>';
$errors['email']['aria'] = 'aria-describeby="poll_email_error" ';
$errors['email']['class'] = ' has-error';
$errors['email']['msg'] = '<div class="alert alert-danger"><p id="poll_email_error">' . _('The address is not correct! You should enter a valid email address (like r.stallman@outlock.com) in order to receive the link to your poll.') . '</p></div>';
}
/*
......@@ -175,9 +184,9 @@ if (!$_SESSION['form']->admin_mail && !empty($_POST['poursuivre'])) {
// REMOTE_USER ?
if (USE_REMOTE_USER && isset($_SERVER['REMOTE_USER'])) {
$input_name = '<input type="hidden" name="nom" value="'.$_SESSION['form']->admin_name.'" />'.stripslashes($_SESSION['form']->admin_name);
$input_name = '<input type="hidden" name="name" value="'.$_SESSION['form']->admin_name.'" />'.$_SESSION['form']->admin_name;
} else {
$input_name = '<input id="yourname" type="text" name="nom" class="form-control" '.$errors['name']['aria'].' value="'.stripslashes($_SESSION['form']->admin_name).'" />';
$input_name = '<input id="yourname" type="text" name="name" class="form-control" '.$errors['name']['aria'].' value="'.$_SESSION['form']->admin_name.'" />';
}
if (USE_REMOTE_USER && isset($_SERVER['REMOTE_USER'])) {
......@@ -195,6 +204,10 @@ if ($_SESSION['form']->receiveNewVotes) {
$receiveNewVotes = 'checked';
}
if ($_SESSION['form']->receiveNewComments) {
$receiveNewComments = 'checked';
}
// Display form
echo '
<div class="row">
......@@ -202,25 +215,25 @@ echo '
<form name="formulaire" id="formulaire" action="' . Utils::get_server_name() . 'infos_sondage.php" method="POST" class="form-horizontal" role="form">
<div class="alert alert-info">
<p>'. _("You are in the poll creation section.").' <br /> '._("Required fields cannot be left blank.") .'</p>
<p>'. _('You are in the poll creation section.').' <br /> '._('Required fields cannot be left blank.') .'</p>
</div>
<div class="form-group'.$errors['title']['class'].'">
<label for="poll_title" class="col-sm-4 control-label">' . _("Poll title") . ' *</label>
<label for="poll_title" class="col-sm-4 control-label">' . _('Poll title') . ' *</label>
<div class="col-sm-8">
<input id="poll_title" type="text" name="titre" class="form-control" '.$errors['title']['aria'].' value="'.stripslashes($_SESSION['form']->title).'" />
<input id="poll_title" type="text" name="titre" class="form-control" '.$errors['title']['aria'].' value="'.$_SESSION['form']->title.'" />
</div>
</div>
'.$errors['title']['msg'].'
<div class="form-group'.$errors['description']['class'].'">
<label for="poll_comments" class="col-sm-4 control-label">'. _("Description") .'</label>
<label for="poll_comments" class="col-sm-4 control-label">'. _('Description') .'</label>
<div class="col-sm-8">
<textarea id="poll_comments" name="commentaires" class="form-control" '.$errors['description']['aria'].' rows="5">'.stripslashes($_SESSION['form']->description).'</textarea>
<textarea id="poll_comments" name="commentaires" class="form-control" '.$errors['description']['aria'].' rows="5">'.$_SESSION['form']->description.'</textarea>
</div>
</div>
'.$errors['description']['msg'].'
<div class="form-group'.$errors['name']['class'].'">
<label for="yourname" class="col-sm-4 control-label">'. _("Your name") .' *</label>
<label for="yourname" class="col-sm-4 control-label">'. _('Your name') .' *</label>
<div class="col-sm-8">
'.$input_name.'
</div>
......@@ -229,7 +242,7 @@ echo '
if($config['use_smtp']==true){
echo '
<div class="form-group'.$errors['email']['class'].'">
<label for="email" class="col-sm-4 control-label">'. _("Your email address") .' *<br /><span class="small">'. _("(in the format name@mail.com)") .'</span></label>
<label for="email" class="col-sm-4 control-label">'. _('Your email address') .' *<br /><span class="small">'. _('(in the format name@mail.com)') .'</span></label>
<div class="col-sm-8">
'.$input_email.'
</div>
......@@ -238,20 +251,29 @@ if($config['use_smtp']==true){
}
echo '
<div class="form-group">
<div class="col-sm-offset-1 col-sm-11">
<div class="col-sm-offset-4 col-sm-8">
<div class="checkbox">
<label>
<input type=checkbox name="editable" '.$editable.' id="editable">'. _("Voters can modify their vote themselves.") .'
<input type=checkbox name="editable" '.$editable.' id="editable">'. _('Voters can modify their vote themselves.') .'
</label>
</div>
</div>
</div>';
if($config['use_smtp']==true){
echo '<div class="form-group">
<div class="col-sm-offset-1 col-sm-11">
<div class="col-sm-offset-4 col-sm-8">
<div class="checkbox">
<label>
<input type=checkbox name="receiveNewVotes" '.$receiveNewVotes.' id="receiveNewVotes">'. _('To receive an email for each new vote.') .'
</label>
</div>
</div>
</div>';
echo '<div class="form-group">
<div class="col-sm-offset-4 col-sm-8">
<div class="checkbox">
<label>
<input type=checkbox name="receiveNewVotes" '.$receiveNewVotes.' id="receiveNewVotes">'. _("To receive an email for each new vote.") .'
<input type=checkbox name="receiveNewComments" '.$receiveNewComments.' id="receiveNewComments">'. _('To receive an email for each new comment.') .'
</label>
</div>
</div>
......@@ -263,7 +285,7 @@ echo '
<button name="poursuivre" value="'. $choix_sondage .'" type="submit" class="btn btn-success" title="'. _('Go to step 2') . '">'. _('Next') . '</button>
</p>
<script type="text/javascript"> document.formulaire.titre.focus(); </script>
<script type="text/javascript">document.formulaire.title.focus();</script>
</form>
</div>
......
......@@ -616,10 +616,24 @@ msgid "Poll's participation"
msgstr "Beteiligung an der Umfrage"
msgid ""
"has filled a line.\n"
"filled a vote.\n"
"You can find your poll at the link"
msgstr ""
" hat eine Zeile ausgefüllt.\n"
"hat eine Zeile ausgefüllt.\n"
"Sie finden Ihre Umfrage unter dem folgenden Link:"
msgid ""
"updated a vote.\n"
"You can find your poll at the link"
msgstr ""
"updated a vote.\n"
"Sie finden Ihre Umfrage unter dem folgenden Link:"
msgid ""
"wrote a comment.\n"
"You can find your poll at the link"
msgstr ""
"wrote a comment.\n"
"Sie finden Ihre Umfrage unter dem folgenden Link:"
msgid "Thanks for your confidence."
......
......@@ -670,10 +670,24 @@ msgid "Poll's participation"
msgstr "Poll's participation"
msgid ""
"has filled a line.\n"
"filled a vote.\n"
"You can find your poll at the link"
msgstr ""
"has filled a line.\n"
"filled a vote.\n"
"You can find your poll at the link"
msgid ""
"updated a vote.\n"
"You can find your poll at the link"
msgstr ""
"updated a vote.\n"
"You can find your poll at the link"
msgid ""
"wrote a comment.\n"
"You can find your poll at the link"
msgstr ""
"wrote a comment.\n"
"You can find your poll at the link"
msgid "Thanks for your confidence."
......
......@@ -393,12 +393,26 @@ msgstr "Participaci&oacute;n a la encuesta"
#: studs.php:171
#: studs.php:211
msgid ""
"has filled a line.\n"
"filled a vote.\n"
"You can find your poll at the link"
msgstr ""
"acaba de llenar una l&iacute;nea.\n"
"Usted puede retroceder a su encuesta con el enlace siguiente"
msgid ""
"updated a vote.\n"
"You can find your poll at the link"
msgstr ""
"updated a vote.\n"
"Usted puede retroceder a su encuesta con el enlace siguiente"
msgid ""
"wrote a comment.\n"
"You can find your poll at the link"
msgstr ""
"wrote a comment.\n"
"Usted puede retroceder a su encuesta con el enlace siguiente"
#: studs.php:246
#: adminstuds.php:567
msgid "Initiator of the poll"
......
......@@ -670,10 +670,24 @@ msgid "Poll's participation"
msgstr "Participation au sondage"
msgid ""
"has filled a line.\n"
"filled a vote.\n"
"You can find your poll at the link"
msgstr ""
"vient de remplir une ligne.\n"
"vient de voter.\n"
"Vous pouvez retrouver votre sondage avec le lien suivant"
msgid ""
"updated a vote.\n"
"You can find your poll at the link"
msgstr ""
"vient de mettre à jour un vote.\n"
"Vous pouvez retrouver votre sondage avec le lien suivant"
msgid ""
"vient de rédiger un commentaire.\n"
"You can find your poll at the link"
msgstr ""
"wrote a comment.\n"
"Vous pouvez retrouver votre sondage avec le lien suivant"
msgid "Thanks for your confidence."
......
......@@ -25,6 +25,12 @@ use Framadate\Utils;
include_once __DIR__ . '/app/inc/init.php';
/* Constants */
/* --------- */
const UPDATE_VOTE = 1;
const ADD_VOTE = 2;
const ADD_COMMENT = 3;
/* Variables */
/* --------- */
......@@ -49,19 +55,36 @@ $mailService = new MailService($config['use_smtp']);
*
* @param $poll stdClass The poll
* @param $mailService MailService The mail service
* @param $name string The name user who triggered the notification
* @param $type int cf: Constants on the top of this page
*/
function sendUpdateNotification($poll, $mailService) {
if ($poll->receiveNewVotes && !isset($_SESSION['mail_sent'][$poll->id])) {
function sendUpdateNotification($poll, $mailService, $name, $type) {
if (!isset($_SESSION['mail_sent'])) {
$_SESSION['mail_sent'] = [];
}
if ($poll->receiveNewVotes && (!isset($_SESSION['mail_sent'][$poll->id]) || $_SESSION['mail_sent'][$poll->id] !== true)) {
$subject = '[' . NOMAPPLICATION . '] ' . _('Poll\'s participation') . ' : ' . $poll->title;
$message = html_entity_decode('"$nom" ', ENT_QUOTES, 'UTF-8') .
_('has filled a line.\nYou can find your poll at the link') . " :\n\n" .
Utils::getUrlSondage($poll->admin_poll_id, true) . " \n\n" .
_('Thanks for your confidence.') . "\n" . NOMAPPLICATION;
$message = $name . ' ';
switch ($type) {
case UPDATE_VOTE:
$message .= _('updated a vote.\nYou can find your poll at the link') . " :\n\n";
break;
case ADD_VOTE:
$message .= _('filled a vote.\nYou can find your poll at the link') . " :\n\n";
break;
case ADD_COMMENT:
$message .= _('wrote a comment.\nYou can find your poll at the link') . " :\n\n";
break;
}
$message .= Utils::getUrlSondage($poll->admin_id, true) . "\n\n";
$message .= _('Thanks for your confidence.') . "\n" . NOMAPPLICATION;
$mailService->send($poll->admin_mail, $subject, $message);
$_SESSION["mail_sent"][$poll->id] = true;
$_SESSION['mail_sent'][$poll->id] = true;
}
}
......@@ -108,7 +131,7 @@ if (!empty($_POST['save'])) { // Save edition of an old vote
$result = $pollService->updateVote($poll_id, $editedVote, $name, $choices);
if ($result) {
$message = new Message('success', _('Update vote successfully.'));
sendUpdateNotification($poll, $mailService);
sendUpdateNotification($poll, $mailService, $name, UPDATE_VOTE);
} else {
$message = new Message('danger', _('Update vote failed.'));
}
......@@ -129,7 +152,7 @@ if (!empty($_POST['save'])) { // Save edition of an old vote
$result = $pollService->addVote($poll_id, $name, $choices);
if ($result) {
$message = new Message('success', _('Update vote successfully.'));
sendUpdateNotification($poll, $mailService);
sendUpdateNotification($poll, $mailService, $name, ADD_VOTE);
} else {
$message = new Message('danger', _('Update vote failed.'));
}
......@@ -153,6 +176,7 @@ if (isset($_POST['add_comment'])) {
$result = $pollService->addComment($poll_id, $name, $comment);
if ($result) {
$message = new Message('success', _('Comment added.'));
sendUpdateNotification($poll, $mailService, $name, ADD_COMMENT);
} else {
$message = new Message('danger', _('Comment failed.'));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment