diff --git a/adminstuds.php b/adminstuds.php
index 5d7e2d6..bb450be 100644
--- a/adminstuds.php
+++ b/adminstuds.php
@@ -16,15 +16,22 @@
* 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\PollService;
+use Framadate\Editable;
+use Framadate\Message;
use Framadate\Services\AdminPollService;
use Framadate\Services\InputService;
use Framadate\Services\LogService;
-use Framadate\Message;
-use Framadate\Editable;
+use Framadate\Services\MailService;
+use Framadate\Services\PollService;
+use Framadate\Utils;
include_once __DIR__ . '/app/inc/init.php';
+/* Constants */
+/* --------- */
+const UPDATE_POLL = 1;
+const DELETED_POLL = 2;
+
/* Variables */
/* --------- */
@@ -41,6 +48,41 @@ $logService = new LogService();
$pollService = new PollService($connect, $logService);
$adminPollService = new AdminPollService($connect, $pollService, $logService);
$inputService = new InputService();
+$mailService = new MailService($config['use_smtp']);
+
+/* Functions */
+/*-----------*/
+
+/**
+ * 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 . '] ' . __('Mail', 'Notification of poll') . ' : ' . $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);
+ }
+}
/* PAGE */
/* ---- */
@@ -133,6 +175,7 @@ if (isset($_POST['update_poll_info'])) {
// Update poll in database
if ($updated && $adminPollService->updatePoll($poll)) {
$message = new Message('success', __('adminstuds', 'Poll saved'));
+ sendUpdateNotification($poll, $mailService, UPDATE_POLL);
} else {
$message = new Message('danger', __('Error', 'Failed to save poll'));
$poll = $pollService->findById($poll_id);
@@ -297,6 +340,7 @@ if (isset($_POST['delete_poll'])) {
if (isset($_POST['confirm_delete_poll'])) {
if ($adminPollService->deleteEntirePoll($poll_id)) {
$message = new Message('success', __('adminstuds', 'Poll fully deleted'));
+ sendUpdateNotification($poll, $mailService, DELETED_POLL);
} else {
$message = new Message('danger', __('Error', 'Failed to delete the poll'));
}
diff --git a/locale/de.json b/locale/de.json
index c033119..597e553 100644
--- a/locale/de.json
+++ b/locale/de.json
@@ -189,7 +189,6 @@
"Remove the comments": "Entfernen Sie die Kommentare",
"Comment deleted": "Kommentar gelöscht",
"All comments deleted": "Alle Kommentare gelöscht",
- "The poll has been deleted": "Die Umfrage wurde gelöscht",
"Keep votes": "Halten Stimmen",
"Keep comments": "Halten Sie Kommentare",
"Keep this poll": "Halten Sie diese Umfrage"
@@ -289,9 +288,12 @@
},
"Mail": {
"Poll's participation": "Beteiligung an der Umfrage",
+ "Notification of poll": "Mitteilung bezüglich der Umfrage",
"filled a vote.\nYou can find your poll at the link": "füllte eine Stimme.
Sie 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.
Sie 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",
+ "Someone just change your poll available at the following link %s.": "Jemand ändern Sie einfach Ihre Umfrage finden Sie unter dem folgenden Link %1$s.",
+ "Someone just delete your poll %s.": "Jemand hat gerade Ihre Umfrage löschen \"%s\".",
"Thanks for your trust.": "Danke für Ihr Vertrauen.",
"FOOTER": "",
"[ADMINISTRATOR] New settings for your poll": "[ADMINISTRATOR] Neue Einstellungen für Ihre Umfrage ",
diff --git a/locale/en.json b/locale/en.json
index d63249c..58441e5 100644
--- a/locale/en.json
+++ b/locale/en.json
@@ -189,7 +189,6 @@
"All comments deleted": "All comments deleted",
"Keep the comments": "Keep the comments",
"Remove the comments": "Remove the comments",
- "The poll has been deleted": "The poll has been deleted",
"Keep votes": "Keep votes",
"Keep comments": "Keep comments",
"Keep this poll": "Keep this poll"
@@ -289,9 +288,12 @@
},
"Mail" : {
"Poll's participation": "Poll's participation",
+ "Notification of poll": "Notification of poll",
"filled a vote.\nYou can find your poll at the link": "filled a vote.
You can find your poll at the link",
"updated a vote.\nYou can find your poll at the link": "updated a vote.
You can find your poll at the link",
"wrote a comment.\nYou can find your poll at the link": "wrote a comment.
You can find your poll at the link",
+ "Someone just change your poll available at the following link %s.": "Someone just change your poll available at the following link %1$s.",
+ "Someone just delete your poll %s.": "Someone just delete your poll \"%s\".",
"Thanks for your trust.": "Thanks for your trust.",
"FOOTER": "",
"[ADMINISTRATOR] New settings for your poll": "[ADMINISTRATOR] New settings for your poll",
diff --git a/locale/es.json b/locale/es.json
index 032e51f..ed52eca 100644
--- a/locale/es.json
+++ b/locale/es.json
@@ -189,7 +189,6 @@
"Remove the comments": "ES_Supprimer les commentaires",
"Comment deleted": "ES_Commentaire supprimé",
"All comments deleted": "ES_Tous les commentaires ont été supprimés",
- "The poll has been deleted": "ES_Le sondage a été supprimé",
"Keep votes": "ES_Garder les votes",
"Keep comments": "ES_Garder les commentaires",
"Keep this poll": "Dejar este encuesta!"
@@ -288,10 +287,13 @@
"Polls sent": "ES_Sondages envoyés"
},
"Mail": {
- "Poll's participation": "ES_Participation au sondage",
+ "Poll's participation": "Participación Encuesta",
+ "Notification of poll": "Notificación de la encuesta",
"filled a vote.\nYou can find your poll at the link": "ES_vient de voter.
Vous 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.
Vous 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.
Vous pouvez retrouver votre sondage avec le lien suivant",
+ "Someone just change your poll available at the following link %s.": "Alguien acaba de cambiar su encuesta disponible en el siguiente enlace %1$s.",
+ "Someone just delete your poll %s.": "Alguien acaba de borrar tu encuesta \"%s\".",
"Thanks for your trust.": "ES_Merci de votre confiance.",
"FOOTER": "",
"[ADMINISTRATOR] New settings for your poll": "ES_[ADMINISTRATEUR] Changement de configuration du sondage",
@@ -306,8 +308,8 @@
"Error": {
"Error!": "Error!",
"Enter a title": "Introducza un título",
- "Something is going wrong...": "ES_Quelque chose ne va pas...",
- "Something is wrong with the format": "Something is wrong with the format",
+ "Something is going wrong...": "Algo va mal...",
+ "Something is wrong with the format": "Algo está mal con el formato",
"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é",
diff --git a/locale/fr.json b/locale/fr.json
index 368772c..32026b8 100644
--- a/locale/fr.json
+++ b/locale/fr.json
@@ -189,7 +189,6 @@
"Remove the comments": "Supprimer les commentaires",
"Comment deleted": "Commentaire supprimé",
"All comments deleted": "Tous les commentaires ont été supprimés",
- "The poll has been deleted": "Le sondage a été supprimé",
"Keep votes": "Garder les votes",
"Keep comments": "Garder les commentaires",
"Keep this poll": "Garder ce sondage"
@@ -289,9 +288,12 @@
},
"Mail": {
"Poll's participation": "Participation au sondage",
+ "Notification of poll": "Notification d'un sondage",
"filled a vote.\nYou can find your poll at the link": "vient de voter.
Vous 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.
Vous 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.
Vous pouvez retrouver votre sondage avec le lien suivant",
+ "Someone just change your poll available at the following link %s.": "Quelqu'un vient de modifier votre sondage accessible au lien suivant %1$s.",
+ "Someone just delete your poll %s.": "Quelqu'un vient de supprimer votre sondage \"%s\".",
"Thanks for your trust.": "Merci de votre confiance.",
"FOOTER": "« La route est longue, mais la voie est libre… »
Framasoft ne vit que par vos dons (déductibles des impôts).
Merci d'avance pour votre soutien http://soutenir.framasoft.org.",
"[ADMINISTRATOR] New settings for your poll": "[ADMINISTRATEUR] Changement de configuration du sondage",
diff --git a/locale/it.json b/locale/it.json
index fb12303..0d90324 100644
--- a/locale/it.json
+++ b/locale/it.json
@@ -189,7 +189,6 @@
"Remove the comments": "Eliminare i commenti",
"Comment deleted": "Commento rimosso",
"All comments deleted": "Tutti i commenti sono stati cancellati",
- "The poll has been deleted": "Il sondaggio è stato eliminato",
"Keep votes": "Tenere voti",
"Keep comments": "Tenere commenti",
"Keep this poll": "Mantengo questo sondaggio !"
@@ -289,9 +288,12 @@
},
"Mail": {
"Poll's participation": "Partecipazione al sondaggio",
+ "Notification of poll": "Notifica di sondaggio",
"filled a vote.\nYou can find your poll at the link": "IT_vient de voter.\nVous pouvez retrouver votre sondage avec le lien suivant",
"updated a vote.\nYou can find your poll at the link": "IT_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": "IT_vient de rédiger un commentaire.\nVous pouvez retrouver votre sondage avec le lien suivant",
+ "Someone just change your poll available at the following link %s.": "Qualcuno basta cambiare il vostro sondaggio disponibile al seguente link %1$s.",
+ "Someone just delete your poll %s.": "Qualcuno ha appena cancellare il tuo sondaggio \"%s\".",
"Thanks for your trust.": "Grazie per la vostra fiducia.",
"FOOTER": "IT_« 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.",
"[ADMINISTRATOR] New settings for your poll": "[AMMINISTRATORE] Modifica di configurazione del sondaggio",
diff --git a/tpl/poll_deleted.tpl b/tpl/poll_deleted.tpl
index 79174ec..0c7bd62 100644
--- a/tpl/poll_deleted.tpl
+++ b/tpl/poll_deleted.tpl
@@ -2,7 +2,7 @@
{block name=main}
{__('Generic', 'Back to the homepage of')} {$APPLICATION_NAME|html}