Add page where the users can ask to receive their polls by mail

This commit is contained in:
Olivier PEREZ 2015-04-08 21:52:09 +02:00
parent 8b3eaac717
commit 77234edc82
13 changed files with 172 additions and 19 deletions

View File

@ -90,6 +90,19 @@ SELECT p.*,
return $prepared->fetchAll();
}
/**
* Find all polls that are created with the given admin mail.
*
* @param string $mail Email address of the poll admin
* @return array The list of matching polls
*/
public function findAllByAdminMail($mail) {
$prepared = $this->prepare('SELECT * FROM `' . Utils::table('poll') . '` WHERE admin_mail = :admin_mail');
$prepared->execute(array('admin_mail' => $mail));
return $prepared->fetchAll();
}
/**
* Get the total number of polls in databse.
*

View File

@ -34,12 +34,12 @@ class MailService {
$headers = $from;
$headers .= 'Reply-To: ' . ADRESSEMAILREPONSEAUTO . "\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/plain; charset=UTF-8\n";
$headers .= "Content-Type: text/html; charset=UTF-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "Auto-Submitted:auto-generated\n";
$headers .= 'Return-Path: <>';
$body = html_entity_decode($body, ENT_QUOTES, 'UTF-8') . __('Mail', "\n--\n\n« La route est longue, mais la voie est libre… »\nFramasoft ne vit que par vos dons (déductibles des impôts).\nMerci d'avance pour votre soutien http://soutenir.framasoft.org.");
$body = html_entity_decode($body, ENT_QUOTES, 'UTF-8') . __('Mail', 'FOOTER');
mail($to, $subject, $body, $headers, $param);
}

View File

@ -112,6 +112,10 @@ class PollService {
return array($poll_id, $admin_poll_id);
}
public function findAllByAdminMail($mail) {
return $this->pollRepository->findAllByAdminMail($mail);
}
function computeBestChoices($votes) {
$result = [];
foreach ($votes as $vote) {

View File

@ -42,7 +42,7 @@ const MIGRATION_TABLE = 'framadate_migration';
const TABLENAME_PREFIX = 'fd_';
// Default Language using POSIX variant of BC P47 standard (choose in $ALLOWED_LANGUAGES)
const DEFAULT_LANGUAGE = 'fr_FR';
const DEFAULT_LANGUAGE = 'fr';
// List of supported languages, fake constant as arrays can be used as constants only in PHP >=5.6
$ALLOWED_LANGUAGES = [

58
find_polls.php Normal file
View File

@ -0,0 +1,58 @@
<?php
/**
* This software is governed by the CeCILL-B license. If a copy of this license
* is not distributed with this file, you can obtain one at
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
*
* Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
* Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft)
*
* =============================
*
* Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence
* 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\PollService;
include_once __DIR__ . '/app/inc/init.php';
/* SERVICES */
/* -------- */
$logService = '\Framadate\Services\LogService';
$pollService = new PollService($connect, new $logService());
$mailService = new \Framadate\Services\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);
$message = new Message('success', __('FindPolls', 'Polls sent'));
} else {
$message = new Message('warning', __('Error', 'No polls found'));
}
} else {
$message = new Message('danger', __('Error', 'Something is wrong with the format'));
}
}
$smarty->assign('title', __('Homepage', 'Where are my polls'));
$smarty->assign('message', $message);
$smarty->display('find_polls.tpl');

BIN
images/question.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@ -35,7 +35,8 @@
"seconds": "Sekunden",
"Choice": "Wahl",
"Link": "Link",
"Search": "Suche"
"Search": "Suche",
"Creation date:": "Erstellungsdatum:"
},
"Date": {
"dd/mm/yyyy": "jj/mm/aaaa",
@ -52,7 +53,8 @@
},
"Homepage": {
"Schedule an event": "Termin finden",
"Make a classic poll": "Klassische Umfrage"
"Make a classic poll": "Klassische Umfrage",
"Where are my polls": "Wo sind meine Umfragen"
},
"Maintenance": {
"The application": "die Anwendung",
@ -116,12 +118,12 @@
"Votes and comments are locked": "Abstimmungen und Kommentare sind gesperrt",
"Votes and comments are open": "Abstimmungen und Kommentare sind möglich",
"Votes are editable": "Die Abstimmungen können geändert werden",
"Votes are editable solely by their owner.": "DE_Les votes sont modifiables uniquement par leur créateur",
"Votes are editable solely by their owner.": "Stimmen sind nur editierbar von ihrem Eigentümer",
"Save the new rules": "Neue Regeln speichern",
"Cancel the rules edit": "Neue Regeln nicht speichern",
"The name is invalid.": "Der Name ist ungültig.",
"Results are hidden.": "DE_Les résultats sont cachés.",
"Results are visible.": "DE_Les résultats sont visibles."
"Results are hidden.": "Ergebnisse werden ausgeblendet.",
"Results are visible.": "Ergebnisse sind sichtbar."
},
"Poll results": {
"Votes of the poll": "Abstimmungen der Umfrage ",
@ -279,13 +281,18 @@
"polls in the database at this time": "Umfragen derzeit in der Datenbank",
"Purge the polls": "TRANSLATE_ Purge the polls"
},
"FindPolls": {
"Here are your polls": "Hier sind Ihre Umfragen",
"Send me my polls": "Senden Sie mir mein Umfragen",
"Polls sent": "Umfragen geschickt"
},
"Mail": {
"Poll's participation": "Beteiligung an der Umfrage",
"filled a vote.\nYou can find your poll at the link": "füllte eine Stimme.\nSie können Ihre Umfrage unter dem Link zu finden",
"updated a vote.\nYou can find your poll at the link": "eine Abstimmung regelmäßig aktualisiert.\nSie können Ihre Umfrage unter dem Link zu finden",
"wrote a comment.\nYou can find your poll at the link": "hat einen Kommentar. Sie können Ihre Umfrage unter dem Link zu finden",
"Thanks for your confidence.": "Danke für Ihr Vertrauen.",
"\n--\n\n« La route est longue, mais la voie est libre… »\nFramasoft ne vit que par vos dons (déductibles des impôts).\nMerci d'avance pour votre soutien http://soutenir.framasoft.org.": "",
"FOOTER": "",
"[ADMINISTRATOR] New settings for your poll": "[ADMINISTRATOR] Neue Einstellungen für Ihre Umfrage ",
"You have changed the settings of your poll. \nYou can modify this poll with this link": "Sie haben die Einstellungen Ihrer Umfrage verändert.\nSie können diese Umfrage mit diesem Link ändern",
"This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll.": "Dies ist die Botschaft, die Sie zu den Menschen, die Sie abfragen möchten senden.\nNun haben Sie diese Nachricht an alle, die Sie abfragen möchten senden.",
@ -302,6 +309,7 @@
"Something is wrong with the format": "Something is wrong with the format",
"Enter an email address": "Sie müssen eine E-Mail-Adresse eingeben",
"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.": "Die Adresse ist nicht korrekt! Sie sollten eine funktionierende E-Mail-Adresse angeben, um den Link zu ihrer Umfrage zu erhalten",
"No polls found": "Keine Umfragen gefunden",
"There is a problem with your choices": "Es gibt ein Problem mit der Auswahl",
"You haven't filled the first section of the poll creation.": "Sie haben den ersten Teil der Umfrageerstellung nicht ausgefüllt.",
"Javascript is disabled on your browser. Its activation is required to create a poll.": "Javascript ist in Ihrem Browser deaktiviert. Seine Aktivierung ist erforderlich, um eine Umfrage zu erstellen.",
@ -317,6 +325,6 @@
"Update vote failed": "Update vote failed",
"Adding vote failed": "Adding vote failed",
"Comment failed": "Kommentar gescheitert",
"You can't create a poll with hidden results with the following edition option:": "DE_Vous ne pouvez pas créer de sondage avec résulats cachés avec les options d'éditions suivantes : "
"You can't create a poll with hidden results with the following edition option:": "Sie können nicht eine Umfrage erstellen mit versteckten Ergebnisse mit der folgenden Ausgabe-Option:"
}
}

View File

@ -35,7 +35,8 @@
"seconds": "seconds",
"Choice": "Choice",
"Link": "Link",
"Search": "Search"
"Search": "Search",
"Creation date:": "Creation date:"
},
"Date" : {
"dd/mm/yyyy": "jj/mm/aaaa",
@ -48,7 +49,8 @@
},
"Language selector": {
"Select the language": "Select the language",
"Change the language": "Change the language"
"Change the language": "Change the language",
"Where are my polls": "Where are my polls"
},
"Maintenance": {
"The application": "The application",
@ -279,13 +281,18 @@
"polls in the database at this time": "polls in the database at this time",
"Purge the polls": "Purge the polls"
},
"FindPolls": {
"Here are your polls": "Here are your polls",
"Send me my polls": "Send me my polls",
"Polls sent": "Polls sent"
},
"Mail" : {
"Poll's participation": "Poll's participation",
"filled a vote.\nYou can find your poll at the link": "filled a vote.\nYou can find your poll at the link",
"updated a vote.\nYou can find your poll at the link": "updated a vote.\nYou can find your poll at the link",
"wrote a comment.\nYou can find your poll at the link": "wrote a comment.\nYou can find your poll at the link",
"Thanks for your confidence.": "Thanks for your confidence.",
"\n--\n\n« La route est longue, mais la voie est libre… »\nFramasoft ne vit que par vos dons (déductibles des impôts).\nMerci d'avance pour votre soutien http://soutenir.framasoft.org.": "\n\n\n\n",
"FOOTER": "",
"[ADMINISTRATOR] New settings for your poll": "[ADMINISTRATOR] New settings for your poll",
"You have changed the settings of your poll. \nYou can modify this poll with this link": "You have changed the settings of your poll. \nYou can modify this poll with this link",
"This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll.":"This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll.",
@ -302,6 +309,7 @@
"Something is wrong with the format": "Something is wrong with the format",
"Enter an email address": "Enter an email address",
"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.": "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.",
"No polls found": "No polls found",
"There is a problem with your choices": "There is a problem with your choices",
"You haven't filled the first section of the poll creation.": "You haven't filled the first section of the poll creation.",
"Javascript is disabled on your browser. Its activation is required to create a poll.": "Javascript is disabled on your browser. Its activation is required to create a poll.",

View File

@ -35,7 +35,8 @@
"seconds": "ES_secondes",
"Choice": "Opciòn",
"Link": "ES_Lien",
"Search": "Búsqueda"
"Search": "Búsqueda",
"Creation date:": "ES_Date de création :"
},
"Date": {
"dd/mm/yyyy": "ES_jj/mm/aaaa",
@ -52,7 +53,8 @@
},
"Homepage": {
"Schedule an event": "Encuesta para planificar un evento",
"Make a classic poll": "ES_Créer un sondage classique"
"Make a classic poll": "ES_Créer un sondage classique",
"Where are my polls": "ES_Où sont mes sondages"
},
"Maintenance": {
"The application": "ES_L'application",
@ -279,13 +281,18 @@
"polls in the database at this time": "encuestas en la basa por el momento",
"Purge the polls": "ES_Purger les sondages"
},
"FindPolls": {
"Here are your polls": "ES_Voici tes sondages",
"Send me my polls": "ES_Envoyer mes sondages",
"Polls sent": "ES_Sondages envoyés"
},
"Mail": {
"Poll's participation": "ES_Participation au sondage",
"filled a vote.\nYou can find your poll at the link": "ES_vient de voter.\nVous pouvez retrouver votre sondage avec le lien suivant",
"updated a vote.\nYou can find your poll at the link": "ES_vient de mettre à jour un vote.\nVous pouvez retrouver votre sondage avec le lien suivant",
"wrote a comment.\nYou can find your poll at the link": "ES_vient de rédiger un commentaire.\nVous pouvez retrouver votre sondage avec le lien suivant",
"Thanks for your confidence.": "ES_Merci de votre confiance.",
"\n--\n\n« La route est longue, mais la voie est libre… »\nFramasoft ne vit que par vos dons (déductibles des impôts).\nMerci d'avance pour votre soutien http://soutenir.framasoft.org.": "ES_\n--\n\n« La route est longue, mais la voie est libre… »\nFramasoft ne vit que par vos dons (déductibles des impôts).\nMerci d'avance pour votre soutien http://soutenir.framasoft.org.",
"FOOTER": "",
"[ADMINISTRATOR] New settings for your poll": "ES_[ADMINISTRATEUR] Changement de configuration du sondage",
"You have changed the settings of your poll. \nYou can modify this poll with this link": "ES_Vous avez modifié la configuration de votre sondage. \nVous pouvez modifier ce sondage avec le lien suivant",
"This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll.": "ES_Ceci est le message qui doit être envoyé aux sondés. \nVous pouvez maintenant transmettre ce message à toutes les personnes susceptibles de participer au vote.",
@ -302,6 +309,7 @@
"Something is wrong with the format": "Something is wrong with the format",
"Enter an email address": "Introduzca una dirección electrónica",
"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.": "ES_L'adresse saisie n'est pas correcte ! Il faut une adresse électronique valide (par exemple r.stallman@outlock.com) pour recevoir le lien vers le sondage.",
"No polls found": "ES_Aucun sondage n'a été trouvé",
"There is a problem with your choices": "ES_Il y a un problème avec vos choix",
"You haven't filled the first section of the poll creation.": "Usted no habia llenado la primera pagina dela encuesta",
"Javascript is disabled on your browser. Its activation is required to create a poll.": "ES_Javascript est désactivé sur votre navigateur. Son activation est requise pour la création d'un sondage.",

View File

@ -35,7 +35,8 @@
"seconds": "secondes",
"Choice": "Choix",
"Link": "Lien",
"Search": "Chercher"
"Search": "Chercher",
"Creation date:": "Date de création :"
},
"Date": {
"dd/mm/yyyy": "jj/mm/aaaa",
@ -52,7 +53,8 @@
},
"Homepage": {
"Schedule an event": "Créer un sondage spécial dates",
"Make a classic poll": "Créer un sondage classique"
"Make a classic poll": "Créer un sondage classique",
"Where are my polls": "Où sont mes sondages"
},
"Maintenance": {
"The application": "L'application",
@ -279,13 +281,18 @@
"polls in the database at this time": "sondages dans la base actuellement",
"Purge the polls": "Purger les sondages"
},
"FindPolls": {
"Here are your polls": "Voici tes sondages",
"Send me my polls": "Envoyer mes sondages",
"Polls sent": "Sondages envoyés"
},
"Mail": {
"Poll's participation": "Participation au sondage",
"filled a vote.\nYou can find your poll at the link": "vient de voter.\nVous pouvez retrouver votre sondage avec le lien suivant",
"updated a vote.\nYou can find your poll at the link": "vient de mettre à jour un vote.\nVous pouvez retrouver votre sondage avec le lien suivant",
"wrote a comment.\nYou can find your poll at the link": "vient de rédiger un commentaire.\nVous pouvez retrouver votre sondage avec le lien suivant",
"Thanks for your confidence.": "Merci de votre confiance.",
"\n--\n\n« La route est longue, mais la voie est libre… »\nFramasoft ne vit que par vos dons (déductibles des impôts).\nMerci d'avance pour votre soutien http://soutenir.framasoft.org.": "\n--\n\n« La route est longue, mais la voie est libre… »\nFramasoft ne vit que par vos dons (déductibles des impôts).\nMerci d'avance pour votre soutien http://soutenir.framasoft.org.",
"FOOTER": "<hr/><br/>« La route est longue, mais la voie est libre… »<br/>Framasoft ne vit que par vos dons (déductibles des impôts).<br/>Merci d'avance pour votre soutien http://soutenir.framasoft.org.",
"[ADMINISTRATOR] New settings for your poll": "[ADMINISTRATEUR] Changement de configuration du sondage",
"You have changed the settings of your poll. \nYou can modify this poll with this link": "Vous avez modifié la configuration de votre sondage. \nVous pouvez modifier ce sondage avec le lien suivant",
"This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll.": "Ceci est le message qui doit être envoyé aux sondés. \nVous pouvez maintenant transmettre ce message à toutes les personnes susceptibles de participer au vote.",
@ -302,6 +309,7 @@
"Something is wrong with the format": "Quelque chose ne va pas avec le format",
"Enter an email address": "Il faut saisir une adresse électronique !",
"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.": "L'adresse saisie n'est pas correcte ! Il faut une adresse électronique valide (par exemple r.stallman@outlock.com) pour recevoir le lien vers le sondage.",
"No polls found": "Aucun sondage n'a été trouvé",
"There is a problem with your choices": "Il y a un problème avec vos choix",
"You haven't filled the first section of the poll creation.": "Vous n'avez pas renseigné la première page du sondage",
"Javascript is disabled on your browser. Its activation is required to create a poll.": "Javascript est désactivé sur votre navigateur. Son activation est requise pour la création d'un sondage.",

25
tpl/find_polls.tpl Normal file
View File

@ -0,0 +1,25 @@
{extends file='page.tpl'}
{block name=main}
{if !empty($message)}
<div class="alert alert-dismissible alert-{$message->type|html}" role="alert">{$message->message|html}{if $message->link != null}<br/><a href="{$message->link}">{$message->link}</a>{/if}<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>
{/if}
<form action="" method="post">
<div class="row">
<div class="col-md-6 col-md-offset-3 text-center">
<div class="form-group">
<div class="input-group">
<label for="mail" class="input-group-addon">{__('Generic', 'Your email address')}</label>
<input type="email" class="form-control" id="mail" name="mail" autofocus>
</div>
</div>
</div>
<div class="col-md-6 col-md-offset-3 text-center">
<button type="submit" class="btn btn-warning btn-lg">
<span class="glyphicon glyphicon-search"></span>
{__('FindPolls', 'Send me my polls')}
</button>
</div>
</div>
</form>
{/block}

View File

@ -26,6 +26,18 @@
</a>
</p>
</div>
<div class="col-md-6 col-md-offset-3 text-center">
<p class="home-choice">
<a href="{$SERVER_URL}find_polls.php" class="opacity" role="button">
<img alt="" class="img-responsive center-block" src="{'images/question.png'|resource}"/>
<br/>
<span class="btn btn-warning btn-lg">
<span class="glyphicon glyphicon-search"></span>
{__('Homepage', 'Where are my polls')}
</span>
</a>
</p>
</div>
</div>
<hr role="presentation"/>
<div class="row">

9
tpl/mail/find_polls.tpl Normal file
View File

@ -0,0 +1,9 @@
<h1>{__('FindPolls', 'Here are your polls')}</h1>
<ul>
{foreach $polls as $poll}
<li>
<a href="{poll_url id=$poll->admin_id admin=true}">{$poll->title|html}</a>
({__('Generic', 'Creation date:')} {$poll->creation_date|date_format:$date_format['txt_full']})
</li>
{/foreach}
</ul>