diff --git a/admin/migration.php b/admin/migration.php index 07ffb2e22eca20d512b66a84c0f1fe80606ccbbd..cade588b9442a91d0477274263d18d05eb1df074 100644 --- a/admin/migration.php +++ b/admin/migration.php @@ -1,6 +1,7 @@ <?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=?'); diff --git a/app/classes/Framadate/Form.php b/app/classes/Framadate/Form.php index c002997747fd08e6cb38a503e49b7010cf705004..76a4a4dfeea2103190bb09d4d2c054e311de3ef7 100644 --- a/app/classes/Framadate/Form.php +++ b/app/classes/Framadate/Form.php @@ -39,6 +39,11 @@ class Form */ public $receiveNewVotes; + /** + * If true, notify poll administrator when new comment is posted. + */ + public $receiveNewComments; + /** * List of available choices */ diff --git a/app/classes/Framadate/Migration/From_0_0_to_0_8_Migration.php b/app/classes/Framadate/Migration/From_0_0_to_0_8_Migration.php index dbdb59eb0a39595e5434836287dd25412a03b6d1..013c6ddb57aef593fcc161a71d08684f82e5d9ea 100644 --- a/app/classes/Framadate/Migration/From_0_0_to_0_8_Migration.php +++ b/app/classes/Framadate/Migration/From_0_0_to_0_8_Migration.php @@ -75,4 +75,3 @@ CREATE TABLE IF NOT EXISTS `user_studs` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;'); } } - \ No newline at end of file diff --git a/app/classes/Framadate/Migration/From_0_8_to_0_9_Migration.php b/app/classes/Framadate/Migration/From_0_8_to_0_9_Migration.php index ea69991f4c62289e85f39ee3c7fecbc7253cf2e5..e6aab47426a2fd21edb28aa1bb90949807eb053a 100644 --- a/app/classes/Framadate/Migration/From_0_8_to_0_9_Migration.php +++ b/app/classes/Framadate/Migration/From_0_8_to_0_9_Migration.php @@ -207,4 +207,3 @@ INSERT INTO `' . Utils::table('vote') . '` } } - \ No newline at end of file diff --git a/app/classes/Framadate/Migration/From_0_9_to_0_9_1_Migration.php b/app/classes/Framadate/Migration/From_0_9_to_0_9_1_Migration.php new file mode 100644 index 0000000000000000000000000000000000000000..19c9a25566fcdd6e862eae28009a49e8b36158e6 --- /dev/null +++ b/app/classes/Framadate/Migration/From_0_9_to_0_9_1_Migration.php @@ -0,0 +1,51 @@ +<?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`'); + } + +} diff --git a/app/classes/Framadate/Services/PollService.php b/app/classes/Framadate/Services/PollService.php index 5193081ed794235a8b7f6c12f29f452ebb878d18..cf32713124b0b7dbac744343fbe0d6e0d38e6f3c 100644 --- a/app/classes/Framadate/Services/PollService.php +++ b/app/classes/Framadate/Services/PollService.php @@ -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 (?, ?, ?)'); diff --git a/app/inc/constants.php.template b/app/inc/constants.php.template index 21fd6d657df70d49717855a575f39565dbd15ccf..7d733cde73150a4193480d460063424688893322 100644 --- a/app/inc/constants.php.template +++ b/app/inc/constants.php.template @@ -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>'; diff --git a/infos_sondage.php b/infos_sondage.php index b98ccd3b8525e5f69b03e30c6d29675b3b62a97c..77a9343d2a031f56bf70c91596a0b7ccf6844494 100644 --- a/infos_sondage.php +++ b/infos_sondage.php @@ -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> diff --git a/locale/de_DE/LC_MESSAGES/Studs.mo b/locale/de_DE/LC_MESSAGES/Studs.mo index 1fae2345c1667109f2872927c3b1ccbffd98b39a..6a28a3381a354bb71fbb13c0f4564970b96c6304 100644 Binary files a/locale/de_DE/LC_MESSAGES/Studs.mo and b/locale/de_DE/LC_MESSAGES/Studs.mo differ diff --git a/locale/de_DE/LC_MESSAGES/Studs.po b/locale/de_DE/LC_MESSAGES/Studs.po index 68fb4da7ab5c23e3b69b541a4c0da83c4c3c4119..b07ca2750400e50a47bc32459393e3367e93dcaf 100644 --- a/locale/de_DE/LC_MESSAGES/Studs.po +++ b/locale/de_DE/LC_MESSAGES/Studs.po @@ -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." diff --git a/locale/en_GB/LC_MESSAGES/Studs.mo b/locale/en_GB/LC_MESSAGES/Studs.mo index 1586cb4a772491b97cc925a6cee57ce55cceabd1..5c291f84e9b447c0d8eef1762a2d77299774868d 100644 Binary files a/locale/en_GB/LC_MESSAGES/Studs.mo and b/locale/en_GB/LC_MESSAGES/Studs.mo differ diff --git a/locale/en_GB/LC_MESSAGES/Studs.po b/locale/en_GB/LC_MESSAGES/Studs.po index 042f7a5ae78f673757a5cbc4be7db5250fc3d98e..77c129004e967ff59da8f3ce97ffa9e915fae8c4 100644 --- a/locale/en_GB/LC_MESSAGES/Studs.po +++ b/locale/en_GB/LC_MESSAGES/Studs.po @@ -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." diff --git a/locale/es_ES/LC_MESSAGES/Studs.mo b/locale/es_ES/LC_MESSAGES/Studs.mo index 2339be802a393b6fa9b554c12934e075f5e5ade8..e87839f6f74f461eed02d4b46e54d951ddf4640a 100644 Binary files a/locale/es_ES/LC_MESSAGES/Studs.mo and b/locale/es_ES/LC_MESSAGES/Studs.mo differ diff --git a/locale/es_ES/LC_MESSAGES/Studs.po b/locale/es_ES/LC_MESSAGES/Studs.po index 28f5fd2f1c9639d0d9c2eaf56d7a69e03929cda8..c55477173c958016d18c618cdfd05bfa92646a51 100644 --- a/locale/es_ES/LC_MESSAGES/Studs.po +++ b/locale/es_ES/LC_MESSAGES/Studs.po @@ -393,12 +393,26 @@ msgstr "Participació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í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" diff --git a/locale/fr_FR/LC_MESSAGES/Studs.mo b/locale/fr_FR/LC_MESSAGES/Studs.mo index f3c7d063376b25d0656018a8819ca8818169e5cf..d93851fc1fc52afe555a580d907699086206b099 100644 Binary files a/locale/fr_FR/LC_MESSAGES/Studs.mo and b/locale/fr_FR/LC_MESSAGES/Studs.mo differ diff --git a/locale/fr_FR/LC_MESSAGES/Studs.po b/locale/fr_FR/LC_MESSAGES/Studs.po index 551705dafc632d1535d166b3516070122eba360d..09100a6e648d0fbb054273079414c1eaa1ce0b98 100644 --- a/locale/fr_FR/LC_MESSAGES/Studs.po +++ b/locale/fr_FR/LC_MESSAGES/Studs.po @@ -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." diff --git a/studs.php b/studs.php index 09bddab76650504845be1525bce5aaa33e56de24..76f36224748010f297499930d5c27508dba2d1f4 100644 --- a/studs.php +++ b/studs.php @@ -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.')); }