From 33797cb4a9041705b56a7806410e69a535cbdb21 Mon Sep 17 00:00:00 2001 From: Olivier Perez Date: Fri, 24 Apr 2015 14:03:11 +0200 Subject: [PATCH 01/32] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0281d56..09ef086 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - Amélioration : Mise à jour des fichiers .md pour faciliter la collaboration - Amélioration : Le nom de l'auteur et la date d'expiration sont modifiables - Amélioration : Le nom de vote est modifiable + - Amélioration : Affichage du comptage des "Si nécessaire" entre parenthèses - Fix : Purge en 2 étapes → 1. Verrouillage du sondage → 2. 60 jours plus tard suppression du sondage - Fix : Date d'expiration qui devient nulle quand on ajoute une colonne - Fix : clic/focus sur oui/non/si nécessaire → retour à gauche de la barre de scroll sur Chromium From f21892dc26b0c62bff94d5bc51116886b85db830 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Sun, 24 May 2015 23:40:57 +0200 Subject: [PATCH 02/32] Put i18n on aria-label --- tpl/admin/purge.tpl | 2 +- tpl/find_polls.tpl | 2 +- tpl/studs.tpl | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tpl/admin/purge.tpl b/tpl/admin/purge.tpl index 3033c08..2b2d6a2 100644 --- a/tpl/admin/purge.tpl +++ b/tpl/admin/purge.tpl @@ -2,7 +2,7 @@ {block 'admin_main'} {if $message} - + {/if}
diff --git a/tpl/find_polls.tpl b/tpl/find_polls.tpl index 33c1b53..418f50b 100644 --- a/tpl/find_polls.tpl +++ b/tpl/find_polls.tpl @@ -2,7 +2,7 @@ {block name=main} {if !empty($message)} - + {/if}
diff --git a/tpl/studs.tpl b/tpl/studs.tpl index 4a9828f..39d39b4 100644 --- a/tpl/studs.tpl +++ b/tpl/studs.tpl @@ -9,10 +9,10 @@
{if !empty($message)} - + {/if}
- + {* Global informations about the current poll *} From 67d05161613f054bb658642fa354d0a89733d68e Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Sun, 24 May 2015 23:43:44 +0200 Subject: [PATCH 03/32] Remove icon on 'Send me my polls' button + Make it btn-success --- tpl/find_polls.tpl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tpl/find_polls.tpl b/tpl/find_polls.tpl index 418f50b..351c149 100644 --- a/tpl/find_polls.tpl +++ b/tpl/find_polls.tpl @@ -15,10 +15,7 @@
- +
From 4392dde5dc2c89f9bd86694d75f2427be385831a Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Sun, 24 May 2015 23:51:54 +0200 Subject: [PATCH 04/32] Display datepicker when click in field --- js/app/framadatepicker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/app/framadatepicker.js b/js/app/framadatepicker.js index 20ebca0..c09a30b 100644 --- a/js/app/framadatepicker.js +++ b/js/app/framadatepicker.js @@ -47,7 +47,7 @@ $(document).ready(function () { }); }; - $(document).on('click', '.input-group.date .input-group-addon', function () { + $(document).on('click', '.input-group.date .input-group-addon, .input-group.date input', function () { // Re-init datepicker config before displaying init_datepicker(); $(this).parent().datepicker('show'); From 4aee1d71e4f6743e6ea0074847ddd5f61c0e49ed Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Mon, 25 May 2015 00:02:20 +0200 Subject: [PATCH 05/32] Fix: Display framanav when present --- tpl/page.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tpl/page.tpl b/tpl/page.tpl index 3bc2d29..c3922c5 100644 --- a/tpl/page.tpl +++ b/tpl/page.tpl @@ -20,7 +20,7 @@ - {if !empty($nav_js)} + {if $use_nav_js} {/if} From 35da81a4cd95464dc53d4344a7e797ebb3ff1120 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 11:28:04 +0200 Subject: [PATCH 06/32] Remove "." at the end of options --- locale/de.json | 10 +++++----- locale/en.json | 10 +++++----- locale/es.json | 10 +++++----- locale/fr.json | 10 +++++----- locale/it.json | 10 +++++----- tpl/create_poll.tpl | 12 ++++++------ 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/locale/de.json b/locale/de.json index 40a12cb..c033119 100644 --- a/locale/de.json +++ b/locale/de.json @@ -200,11 +200,11 @@ "Required fields cannot be left blank.": "Mit * markierte Felder müssen ausgefüllt sein.", "Poll title": "Umfragetitel", "Votes cannot be modified.": "DE_Aucun vote ne peut être modifié", - "All voters can modify any vote.": "DE_Tous les sondés peuvent modifier tous les votes", - "Voters can modify their vote themselves.": "Teilnehmer können ihre Antworten verändern", - "To receive an email for each new vote.": "Bei jeder neuen Abstimmung eine E-Mail erhalten.", - "To receive an email for each new comment.": "Um eine E-Mail für jede neue Kommentar zu empfangen.", - "Only the poll maker can see the poll's results.": "DE_Seul le créateur du sondage peut voir les résultats.", + "All voters can modify any vote": "DE_Tous les sondés peuvent modifier tous les votes", + "Voters can modify their vote themselves": "Teilnehmer können ihre Antworten verändern", + "To receive an email for each new vote": "Bei jeder neuen Abstimmung eine E-Mail erhalten", + "To receive an email for each new comment": "Um eine E-Mail für jede neue Kommentar zu empfangen", + "Only the poll maker can see the poll's results": "DE_Seul le créateur du sondage peut voir les résultats", "Go to step 2": "Weiter zum 2. Schritt" }, "Step 2": { diff --git a/locale/en.json b/locale/en.json index 8847640..d63249c 100644 --- a/locale/en.json +++ b/locale/en.json @@ -200,11 +200,11 @@ "Required fields cannot be left blank.": "Required fields cannot be left blank.", "Poll title": "Poll title", "Votes cannot be modified.": "Votes cannot be modified", - "All voters can modify any vote.": "All voters can modify any vote.", - "Voters can modify their vote themselves.": "Voters can modify their vote themselves.", - "To receive an email for each new vote.": "To receive an email for each new vote.", - "To receive an email for each new comment.": "To receive an email for each new comment.", - "Only the poll maker can see the poll's results.": "Only the poll maker can see the poll's results.", + "All voters can modify any vote": "All voters can modify any vote", + "Voters can modify their vote themselves": "Voters can modify their vote themselves", + "To receive an email for each new vote": "To receive an email for each new vote", + "To receive an email for each new comment": "To receive an email for each new comment", + "Only the poll maker can see the poll's results": "Only the poll maker can see the poll's results", "Go to step 2": "Go to step 2" }, "Step 2": { diff --git a/locale/es.json b/locale/es.json index 89e5942..aca6b2e 100644 --- a/locale/es.json +++ b/locale/es.json @@ -200,11 +200,11 @@ "Required fields cannot be left blank.": "Gracias por completar los campos con una *.", "Poll title": "ES_Titre du sondage", "Votes cannot be modified.": "ES_Aucun vote ne peut être modifié", - "All voters can modify any vote.": "ES_Tous les sondés peuvent modifier tous les votes", - "Voters can modify their vote themselves.": "Los encuentados pueden cambiar su línea ellos mismos.", - "To receive an email for each new vote.": "Usted quiere recibir un correo electónico cada vez que alguien participe a la encuesta.", - "To receive an email for each new comment.": "ES_Recevoir un courriel à chaque commentaire.", - "Only the poll maker can see the poll's results.": "ES_Seul le créateur du sondage peut voir les résultats.", + "All voters can modify any vote": "ES_Tous les sondés peuvent modifier tous les votes", + "Voters can modify their vote themselves": "Los encuentados pueden cambiar su línea ellos mismos", + "To receive an email for each new vote": "Usted quiere recibir un correo electónico cada vez que alguien participe a la encuesta", + "To receive an email for each new comment": "ES_Recevoir un courriel à chaque commentaire", + "Only the poll maker can see the poll's results": "ES_Seul le créateur du sondage peut voir les résultats", "Go to step 2": "ES_Aller à l'étape 2" }, "Step 2": { diff --git a/locale/fr.json b/locale/fr.json index 11417ec..18509ec 100644 --- a/locale/fr.json +++ b/locale/fr.json @@ -200,11 +200,11 @@ "Required fields cannot be left blank.": "Merci de remplir les champs obligatoires, marqués d'une *.", "Poll title": "Titre du sondage", "Votes cannot be modified.": "Aucun vote ne peut être modifié", - "All voters can modify any vote.": "Tous les sondés peuvent modifier tous les votes", - "Voters can modify their vote themselves.": "Chaque sondé peut modifier son propre vote.", - "To receive an email for each new vote.": "Recevoir un courriel à chaque participation d'un sondé.", - "To receive an email for each new comment.": "Recevoir un courriel à chaque commentaire.", - "Only the poll maker can see the poll's results.": "Seul le créateur du sondage peut voir les résultats.", + "All voters can modify any vote": "Tous les sondés peuvent modifier tous les votes", + "Voters can modify their vote themselves": "Chaque sondé peut modifier son propre vote", + "To receive an email for each new vote": "Recevoir un courriel à chaque participation d'un sondé", + "To receive an email for each new comment": "Recevoir un courriel à chaque commentaire", + "Only the poll maker can see the poll's results": "Seul le créateur du sondage peut voir les résultats", "Go to step 2": "Aller à l'étape 2" }, "Step 2": { diff --git a/locale/it.json b/locale/it.json index fa3d0d6..8d4b49b 100644 --- a/locale/it.json +++ b/locale/it.json @@ -200,11 +200,11 @@ "Required fields cannot be left blank.": "Riempire i campi obbligatori, segnati con *.", "Poll title": "Titolo del sondaggio", "Votes cannot be modified.": "No voto non può essere modificato", - "All voters can modify any vote.": "Tutti i sondaggi possono cambiare tutti i voti", - "Voters can modify their vote themselves.": "I partecipanti possono modificare il loro voto in autonomia.", - "To receive an email for each new vote.": "Per ricevere un'email per ogni voto nuovo", - "To receive an email for each new comment.": "Ricevi una e-mail ogni commento.", - "Only the poll maker can see the poll's results.": "Solo il creatore sondaggio possono vedere i risultati.", + "All voters can modify any vote": "Tutti i sondaggi possono cambiare tutti i voti", + "Voters can modify their vote themselves": "I partecipanti possono modificare il loro voto in autonomia", + "To receive an email for each new vote": "Per ricevere un'email per ogni voto nuovo", + "To receive an email for each new comment": "Ricevi una e-mail ogni commento", + "Only the poll maker can see the poll's results": "Solo il creatore sondaggio possono vedere i risultati", "Go to step 2": "Andare al punto 2" }, "Step 2": { diff --git a/tpl/create_poll.tpl b/tpl/create_poll.tpl index 2aad0bf..c064dbf 100644 --- a/tpl/create_poll.tpl +++ b/tpl/create_poll.tpl @@ -102,11 +102,11 @@ @@ -120,7 +120,7 @@ @@ -131,7 +131,7 @@ @@ -142,12 +142,12 @@ From 6fbbd848fbe04590bff8091db811ac36ea6d10c1 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 11:37:49 +0200 Subject: [PATCH 07/32] Typo on 'lien vers lapage d'administration du sondage' --- locale/es.json | 2 +- locale/fr.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/es.json b/locale/es.json index aca6b2e..96fd0bd 100644 --- a/locale/es.json +++ b/locale/es.json @@ -244,7 +244,7 @@ "Confirm the creation of your poll": "ES_Confirmez la création de votre sondage", "List of your choices": "ES_Liste de vos choix", "Once you have confirmed the creation of your poll, you will be automatically redirected on the administration page of your poll.": "ES_Une fois que vous aurez confirmé la création du sondage, vous serez redirigé automatiquement vers la page d'administration de votre sondage.", - "Then, you will receive quickly two emails: one contening the link of your poll for sending it to the voters, the other contening the link to the administration page of your poll.": "ES_En même temps, vous recevrez deux courriels : l'un contenant le lien vers votre sondage pour le faire suivre aux futurs sondés, l'autre contenant le lien vers la page d'administraion du sondage.", + "Then, you will receive quickly two emails: one contening the link of your poll for sending it to the voters, the other contening the link to the administration page of your poll.": "ES_En même temps, vous recevrez deux courriels : l'un contenant le lien vers votre sondage pour le faire suivre aux futurs sondés, l'autre contenant le lien vers la page d'administration du sondage.", "Create the poll": "Crear la encuesta", "Your poll will automatically be archived": "ES_Votre sondage sera automatiquement archivé", "after the last date of your poll.": "ES_après la date la plus tardive.", diff --git a/locale/fr.json b/locale/fr.json index 18509ec..f9a87bd 100644 --- a/locale/fr.json +++ b/locale/fr.json @@ -244,7 +244,7 @@ "Confirm the creation of your poll": "Confirmez la création de votre sondage", "List of your choices": "Liste de vos choix", "Once you have confirmed the creation of your poll, you will be automatically redirected on the administration page of your poll.": "Une fois que vous aurez confirmé la création du sondage, vous serez redirigé automatiquement vers la page d'administration de votre sondage.", - "Then, you will receive quickly two emails: one contening the link of your poll for sending it to the voters, the other contening the link to the administration page of your poll.": "En même temps, vous recevrez deux courriels : l'un contenant le lien vers votre sondage pour le faire suivre aux futurs sondés, l'autre contenant le lien vers la page d'administraion du sondage.", + "Then, you will receive quickly two emails: one contening the link of your poll for sending it to the voters, the other contening the link to the administration page of your poll.": "En même temps, vous recevrez deux courriels : l'un contenant le lien vers votre sondage pour le faire suivre aux futurs sondés, l'autre contenant le lien vers la page d'administration du sondage.", "Create the poll": "Créer le sondage", "Your poll will automatically be archived": "Votre sondage sera automatiquement archivé", "after the last date of your poll.": "après la date la plus tardive.", From 60069b11511575574af7cbc11dca33ecd1d95228 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 11:48:47 +0200 Subject: [PATCH 08/32] Add hidden-print class on some alerts block --- tpl/studs.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tpl/studs.tpl b/tpl/studs.tpl index 39d39b4..c136c0c 100644 --- a/tpl/studs.tpl +++ b/tpl/studs.tpl @@ -9,10 +9,10 @@
{if !empty($message)} - + {/if}
- + {* Global informations about the current poll *} From d5cf1aa5a7fef5a6258f8be02a38589345b0eb11 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 12:00:56 +0200 Subject: [PATCH 09/32] Add hidden-print class on vote line and actions column --- tpl/part/vote_table_classic.tpl | 131 ++++++++++++++++---------------- tpl/part/vote_table_date.tpl | 131 ++++++++++++++++---------------- 2 files changed, 133 insertions(+), 129 deletions(-) diff --git a/tpl/part/vote_table_classic.tpl b/tpl/part/vote_table_classic.tpl index cfa005c..a66e141 100644 --- a/tpl/part/vote_table_classic.tpl +++ b/tpl/part/vote_table_classic.tpl @@ -38,85 +38,86 @@ {foreach $votes as $vote} - - {* Edited line *} - {if $editingVoteId === $vote->uniqId} - -
- - - -
+ {if $editingVoteId === $vote->uniqId} {* Edited line *} + + + +
+ + + +
+ + + {foreach $vote->choices as $id=>$choice} + + +
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
+ {/foreach} + + + {elseif !$hidden} {* Voted line *} + - {foreach $vote->choices as $id=>$choice} + {$vote->name|html} - -
    -
  • - - -
  • -
  • - - -
  • -
  • - - -
  • -
- - {/foreach} - - {elseif !$hidden} - {* Voted line *} + {foreach $vote->choices as $id=>$choice} - {$vote->name|html} - - {foreach $vote->choices as $id=>$choice} - - {if $choice==2} - {__('Generic', 'Yes')} - {elseif $choice==1} - (){__('Generic', 'Ifneedbe')} - {else} - {__('Generic', 'No')} - {/if} - - {/foreach} - - {if $active && !$expired && ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL') or $admin)} - - - {__('Generic', 'Edit')} - - {if $admin} - - {__('Generic', 'Remove')} - - {/if} - + {if $choice==2} + {__('Generic', 'Yes')} + {elseif $choice==1} + (){__('Generic', 'Ifneedbe')} {else} - + {__('Generic', 'No')} {/if} + + {/foreach} + + {if $active && !$expired && ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL') or $admin)} + + + {__('Generic', 'Edit')} + + {if $admin} + + {__('Generic', 'Remove')} + + {/if} + + {else} + {/if} + {/if} {/foreach} {* Line to add a new vote *} {if $active && $editingVoteId === 0 && !$expired} - +
diff --git a/tpl/part/vote_table_date.tpl b/tpl/part/vote_table_date.tpl index 8fdb74c..5d21aed 100644 --- a/tpl/part/vote_table_date.tpl +++ b/tpl/part/vote_table_date.tpl @@ -86,86 +86,89 @@ {foreach $votes as $vote} - - {* Edited line *} + {* Edited line *} - {if $editingVoteId === $vote->uniqId && !$expired} - -
- - - -
+ {if $editingVoteId === $vote->uniqId && !$expired} + + +
+ + + +
+ + + {foreach $vote->choices as $k=>$choice} + + +
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
+ {/foreach} + - {foreach $vote->choices as $k=>$choice} + + {elseif !$hidden} + - -
    -
  • - - -
  • -
  • - - -
  • -
  • - - -
  • -
- - {/foreach} - - {elseif !$hidden} + {* Voted line *} - {* Voted line *} + {$vote->name|html} - {$vote->name|html} + {foreach $vote->choices as $k=>$choice} - {foreach $vote->choices as $k=>$choice} - - {if $choice==2} - {__('Generic', 'Yes')} - {elseif $choice==1} - (){__('Generic', 'Ifneedbe')} - {else} - {__('Generic', 'No')} - {/if} - - {/foreach} - - {if $active && !$expired && ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL') or $admin)} - - - {__('Generic', 'Edit')} - - {if $admin} - - {__('Generic', 'Remove')} - - {/if} - + {if $choice==2} + {__('Generic', 'Yes')} + {elseif $choice==1} + (){__('Generic', 'Ifneedbe')} {else} - + {__('Generic', 'No')} {/if} + + {/foreach} + + {if $active && !$expired && ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL') or $admin)} + + + {__('Generic', 'Edit')} + + {if $admin} + + {__('Generic', 'Remove')} + + {/if} + + {else} + {/if} + {/if} {/foreach} {* Line to add a new vote *} {if $active && $editingVoteId === 0 && !$expired} - +
From ccf9109133bbd1e126e2755b5149d2743feb0416 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 12:28:02 +0200 Subject: [PATCH 10/32] Typo on 'Echec de la sauvegarde du sondage' --- locale/es.json | 2 +- locale/fr.json | 2 +- locale/it.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/es.json b/locale/es.json index 96fd0bd..032e51f 100644 --- a/locale/es.json +++ b/locale/es.json @@ -322,7 +322,7 @@ "Enter a name and a comment!": "Introduzca su nombre y un comentario!", "Failed to insert the comment!": "ES_Échec à l'insertion du commentaire !", "Framadate is not properly installed, please check the \"INSTALL\" to setup the database before continuing.": "ES_Framadate n'est pas installé correctement, lisez le fichier INSTALL pour configurer la base de données avant de continuer.", - "Failed to save poll": "ES_Echèc de la sauvegarde du sondage", + "Failed to save poll": "ES_Echec de la sauvegarde du sondage", "Update vote failed": "ES_Mise à jour du vote échoué", "Adding vote failed": "ES_Ajout d'un vote échoué", "Comment failed": "ES_Commentaire échoué", diff --git a/locale/fr.json b/locale/fr.json index f9a87bd..368772c 100644 --- a/locale/fr.json +++ b/locale/fr.json @@ -322,7 +322,7 @@ "Enter a name and a comment!": "Merci de remplir les deux champs !", "Failed to insert the comment!": "Échec à l'insertion du commentaire !", "Framadate is not properly installed, please check the \"INSTALL\" to setup the database before continuing.": "Framadate n'est pas installé correctement, lisez le fichier INSTALL pour configurer la base de données avant de continuer.", - "Failed to save poll": "Echèc de la sauvegarde du sondage", + "Failed to save poll": "Echec de la sauvegarde du sondage", "Update vote failed": "Mise à jour du vote échoué", "Adding vote failed": "Ajout d'un vote échoué", "Comment failed": "Commentaire échoué", diff --git a/locale/it.json b/locale/it.json index 8d4b49b..fb12303 100644 --- a/locale/it.json +++ b/locale/it.json @@ -322,7 +322,7 @@ "Enter a name and a comment!": "Inserire un nome e un commento!", "Failed to insert the comment!": "Errore nell'inserimento del commento !", "Framadate is not properly installed, please check the \"INSTALL\" to setup the database before continuing.": "IT_Framadate n'est pas installé correctement, lisez le fichier INSTALL pour configurer la base de données avant de continuer.", - "Failed to save poll": "IT_Echèc de la sauvegarde du sondage", + "Failed to save poll": "IT_Echec de la sauvegarde du sondage", "Update vote failed": "IT_Mise à jour du vote échoué", "Adding vote failed": "IT_Ajout d'un vote échoué", "Comment failed": "IT_Commentaire échoué", From 430cb511b635e9fb7450cd80e9d3ef444069f044 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 12:34:54 +0200 Subject: [PATCH 11/32] Fix label for 'name' in comments form --- tpl/part/comments.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tpl/part/comments.tpl b/tpl/part/comments.tpl index a2c2f5e..660041e 100644 --- a/tpl/part/comments.tpl +++ b/tpl/part/comments.tpl @@ -22,8 +22,8 @@
{__('Comments', 'Add a comment to the poll')}
- - + +
From 4cacb412c68f3033d0fb58f6c44eea437a7183c4 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 16:06:50 +0200 Subject: [PATCH 12/32] Admin : Change colors on purge button --- tpl/admin/purge.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tpl/admin/purge.tpl b/tpl/admin/purge.tpl index 2b2d6a2..ad13913 100644 --- a/tpl/admin/purge.tpl +++ b/tpl/admin/purge.tpl @@ -2,12 +2,12 @@ {block 'admin_main'} {if $message} - + {/if}
- +
{/block} From 92d84f31935d6016c10ecefa2f6ad8334d66c965 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 17:05:26 +0200 Subject: [PATCH 13/32] Install PHPUnit for UnitTesting --- app/tests/Framadate/FramaTestCase.php | 23 + .../Services/MailServiceUnitTest.php | 15 + app/tests/bootstrap.php | 3 + composer.json | 4 + composer.lock | 972 +++++++++++++++++- phpunit.bat | 1 + phpunit.sh | 1 + 7 files changed, 1012 insertions(+), 7 deletions(-) create mode 100644 app/tests/Framadate/FramaTestCase.php create mode 100644 app/tests/Framadate/Services/MailServiceUnitTest.php create mode 100644 app/tests/bootstrap.php create mode 100644 phpunit.bat create mode 100644 phpunit.sh diff --git a/app/tests/Framadate/FramaTestCase.php b/app/tests/Framadate/FramaTestCase.php new file mode 100644 index 0000000..b2f6e14 --- /dev/null +++ b/app/tests/Framadate/FramaTestCase.php @@ -0,0 +1,23 @@ +getTestResourcePath($resourcepath)); + } + + protected function invoke(&$object, $methodName) { + $reflectionClass = new \ReflectionClass($object); + $reflectionMethod = $reflectionClass->getMethod($methodName); + $reflectionMethod->setAccessible(true); + + $params = array_slice(func_get_args(), 2); // get all the parameters after $methodName + return $reflectionMethod->invokeArgs($object, $params); + } + +} diff --git a/app/tests/Framadate/Services/MailServiceUnitTest.php b/app/tests/Framadate/Services/MailServiceUnitTest.php new file mode 100644 index 0000000..70e99c6 --- /dev/null +++ b/app/tests/Framadate/Services/MailServiceUnitTest.php @@ -0,0 +1,15 @@ +assertEquals('a', 'a'); + } + +} diff --git a/app/tests/bootstrap.php b/app/tests/bootstrap.php new file mode 100644 index 0000000..9d4b65e --- /dev/null +++ b/app/tests/bootstrap.php @@ -0,0 +1,3 @@ +addPsr4('Framadate\\', __DIR__.'/Framadate'); diff --git a/composer.json b/composer.json index 620b1c0..c8f208e 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,10 @@ "o80/i18n": "dev-develop" }, + "require-dev": { + "phpunit/phpunit": "^4.5" + }, + "autoload": { "psr-4": { "Framadate\\": "app/classes/Framadate/" diff --git a/composer.lock b/composer.lock index aa3f492..b9eb05f 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "35bdfd24b481ad94a99b6fd67499aba9", + "hash": "0850a63e18c972e762c563d3d4971ea0", "packages": [ { "name": "o80/i18n", @@ -12,12 +12,12 @@ "source": { "type": "git", "url": "https://github.com/olivierperez/o80-i18n.git", - "reference": "27ad49063797169878605e310d42d2de618ff695" + "reference": "9b57197b395add3afc62fd674b03926230819b97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/olivierperez/o80-i18n/zipball/27ad49063797169878605e310d42d2de618ff695", - "reference": "27ad49063797169878605e310d42d2de618ff695", + "url": "https://api.github.com/repos/olivierperez/o80-i18n/zipball/9b57197b395add3afc62fd674b03926230819b97", + "reference": "9b57197b395add3afc62fd674b03926230819b97", "shasum": "" }, "require": { @@ -50,7 +50,7 @@ "internationalization", "php" ], - "time": "2015-04-11 20:55:50" + "time": "2015-05-09 22:08:09" }, { "name": "smarty/smarty", @@ -108,7 +108,965 @@ "time": "2014-10-31 04:22:20" } ], - "packages-dev": [], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "2.0.*@ALPHA" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Instantiator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2014-10-13 12:58:55" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2015-02-03 12:10:50" + }, + { + "name": "phpspec/prophecy", + "version": "v1.4.1", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "phpdocumentor/reflection-docblock": "~2.0", + "sebastian/comparator": "~1.1" + }, + "require-dev": { + "phpspec/phpspec": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2015-04-27 22:15:08" + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.0.17", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "c4e8e7725e351184a76544634855b8a9c405a6e3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c4e8e7725e351184a76544634855b8a9c405a6e3", + "reference": "c4e8e7725e351184a76544634855b8a9c405a6e3", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "~1.0", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2015-05-25 05:11:59" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb", + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2015-04-02 05:19:05" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "Text/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2014-01-30 17:20:04" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2013-08-02 07:42:54" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.4.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "eab81d02569310739373308137284e0158424330" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/eab81d02569310739373308137284e0158424330", + "reference": "eab81d02569310739373308137284e0158424330", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2015-04-08 04:46:07" + }, + { + "name": "phpunit/phpunit", + "version": "4.6.9", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "816d12536a7a032adc3b68737f82cfbbf98b79c1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/816d12536a7a032adc3b68737f82cfbbf98b79c1", + "reference": "816d12536a7a032adc3b68737f82cfbbf98b79c1", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpspec/prophecy": "~1.3,>=1.3.1", + "phpunit/php-code-coverage": "~2.0,>=2.0.11", + "phpunit/php-file-iterator": "~1.4", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "~1.0", + "phpunit/phpunit-mock-objects": "~2.3", + "sebastian/comparator": "~1.1", + "sebastian/diff": "~1.2", + "sebastian/environment": "~1.2", + "sebastian/exporter": "~1.2", + "sebastian/global-state": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.1|~3.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.6.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2015-05-29 06:00:03" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "2.3.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/253c005852591fd547fc18cd5b7b43a1ec82d8f7", + "reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "~1.0,>=1.0.2", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2015-05-29 05:19:18" + }, + { + "name": "sebastian/comparator", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2015-01-29 16:28:08" + }, + { + "name": "sebastian/diff", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2015-02-22 15:13:53" + }, + { + "name": "sebastian/environment", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2015-01-01 10:01:08" + }, + { + "name": "sebastian/exporter", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "84839970d05254c73cde183a721c7af13aede943" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943", + "reference": "84839970d05254c73cde183a721c7af13aede943", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2015-01-27 07:23:06" + }, + { + "name": "sebastian/global-state", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2014-10-06 09:23:50" + }, + { + "name": "sebastian/recursion-context", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2015-01-24 09:48:32" + }, + { + "name": "sebastian/version", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", + "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2015-02-24 06:35:25" + }, + { + "name": "symfony/yaml", + "version": "v2.6.8", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/f157ab074e453ecd4c0fa775f721f6e67a99d9e2", + "reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2015-05-02 15:18:45" + } + ], "aliases": [], "minimum-stability": "stable", "stability-flags": { diff --git a/phpunit.bat b/phpunit.bat new file mode 100644 index 0000000..7691614 --- /dev/null +++ b/phpunit.bat @@ -0,0 +1 @@ +vendor\bin\phpunit.bat --bootstrap app\tests\bootstrap.php app/tests \ No newline at end of file diff --git a/phpunit.sh b/phpunit.sh new file mode 100644 index 0000000..ce4446f --- /dev/null +++ b/phpunit.sh @@ -0,0 +1 @@ +vendor\bin\phpunit --bootstrap app\tests\bootstrap.php app/tests \ No newline at end of file From be155aa2a1e11e847a77892683a4c6ca5126b020 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 17:06:03 +0200 Subject: [PATCH 14/32] MailService now manage the anti-flood system --- .../Framadate/Services/MailService.php | 29 +++++++++++++++++-- .../Services/MailServiceUnitTest.php | 28 ++++++++++++++++-- studs.php | 7 ++--- 3 files changed, 56 insertions(+), 8 deletions(-) diff --git a/app/classes/Framadate/Services/MailService.php b/app/classes/Framadate/Services/MailService.php index 2b7dd66..51d343d 100644 --- a/app/classes/Framadate/Services/MailService.php +++ b/app/classes/Framadate/Services/MailService.php @@ -5,6 +5,10 @@ class MailService { private $smtp_allowed; + const DELAY_BEFORE_RESEND = 300; + + const MAILSERVICE_KEY = 'mailservice'; + function __construct($smtp_allowed) { $this->smtp_allowed = $smtp_allowed; } @@ -13,10 +17,12 @@ class MailService { return filter_var($email, FILTER_VALIDATE_EMAIL); } - function send($to, $subject, $body, $param = '') { - if ($this->smtp_allowed == true) { + function send($to, $subject, $body, $param = '', $msgKey = null) { + if ($this->smtp_allowed == true && $this->canSendMsg($msgKey)) { mb_internal_encoding('UTF-8'); + // Build headers + $subject = mb_encode_mimeheader(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'), 'UTF-8', 'B', "\n", 9); $encoded_app = mb_encode_mimeheader(NOMAPPLICATION, 'UTF-8', 'B', "\n", 6); @@ -39,11 +45,30 @@ class MailService { $headers .= "Auto-Submitted:auto-generated\n"; $headers .= 'Return-Path: <>'; + // Build body + $body = $body . '

' . __('Mail', 'Thanks for your trust.') . '
' . NOMAPPLICATION . '
' . __('Mail', 'FOOTER'); + // Send mail + mail($to, $subject, $body, $headers, $param); + + // Set date before resend in sessions + + $_SESSION[self::MAILSERVICE_KEY][$msgKey] = time() + self::DELAY_BEFORE_RESEND; } } + function canSendMsg($msgKey) { + if ($msgKey == null) { + return true; + } + + if (!isset($_SESSION[self::MAILSERVICE_KEY])) { + $_SESSION[self::MAILSERVICE_KEY] = []; + } + return !isset($_SESSION[self::MAILSERVICE_KEY][$msgKey]) || $_SESSION[self::MAILSERVICE_KEY][$msgKey] < time(); + } + } \ No newline at end of file diff --git a/app/tests/Framadate/Services/MailServiceUnitTest.php b/app/tests/Framadate/Services/MailServiceUnitTest.php index 70e99c6..fe22ebe 100644 --- a/app/tests/Framadate/Services/MailServiceUnitTest.php +++ b/app/tests/Framadate/Services/MailServiceUnitTest.php @@ -4,12 +4,36 @@ namespace Framadate\Services; use Framadate\FramaTestCase; class MailServiceUnitTest extends FramaTestCase { + const MSG_KEY = '666'; /** * @test */ - function cconstruct() { - $this->assertEquals('a', 'a'); + function should_send_a_2nd_mail_after_a_good_interval() { + // Given + $mailService = new MailService(true); + $_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time() - 500]; + + // When + $canSendMsg = $mailService->canSendMsg(self::MSG_KEY); + + // Then + $this->assertEquals(true, $canSendMsg); + } + + /** + * @test + */ + function should_not_send_2_mails_in_a_short_interval() { + // Given + $mailService = new MailService(true); + $_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time() + 500]; + + // When + $canSendMsg = $mailService->canSendMsg(self::MSG_KEY); + + // Then + $this->assertEquals(false, $canSendMsg); } } diff --git a/studs.php b/studs.php index 0bcf460..bab6141 100644 --- a/studs.php +++ b/studs.php @@ -64,7 +64,7 @@ function sendUpdateNotification($poll, $mailService, $name, $type) { $_SESSION['mail_sent'] = []; } - if ($poll->receiveNewVotes && (!isset($_SESSION['mail_sent'][$poll->id]) || $_SESSION['mail_sent'][$poll->id] !== true)) { + if ($poll->receiveNewVotes) { $subject = '[' . NOMAPPLICATION . '] ' . __('Mail', 'Poll\'s participation') . ' : ' . $poll->title; @@ -82,9 +82,8 @@ function sendUpdateNotification($poll, $mailService, $name, $type) { } $message .= Utils::getUrlSondage($poll->admin_id, true) . "\n\n"; - $mailService->send($poll->admin_mail, $subject, $message); - - $_SESSION['mail_sent'][$poll->id] = true; + $messageTypeKey = $type . '-' . $poll->id; + $mailService->send($messageTypeKey, $poll->admin_mail, $subject, $message); } } From 8313b9345d9936c4848f597c9d2a7ab0b42ec3d0 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 17:12:47 +0200 Subject: [PATCH 15/32] Fix after update o80-i18n --- app/inc/i18n.php | 2 +- create_classic_poll.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/inc/i18n.php b/app/inc/i18n.php index 257ac18..2257286 100644 --- a/app/inc/i18n.php +++ b/app/inc/i18n.php @@ -28,7 +28,7 @@ if (isset($_POST['lang']) && is_string($_POST['lang']) && in_array($_POST['lang' } /* */ -$i18n->get('Something, just to load the dictionary'); +$i18n->get('', 'Something, just to load the dictionary'); $locale = $i18n->getLoadedLang(); /* Date Format */ diff --git a/create_classic_poll.php b/create_classic_poll.php index e2b87c4..1b989e8 100644 --- a/create_classic_poll.php +++ b/create_classic_poll.php @@ -198,7 +198,7 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || (
- +
' . __('Date', 'dd/mm/yyyy') . ' From 755580463dc2cf44d5834d2f068a22afd2a92e33 Mon Sep 17 00:00:00 2001 From: Antonin Date: Fri, 29 May 2015 17:36:13 +0200 Subject: [PATCH 16/32] Fix the change of expiration date check which was too loose. --- adminstuds.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adminstuds.php b/adminstuds.php index 5d7e2d6..0ccc534 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -111,7 +111,8 @@ if (isset($_POST['update_poll_info'])) { break; } } elseif ($field == 'expiration_date') { - $expiration_date = filter_input(INPUT_POST, 'expiration_date', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '#^[0-9]+[-/][0-9]+[-/][0-9]+#']]); + $expiration_date = filter_input(INPUT_POST, 'expiration_date', FILTER_VALIDATE_REGEXP, + ['options' => ['regexp' => '#^[0-9]{4}-[0-9]{2}-[0-9]{2}$#']]); if ($expiration_date) { $poll->end_date = $expiration_date; $updated = true; From 278e478d1ac5e375599925b1bb08264f059d95c4 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 17:41:50 +0200 Subject: [PATCH 17/32] Write log when send a mail --- .../Framadate/Services/MailService.php | 23 ++++++++++++++----- .../Services/MailServiceUnitTest.php | 4 ++-- studs.php | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/app/classes/Framadate/Services/MailService.php b/app/classes/Framadate/Services/MailService.php index 51d343d..1f87d6e 100644 --- a/app/classes/Framadate/Services/MailService.php +++ b/app/classes/Framadate/Services/MailService.php @@ -9,7 +9,10 @@ class MailService { const MAILSERVICE_KEY = 'mailservice'; + private $logService; + function __construct($smtp_allowed) { + $this->logService = new LogService(); $this->smtp_allowed = $smtp_allowed; } @@ -51,11 +54,7 @@ class MailService { // Send mail - mail($to, $subject, $body, $headers, $param); - - // Set date before resend in sessions - - $_SESSION[self::MAILSERVICE_KEY][$msgKey] = time() + self::DELAY_BEFORE_RESEND; + $this->sendMail($to, $subject, $body, $param, $msgKey, $headers); } } @@ -67,7 +66,19 @@ class MailService { if (!isset($_SESSION[self::MAILSERVICE_KEY])) { $_SESSION[self::MAILSERVICE_KEY] = []; } - return !isset($_SESSION[self::MAILSERVICE_KEY][$msgKey]) || $_SESSION[self::MAILSERVICE_KEY][$msgKey] < time(); + return !isset($_SESSION[self::MAILSERVICE_KEY][$msgKey]) || time() - $_SESSION[self::MAILSERVICE_KEY][$msgKey] > self::DELAY_BEFORE_RESEND; + } + + private function sendMail($to, $subject, $body, $param, $msgKey, $headers) { + mail($to, $subject, $body, $headers, $param); + + // Log + + $this->logService->log('MAIL', 'Mail sent to: ' . $to . ', key: ' . $msgKey); + + // Store the mail sending date + + $_SESSION[self::MAILSERVICE_KEY][$msgKey] = time(); } } diff --git a/app/tests/Framadate/Services/MailServiceUnitTest.php b/app/tests/Framadate/Services/MailServiceUnitTest.php index fe22ebe..b4045f2 100644 --- a/app/tests/Framadate/Services/MailServiceUnitTest.php +++ b/app/tests/Framadate/Services/MailServiceUnitTest.php @@ -12,7 +12,7 @@ class MailServiceUnitTest extends FramaTestCase { function should_send_a_2nd_mail_after_a_good_interval() { // Given $mailService = new MailService(true); - $_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time() - 500]; + $_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time() - 1000]; // When $canSendMsg = $mailService->canSendMsg(self::MSG_KEY); @@ -27,7 +27,7 @@ class MailServiceUnitTest extends FramaTestCase { function should_not_send_2_mails_in_a_short_interval() { // Given $mailService = new MailService(true); - $_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time() + 500]; + $_SESSION[MailService::MAILSERVICE_KEY] = [self::MSG_KEY => time()]; // When $canSendMsg = $mailService->canSendMsg(self::MSG_KEY); diff --git a/studs.php b/studs.php index bab6141..26d7b23 100644 --- a/studs.php +++ b/studs.php @@ -83,7 +83,7 @@ function sendUpdateNotification($poll, $mailService, $name, $type) { $message .= Utils::getUrlSondage($poll->admin_id, true) . "\n\n"; $messageTypeKey = $type . '-' . $poll->id; - $mailService->send($messageTypeKey, $poll->admin_mail, $subject, $message); + $mailService->send($poll->admin_mail, $subject, $message, '', $messageTypeKey); } } From d7d9b11fbd5fdc86515116297cc2fe79a0970b9e Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 17:46:13 +0200 Subject: [PATCH 18/32] Add anti-flood 'find my polls' --- find_polls.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/find_polls.php b/find_polls.php index e3ca6dd..5e25a07 100644 --- a/find_polls.php +++ b/find_polls.php @@ -43,7 +43,7 @@ if (!empty($_POST['mail'])) { $smarty->assign('polls', $polls); $body = $smarty->fetch('mail/find_polls.tpl'); - $mailService->send($mail, __('Homepage', 'Where are my polls'), $body); + $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')); From 4a9179ffea5b285888351d1a46ca797975e60c3e Mon Sep 17 00:00:00 2001 From: Antonin Date: Fri, 29 May 2015 17:46:29 +0200 Subject: [PATCH 19/32] Fix the poll's deletion date --- studs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/studs.php b/studs.php index 0bcf460..6597c02 100644 --- a/studs.php +++ b/studs.php @@ -207,7 +207,7 @@ $smarty->assign('poll_id', $poll_id); $smarty->assign('poll', $poll); $smarty->assign('title', __('Generic', 'Poll') . ' - ' . $poll->title); $smarty->assign('expired', strtotime($poll->end_date) < time()); -$smarty->assign('deletion_date', $poll->end_date + PURGE_DELAY * 86400); +$smarty->assign('deletion_date', strtotime($poll->end_date) + PURGE_DELAY * 86400); $smarty->assign('slots', $poll->format === 'D' ? $pollService->splitSlots($slots) : $slots); $smarty->assign('votes', $pollService->splitVotes($votes)); $smarty->assign('best_choices', $pollService->computeBestChoices($votes)); From ad2b146c3c813c481d14b6390583e957d447574e Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 17:49:01 +0200 Subject: [PATCH 20/32] Remove parameter from MailService::send --- app/classes/Framadate/Services/MailService.php | 8 ++++---- find_polls.php | 2 +- studs.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/classes/Framadate/Services/MailService.php b/app/classes/Framadate/Services/MailService.php index 1f87d6e..18807b2 100644 --- a/app/classes/Framadate/Services/MailService.php +++ b/app/classes/Framadate/Services/MailService.php @@ -20,7 +20,7 @@ class MailService { return filter_var($email, FILTER_VALIDATE_EMAIL); } - function send($to, $subject, $body, $param = '', $msgKey = null) { + function send($to, $subject, $body, $msgKey = null) { if ($this->smtp_allowed == true && $this->canSendMsg($msgKey)) { mb_internal_encoding('UTF-8'); @@ -54,7 +54,7 @@ class MailService { // Send mail - $this->sendMail($to, $subject, $body, $param, $msgKey, $headers); + $this->sendMail($to, $subject, $body, $msgKey, $headers); } } @@ -69,8 +69,8 @@ class MailService { return !isset($_SESSION[self::MAILSERVICE_KEY][$msgKey]) || time() - $_SESSION[self::MAILSERVICE_KEY][$msgKey] > self::DELAY_BEFORE_RESEND; } - private function sendMail($to, $subject, $body, $param, $msgKey, $headers) { - mail($to, $subject, $body, $headers, $param); + private function sendMail($to, $subject, $body, $msgKey, $headers) { + mail($to, $subject, $body, $headers, ''); // Log diff --git a/find_polls.php b/find_polls.php index 5e25a07..c4ced25 100644 --- a/find_polls.php +++ b/find_polls.php @@ -43,7 +43,7 @@ if (!empty($_POST['mail'])) { $smarty->assign('polls', $polls); $body = $smarty->fetch('mail/find_polls.tpl'); - $mailService->send($mail, __('Homepage', 'Where are my polls'), $body, '', 'SEND_POLLS'); + $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')); diff --git a/studs.php b/studs.php index 26d7b23..0ebdd0f 100644 --- a/studs.php +++ b/studs.php @@ -83,7 +83,7 @@ function sendUpdateNotification($poll, $mailService, $name, $type) { $message .= Utils::getUrlSondage($poll->admin_id, true) . "\n\n"; $messageTypeKey = $type . '-' . $poll->id; - $mailService->send($poll->admin_mail, $subject, $message, '', $messageTypeKey); + $mailService->send($poll->admin_mail, $subject, $message, $messageTypeKey); } } From cb0864f8fd88bb4562b9c2135387ba0c4825fd06 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 18:11:12 +0200 Subject: [PATCH 21/32] Fix a lot of things --- admin/purge.php | 1 - app/classes/Framadate/Form.php | 2 -- create_classic_poll.php | 10 +++++----- create_date_poll.php | 2 +- exportcsv.php | 3 --- index.php | 2 -- studs.php | 2 +- 7 files changed, 7 insertions(+), 15 deletions(-) diff --git a/admin/purge.php b/admin/purge.php index 5a8e268..fb817f1 100644 --- a/admin/purge.php +++ b/admin/purge.php @@ -21,7 +21,6 @@ use Framadate\Services\InputService; use Framadate\Services\LogService; use Framadate\Services\PurgeService; use Framadate\Services\SecurityService; -use Framadate\Utils; include_once __DIR__ . '/../app/inc/init.php'; include_once __DIR__ . '/../bandeaux.php'; diff --git a/app/classes/Framadate/Form.php b/app/classes/Framadate/Form.php index ce802ba..f73cd9e 100644 --- a/app/classes/Framadate/Form.php +++ b/app/classes/Framadate/Form.php @@ -18,8 +18,6 @@ */ namespace Framadate; -use Framadate\Editable; - class Form { diff --git a/create_classic_poll.php b/create_classic_poll.php index 1b989e8..21c652b 100644 --- a/create_classic_poll.php +++ b/create_classic_poll.php @@ -41,13 +41,13 @@ if (file_exists('bandeaux_local.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!")); - bandeau_titre(__("Error!")); + Utils::print_header(__('Error', 'Error!')); + bandeau_titre(__('Error', 'Error!')); echo '
-

' . __('You haven\'t filled the first section of the poll creation.') . ' !

-

' . __('Back to the homepage of') . ' ' . NOMAPPLICATION . '

+

' . __('Error', 'You haven\'t filled the first section of the poll creation.') . ' !

+

' . __('Generic', 'Back to the homepage of') . ' ' . NOMAPPLICATION . '

' . "\n"; bandeau_pied(); @@ -149,7 +149,7 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || ( // Summary $summary = '
    '; - foreach ($_SESSION['form']->getChoices() as $choice) { + foreach ($_SESSION['form']->getChoices() as $i=>$choice) { preg_match_all('/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/', $choice->getName(), $md_a_img); // Markdown [![alt](src)](href) preg_match_all('/!\[(.*?)\]\((.*?)\)/', $choice->getName(), $md_img); // Markdown ![alt](src) diff --git a/create_date_poll.php b/create_date_poll.php index aec2a26..f170b5b 100644 --- a/create_date_poll.php +++ b/create_date_poll.php @@ -194,7 +194,7 @@ if (!isset($_SESSION['form']->title) || !isset($_SESSION['form']->admin_name) ||
    - +
    ('. __('Date', 'dd/mm/yyyy') .') diff --git a/exportcsv.php b/exportcsv.php index f5b5d0b..6197cfb 100644 --- a/exportcsv.php +++ b/exportcsv.php @@ -18,9 +18,6 @@ */ use Framadate\Services\LogService; use Framadate\Services\PollService; -use Framadate\Services\InputService; -use Framadate\Services\MailService; -use Framadate\Message; use Framadate\Utils; include_once __DIR__ . '/app/inc/init.php'; diff --git a/index.php b/index.php index e756076..364c90c 100644 --- a/index.php +++ b/index.php @@ -17,9 +17,7 @@ * Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft) */ -use Framadate\Services\LogService; use Framadate\Services\PollService; -use Framadate\Utils; include_once __DIR__ . '/app/inc/init.php'; diff --git a/studs.php b/studs.php index 0ebdd0f..9448297 100644 --- a/studs.php +++ b/studs.php @@ -151,7 +151,7 @@ if (!empty($_POST['save'])) { // Save edition of an old vote $message = new Message('danger', __('Error', 'The name is invalid.')); } if (count($choices) != count($_POST['choices'])) { - $message = new Message('danger', __('There is a problem with your choices')); + $message = new Message('danger', __('Error', 'There is a problem with your choices')); } if ($message == null) { From b717bee76515b2db6b739a792de19ef450a91bea Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 18:25:48 +0200 Subject: [PATCH 22/32] Remove '?' image on 'Where are my polls' link --- images/question.png | Bin 9757 -> 0 bytes tpl/index.tpl | 2 -- 2 files changed, 2 deletions(-) delete mode 100644 images/question.png diff --git a/images/question.png b/images/question.png deleted file mode 100644 index 73d1d94803366747773dd6e0a1f9e5fc6201cbcb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9757 zcmZ{K2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mon Sep 17 00:00:00 2001 From: Antonin Date: Fri, 29 May 2015 18:33:55 +0200 Subject: [PATCH 23/32] Fixing the description newlines problem - As it is now, description can't be in error state : we are waiting the markdown implementation to eventually change that. - Comments are now normaly formated (newlines are taken into account) - The title, description and comment regexes are now useless. Deleted. --- app/classes/Framadate/Services/InputService.php | 8 +++----- app/inc/constants.php | 3 --- create_poll.php | 2 +- tpl/part/comments.tpl | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/app/classes/Framadate/Services/InputService.php b/app/classes/Framadate/Services/InputService.php index c7de298..31b3103 100644 --- a/app/classes/Framadate/Services/InputService.php +++ b/app/classes/Framadate/Services/InputService.php @@ -51,8 +51,7 @@ class InputService { } public function filterTitle($title) { - $filtered = filter_var($title, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => TITLE_REGEX]]); - return $this->returnIfNotBlank($filtered); + return $this->returnIfNotBlank($title); } public function filterName($name) { @@ -66,7 +65,7 @@ class InputService { public function filterDescription($description) { $description = str_replace("\r\n", "\n", $description); - return filter_var($description, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => DESCRIPTION_REGEX]]); + return $description; } public function filterBoolean($boolean) { @@ -79,8 +78,7 @@ class InputService { public function filterComment($comment) { $comment = str_replace("\r\n", "\n", $comment); - $filtered = filter_var($comment, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => COMMENT_REGEX]]); - return $this->returnIfNotBlank($filtered); + return $this->returnIfNotBlank($comment); } /** diff --git a/app/inc/constants.php b/app/inc/constants.php index f043099..d1db10a 100644 --- a/app/inc/constants.php +++ b/app/inc/constants.php @@ -24,9 +24,6 @@ const VERSION = '0.9'; const POLL_REGEX = '/^[a-z0-9]+$/i'; const CHOICE_REGEX = '/^[012]$/'; const NAME_REGEX = '/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9_ -]+$/i'; -const TITLE_REGEX = '/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9\\/ &"\'(_)=~#{|`^@}$[\\]\\\\,;:!?.*-]+$/i'; -const DESCRIPTION_REGEX = "/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9\\/ &\"'(_)=~#{|`^@}$[\\]\\\\,;:!?.*\n-]*$/i"; -const COMMENT_REGEX = "/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9\\/ &\"'(_)=~#{|`^@}$[\\]\\\\,;:!?.*\n-]+$/i"; const BOOLEAN_REGEX = '/^(on|off|true|false|1|0)$/i'; const BOOLEAN_TRUE_REGEX = '/^(on|true|1)$/i'; const EDITABLE_CHOICE_REGEX = '/^[0-2]$/'; diff --git a/create_poll.php b/create_poll.php index 8682c74..43c5b4a 100644 --- a/create_poll.php +++ b/create_poll.php @@ -90,7 +90,7 @@ if ($goToStep2) { $error_on_name = true; } - if ($description !== $_POST['description']) { + if ($description === false) { $error_on_description = true; } diff --git a/tpl/part/comments.tpl b/tpl/part/comments.tpl index 660041e..c25adf2 100644 --- a/tpl/part/comments.tpl +++ b/tpl/part/comments.tpl @@ -11,7 +11,7 @@ {/if} {$comment->name|html}  - {nl2br($comment->comment|html)} + {$comment->comment|escape|nl2br}

    {/foreach} {/if} From fa111ab04e29cc10825a7e0323922c9e3f334ed4 Mon Sep 17 00:00:00 2001 From: Antonin Date: Fri, 29 May 2015 18:53:09 +0200 Subject: [PATCH 24/32] Prevent from deleting the last slot - Also fix the corresponding translation when a problem arise. --- adminstuds.php | 2 +- app/classes/Framadate/Services/AdminPollService.php | 8 ++++++++ locale/de.json | 3 ++- locale/en.json | 3 ++- locale/es.json | 3 ++- locale/fr.json | 3 ++- locale/it.json | 3 ++- 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/adminstuds.php b/adminstuds.php index 0ccc534..baf25c7 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -331,7 +331,7 @@ if (!empty($_GET['delete_column'])) { if ($result) { $message = new Message('success', __('adminstuds', 'Column removed')); } else { - $message = new Message('danger', __('Error', 'Failed to delete the column')); + $message = new Message('danger', __('Error', 'Failed to delete column')); } } diff --git a/app/classes/Framadate/Services/AdminPollService.php b/app/classes/Framadate/Services/AdminPollService.php index b4b47d5..4760f8a 100644 --- a/app/classes/Framadate/Services/AdminPollService.php +++ b/app/classes/Framadate/Services/AdminPollService.php @@ -117,6 +117,10 @@ class AdminPollService { $slots = $this->pollService->allSlotsByPollId($poll_id); + if (count($slots) === 1) { + return false; + } + $index = 0; $indexToDelete = -1; $newMoments = []; @@ -155,6 +159,10 @@ class AdminPollService { $slots = $this->pollService->allSlotsByPollId($poll_id); + if (count($slots) === 1) { + return false; + } + $index = 0; $indexToDelete = -1; diff --git a/locale/de.json b/locale/de.json index c033119..6c83142 100644 --- a/locale/de.json +++ b/locale/de.json @@ -326,6 +326,7 @@ "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:": "Sie können nicht eine Umfrage erstellen mit versteckten Ergebnisse mit der folgenden Ausgabe-Option:" + "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:", + "Failed to delete column": "Fehler beim Spalte löschen" } } diff --git a/locale/en.json b/locale/en.json index d63249c..d731d3f 100644 --- a/locale/en.json +++ b/locale/en.json @@ -326,6 +326,7 @@ "Update vote failed": "Update vote failed", "Adding vote failed": "Adding vote failed", "Comment failed": "Comment failed", - "You can't create a poll with hidden results with the following edition option:": "You can't create a poll with hidden results with the following edition option: " + "You can't create a poll with hidden results with the following edition option:": "You can't create a poll with hidden results with the following edition option: ", + "Failed to delete column": "Failed to delete column" } } diff --git a/locale/es.json b/locale/es.json index 032e51f..2150ff3 100644 --- a/locale/es.json +++ b/locale/es.json @@ -326,6 +326,7 @@ "Update vote failed": "ES_Mise à jour du vote échoué", "Adding vote failed": "ES_Ajout d'un vote échoué", "Comment failed": "ES_Commentaire échoué", - "You can't create a poll with hidden results with the following edition option:": "ES_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:": "ES_Vous ne pouvez pas créer de sondage avec résulats cachés avec les options d'éditions suivantes : ", + "Failed to delete column": "Error al eliminar la columna" } } diff --git a/locale/fr.json b/locale/fr.json index 368772c..1f97f7e 100644 --- a/locale/fr.json +++ b/locale/fr.json @@ -326,6 +326,7 @@ "Update vote failed": "Mise à jour du vote échoué", "Adding vote failed": "Ajout d'un vote échoué", "Comment failed": "Commentaire échoué", - "You can't create a poll with hidden results with the following edition option:": "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:": "Vous ne pouvez pas créer de sondage avec résulats cachés avec les options d'éditions suivantes : ", + "Failed to delete column": "Échec de la suppression de colonne" } } diff --git a/locale/it.json b/locale/it.json index fb12303..6ae7e6d 100644 --- a/locale/it.json +++ b/locale/it.json @@ -326,6 +326,7 @@ "Update vote failed": "IT_Mise à jour du vote échoué", "Adding vote failed": "IT_Ajout d'un vote échoué", "Comment failed": "IT_Commentaire échoué", - "You can't create a poll with hidden results with the following edition option:": "IT_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:": "IT_Vous ne pouvez pas créer de sondage avec résulats cachés avec les options d'éditions suivantes : ", + "Failed to delete column": "Impossibile eliminare colonna" } } \ No newline at end of file From c9c45a2d242390eafc11c83f4250d4f43ed71e68 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 19:03:29 +0200 Subject: [PATCH 25/32] Send mail to admin when update/delete a poll --- adminstuds.php | 50 +++++++++++++++++++++++++++++++++++++++++--- locale/de.json | 4 +++- locale/en.json | 4 +++- locale/es.json | 10 +++++---- locale/fr.json | 4 +++- locale/it.json | 4 +++- tpl/poll_deleted.tpl | 2 +- 7 files changed, 66 insertions(+), 12 deletions(-) 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}
    -

    {__('adminstuds', 'The poll has been deleted')}

    +

    {$message}

    {__('Generic', 'Back to the homepage of')} {$APPLICATION_NAME|html}

    {/block} \ No newline at end of file From 50f3088422d810795a444f8f131b6217bf4d9596 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 29 May 2015 19:10:39 +0200 Subject: [PATCH 26/32] Little fix for previous merge --- adminstuds.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adminstuds.php b/adminstuds.php index 701940b..14a1798 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -422,7 +422,7 @@ $smarty->assign('admin_poll_id', $admin_poll_id); $smarty->assign('poll', $poll); $smarty->assign('title', __('Generic', 'Poll') . ' - ' . $poll->title); $smarty->assign('expired', strtotime($poll->end_date) < time()); -$smarty->assign('deletion_date', $poll->end_date + PURGE_DELAY * 86400); +$smarty->assign('deletion_date', strtotime($poll->end_date) + PURGE_DELAY * 86400); $smarty->assign('slots', $poll->format === 'D' ? $pollService->splitSlots($slots) : $slots); $smarty->assign('votes', $pollService->splitVotes($votes)); $smarty->assign('best_choices', $pollService->computeBestChoices($votes)); From d365f18c01af366a0f3950b186bace3f7463d8e4 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Sat, 30 May 2015 23:27:17 +0200 Subject: [PATCH 27/32] Fix message when delete a poll --- tpl/poll_deleted.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tpl/poll_deleted.tpl b/tpl/poll_deleted.tpl index 0c7bd62..78c44f6 100644 --- a/tpl/poll_deleted.tpl +++ b/tpl/poll_deleted.tpl @@ -1,8 +1,8 @@ {extends file='page.tpl'} {block name=main} -
    -

    {$message}

    +
    +

    {$message->message}

    {__('Generic', 'Back to the homepage of')} {$APPLICATION_NAME|html}

    {/block} \ No newline at end of file From 44928b057292129c3f54afbb3c7c9f696ecc105b Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Sat, 30 May 2015 23:36:04 +0200 Subject: [PATCH 28/32] Dont sort classic polls --- adminstuds.php | 10 +-- .../Framadate/Repositories/SlotRepository.php | 2 +- .../Framadate/Services/AdminPollService.php | 68 +++++++++++++++---- .../Framadate/Services/PollService.php | 12 +++- exportcsv.php | 2 +- studs.php | 2 +- 6 files changed, 71 insertions(+), 25 deletions(-) diff --git a/adminstuds.php b/adminstuds.php index 14a1798..d5f9cab 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -367,9 +367,9 @@ if (!empty($_GET['delete_column'])) { $slot->title = $ex[0]; $slot->moment = $ex[1]; - $result = $adminPollService->deleteDateSlot($poll_id, $slot); + $result = $adminPollService->deleteDateSlot($poll, $slot); } else { - $result = $adminPollService->deleteClassicSlot($poll_id, $column); + $result = $adminPollService->deleteClassicSlot($poll, $column); } if ($result) { @@ -397,10 +397,10 @@ if (isset($_POST['confirm_add_slot'])) { $newmoment = strip_tags($_POST['newmoment']); $ex = explode('/', $newdate); - $result = $adminPollService->addSlot($poll_id, mktime(0, 0, 0, $ex[1], $ex[0], $ex[2]), $newmoment); + $result = $adminPollService->addDateSlot($poll_id, mktime(0, 0, 0, $ex[1], $ex[0], $ex[2]), $newmoment); } else { $newslot = strip_tags($_POST['choice']); - $result = $adminPollService->addSlot($poll_id, $newslot, null); + $result = $adminPollService->addClassicSlot($poll_id, $newslot); } if ($result) { @@ -411,7 +411,7 @@ if (isset($_POST['confirm_add_slot'])) { } // Retrieve data -$slots = $pollService->allSlotsByPollId($poll_id); +$slots = $pollService->allSlotsByPoll($poll); $votes = $pollService->allVotesByPollId($poll_id); $comments = $pollService->allCommentsByPollId($poll_id); diff --git a/app/classes/Framadate/Repositories/SlotRepository.php b/app/classes/Framadate/Repositories/SlotRepository.php index fcd11c2..7d69e00 100644 --- a/app/classes/Framadate/Repositories/SlotRepository.php +++ b/app/classes/Framadate/Repositories/SlotRepository.php @@ -61,7 +61,7 @@ class SlotRepository extends AbstractRepository { } function listByPollId($poll_id) { - $prepared = $this->prepare('SELECT * FROM `' . Utils::table('slot') . '` WHERE poll_id = ? ORDER BY title'); + $prepared = $this->prepare('SELECT * FROM `' . Utils::table('slot') . '` WHERE poll_id = ? ORDER BY id'); $prepared->execute(array($poll_id)); return $prepared->fetchAll(); diff --git a/app/classes/Framadate/Services/AdminPollService.php b/app/classes/Framadate/Services/AdminPollService.php index 4760f8a..fb020bc 100644 --- a/app/classes/Framadate/Services/AdminPollService.php +++ b/app/classes/Framadate/Services/AdminPollService.php @@ -105,17 +105,17 @@ class AdminPollService { /** * Delete a slot from a poll. * - * @param $poll_id int The ID of the poll - * @param $slot object The slot informations (datetime + moment) + * @param object $poll The ID of the poll + * @param object $slot The slot informations (datetime + moment) * @return bool true if action succeeded */ - public function deleteDateSlot($poll_id, $slot) { - $this->logService->log('DELETE_SLOT', 'id:' . $poll_id . ', slot:' . json_encode($slot)); + public function deleteDateSlot($poll, $slot) { + $this->logService->log('DELETE_SLOT', 'id:' . $poll->id . ', slot:' . json_encode($slot)); $datetime = $slot->title; $moment = $slot->moment; - $slots = $this->pollService->allSlotsByPollId($poll_id); + $slots = $this->pollService->allSlotsByPoll($poll); if (count($slots) === 1) { return false; @@ -143,21 +143,21 @@ class AdminPollService { // Remove votes $this->connect->beginTransaction(); - $this->voteRepository->deleteByIndex($poll_id, $indexToDelete); + $this->voteRepository->deleteByIndex($poll->id, $indexToDelete); if (count($newMoments) > 0) { - $this->slotRepository->update($poll_id, $datetime, implode(',', $newMoments)); + $this->slotRepository->update($poll->id, $datetime, implode(',', $newMoments)); } else { - $this->slotRepository->deleteByDateTime($poll_id, $datetime); + $this->slotRepository->deleteByDateTime($poll->id, $datetime); } $this->connect->commit(); return true; } - public function deleteClassicSlot($poll_id, $slot_title) { - $this->logService->log('DELETE_SLOT', 'id:' . $poll_id . ', slot:' . $slot_title); + public function deleteClassicSlot($poll, $slot_title) { + $this->logService->log('DELETE_SLOT', 'id:' . $poll->id . ', slot:' . $slot_title); - $slots = $this->pollService->allSlotsByPollId($poll_id); + $slots = $this->pollService->allSlotsByPoll($poll); if (count($slots) === 1) { return false; @@ -176,15 +176,15 @@ class AdminPollService { // Remove votes $this->connect->beginTransaction(); - $this->voteRepository->deleteByIndex($poll_id, $indexToDelete); - $this->slotRepository->deleteByDateTime($poll_id, $slot_title); + $this->voteRepository->deleteByIndex($poll->id, $indexToDelete); + $this->slotRepository->deleteByDateTime($poll->id, $slot_title); $this->connect->commit(); return true; } /** - * Add a new slot to the poll. And insert default values for user's votes. + * Add a new slot to a date poll. And insert default values for user's votes. *
      *
    • Create a new slot if no one exists for the given date
    • *
    • Create a new moment if a slot already exists for the given date
    • @@ -195,7 +195,7 @@ class AdminPollService { * @param $new_moment string The moment's name * @return bool true if added */ - public function addSlot($poll_id, $datetime, $new_moment) { + public function addDateSlot($poll_id, $datetime, $new_moment) { $slots = $this->slotRepository->listByPollId($poll_id); $result = $this->findInsertPosition($slots, $datetime, $new_moment); @@ -232,6 +232,44 @@ class AdminPollService { } + /** + * Add a new slot to a classic poll. And insert default values for user's votes. + *
        + *
      • Create a new slot if no one exists for the given title
      • + *
      + * + * @param $poll_id int The ID of the poll + * @param $title int The title + * @return bool true if added + */ + public function addClassicSlot($poll_id, $title) { + $slots = $this->slotRepository->listByPollId($poll_id); + + // Check if slot already exists + $titles = array_map(function ($slot) { + return $slot->title; + }, $slots); + if (in_array($title, $titles)) { + // The moment already exists + return false; + } + + + // Begin transaction + $this->connect->beginTransaction(); + + // New slot + $this->slotRepository->insert($poll_id, $title, null); + // Set default votes + $this->voteRepository->insertDefault($poll_id, count($slots)); + + // Commit transaction + $this->connect->commit(); + + return true; + + } + /** * This method find where to insert a datatime+moment into a list of slots.
      * Return the {insert:X}, where X is the index of the moment into the whole poll (ex: X=0 => Insert to the first column). diff --git a/app/classes/Framadate/Services/PollService.php b/app/classes/Framadate/Services/PollService.php index 7b99902..7ca2921 100644 --- a/app/classes/Framadate/Services/PollService.php +++ b/app/classes/Framadate/Services/PollService.php @@ -64,8 +64,16 @@ class PollService { return $this->voteRepository->allUserVotesByPollId($poll_id); } - function allSlotsByPollId($poll_id) { - return $this->slotRepository->listByPollId($poll_id); + function allSlotsByPoll($poll) { + $slots = $this->slotRepository->listByPollId($poll->id); + if ($poll->format == 'D') { + uasort($slots, function ($a, $b) { + return $a->title > $b->title; + }); + return $slots; + } else { + return $slots; + } } public function updateVote($poll_id, $vote_id, $name, $choices) { diff --git a/exportcsv.php b/exportcsv.php index 6197cfb..15fd9cb 100644 --- a/exportcsv.php +++ b/exportcsv.php @@ -51,7 +51,7 @@ if (!$poll) { } -$slots = $pollService->allSlotsByPollId($poll_id); +$slots = $pollService->allSlotsByPoll($poll); $votes = $pollService->allVotesByPollId($poll_id); // CSV header diff --git a/studs.php b/studs.php index 9246943..7270fd1 100644 --- a/studs.php +++ b/studs.php @@ -197,7 +197,7 @@ if (isset($_POST['add_comment'])) { } // Retrieve data -$slots = $pollService->allSlotsByPollId($poll_id); +$slots = $pollService->allSlotsByPoll($poll); $votes = $pollService->allVotesByPollId($poll_id); $comments = $pollService->allCommentsByPollId($poll_id); From 94f80687f34729e1be1290b018c9559509d25a8e Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Sun, 31 May 2015 15:45:26 +0200 Subject: [PATCH 29/32] Don't submit dates form if form is not completed --- js/app/date_poll.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/app/date_poll.js b/js/app/date_poll.js index 67c71a0..d63684d 100644 --- a/js/app/date_poll.js +++ b/js/app/date_poll.js @@ -42,11 +42,21 @@ $(document).ready(function () { if (nb_filled_days >= 1 && nb_filled_hours >= 1) { $('button[name="choixheures"]').removeClass('disabled'); + return true; } else { $('button[name="choixheures"]').addClass('disabled'); + return false; } }; + // Handle form submission + $(document.formulaire).on('submit', function (e) { + if (!submitDaysAvalaible()) { + e.preventDefault(); + e.stopPropagation(); + } + }); + // Button "Remove all hours" $(document).on('click', '#resethours', function () { From e8a1f37c981fbe0d7ac09e0ec4de9ca8ad5abc42 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Sun, 31 May 2015 15:57:44 +0200 Subject: [PATCH 30/32] Date poll creation: Always propose 3 choices and 3 slots when choosing dates --- create_date_poll.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/create_date_poll.php b/create_date_poll.php index f170b5b..d33e48f 100644 --- a/create_date_poll.php +++ b/create_date_poll.php @@ -221,17 +221,15 @@ if (!isset($_SESSION['form']->title) || !isset($_SESSION['form']->admin_name) || } else { // Prefill form->choices - if (count($_SESSION['form']->getChoices()) == 0) { - $c = new Choice(''); - $c->addSlot(''); - $c->addSlot(''); - $c->addSlot(''); - $_SESSION['form']->addChoice($c); - $c = new Choice(''); - $c->addSlot(''); - $c->addSlot(''); - $c->addSlot(''); - $_SESSION['form']->addChoice($c); + foreach ($_SESSION['form']->getChoices() as $c) { + $count = 3 - count($c->getSlots()); + for($i=0; $i< $count; $i++) { + $c->addSlot(''); + } + } + + $count = 3 - count($_SESSION['form']->getChoices()); + for($i=0; $i< $count; $i++) { $c = new Choice(''); $c->addSlot(''); $c->addSlot(''); From 474c595b88da5c15ba37f02dbd5adcec236f90d6 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Sun, 31 May 2015 16:02:21 +0200 Subject: [PATCH 31/32] Classic poll: Don't submit choices form if form is not completed --- js/app/classic_poll.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/app/classic_poll.js b/js/app/classic_poll.js index cd3938c..b196822 100644 --- a/js/app/classic_poll.js +++ b/js/app/classic_poll.js @@ -28,11 +28,21 @@ }); if (nb_filled_choices >= 1) { $('button[name="fin_sondage_autre"]').removeClass('disabled'); + return true; } else { $('button[name="fin_sondage_autre"]').addClass('disabled'); + return false; } }; + // Handle form submission + $(document.formulaire).on('submit', function (e) { + if (!submitChoicesAvalaible()) { + e.preventDefault(); + e.stopPropagation(); + } + }); + // Button "Add a choice" $('#add-a-choice').on('click', function () { From 22605a190f291abf5419c2d462666d7186c9375c Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Tue, 9 Jun 2015 11:16:15 +0200 Subject: [PATCH 32/32] Fix an IT translation --- locale/it.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locale/it.json b/locale/it.json index 19d702c..c41a72e 100644 --- a/locale/it.json +++ b/locale/it.json @@ -244,7 +244,7 @@ "List of your choices": "Liste delle vostre scelte", "Once you have confirmed the creation of your poll, you will be automatically redirected on the administration page of your poll.": "Un volta che avrete confermato la creazione del sondaggio, sarete rediretti automaticamente sulla pagina di amministrazione del vostro sondaggio.", "Then, you will receive quickly two emails: one contening the link of your poll for sending it to the voters, the other contening the link to the administration page of your poll.": "Nello stesso momento, riceverete 2 email : una con il Link verso il vostro sondaggio da inoltrare ai partecipanti, l'altra con il Link verso la pagina di amministrazione del sondaggio.", - "Create the poll": "Creare le sondaggio", + "Create the poll": "Creare il sondaggio", "Your poll will automatically be archived": "La vostra indagine verrà archiviata automaticamente", "after the last date of your poll.": "dopo l'ultima data.", "You can set a closer archiving date for it.": "Si può decidere su una data più vicina di archiviazione.",