diff --git a/adminstuds.php b/adminstuds.php index b7fe959..997788e 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -22,6 +22,7 @@ use Framadate\Services\InputService; use Framadate\Services\LogService; use Framadate\Message; use Framadate\Utils; +use Framadate\Editable; include_once __DIR__ . '/app/inc/init.php'; @@ -95,17 +96,22 @@ if (isset($_POST['update_poll_info'])) { switch ($rules) { case 0: $poll->active = false; - $poll->editable = false; + $poll->editable = Editable::NOT_EDITABLE; $updated = true; break; case 1: $poll->active = true; - $poll->editable = false; + $poll->editable = Editable::NOT_EDITABLE; $updated = true; break; case 2: $poll->active = true; - $poll->editable = true; + $poll->editable = Editable::EDITABLE_BY_ALL; + $updated = true; + break; + case 3: + $poll->active = true; + $poll->editable = Editable::EDITABLE_BY_OWN; $updated = true; break; } diff --git a/app/classes/Framadate/FramaDB.php b/app/classes/Framadate/FramaDB.php index ba1b250..8159b33 100644 --- a/app/classes/Framadate/FramaDB.php +++ b/app/classes/Framadate/FramaDB.php @@ -131,7 +131,7 @@ class FramaDB { $newVote->id = $this->pdo->lastInsertId(); $newVote->name = $name; $newVote->choices = $choices; - $newVote->token = $token; + $newVote->uniqId = $token; return $newVote; } diff --git a/app/classes/Framadate/Message.php b/app/classes/Framadate/Message.php index 9819e00..c7d7ede 100644 --- a/app/classes/Framadate/Message.php +++ b/app/classes/Framadate/Message.php @@ -22,10 +22,12 @@ class Message { var $type; var $message; + var $link; - function __construct($type, $message) { + function __construct($type, $message, $link=null) { $this->type = $type; $this->message = $message; + $this->link = $link; } } diff --git a/app/classes/Framadate/Utils.php b/app/classes/Framadate/Utils.php index 6a91a27..9c0ab32 100644 --- a/app/classes/Framadate/Utils.php +++ b/app/classes/Framadate/Utils.php @@ -110,7 +110,7 @@ class Utils { } else { $url = str_replace('/admin', '', self::get_server_name()) . $id; if ($vote_id != '') { - $url .= '/vote/'.$vote_id; + $url .= '/vote/'.$vote_id."#edit"; } } } else { @@ -119,7 +119,7 @@ class Utils { } else { $url = str_replace('/admin', '', self::get_server_name()) . 'studs.php?poll=' . $id; if ($vote_id != '') { - $url .= '&vote='.$vote_id; + $url .= '&vote='.$vote_id."#edit"; } } } diff --git a/app/inc/smarty.php b/app/inc/smarty.php index 87e8046..98ad34b 100644 --- a/app/inc/smarty.php +++ b/app/inc/smarty.php @@ -47,8 +47,8 @@ if ($_SERVER['FRAMADATE_DEVMODE']) { function smarty_function_poll_url($params, Smarty_Internal_Template $template) { $poll_id = filter_var($params['id'], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]); - $admin = $params['admin']?true:false; - $vote_unique_id = filter_var($params['vote_id'], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]); + $admin = (isset($params['admin']) && $params['admin']) ? true : false; + $vote_unique_id = isset($params['vote_id']) ? filter_var($params['vote_id'], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]) : ''; // If filter_var fails (i.e.: hack tentative), it will return false. At least no leak is possible from this. diff --git a/locale/de.json b/locale/de.json index 9a99039..a28e227 100644 --- a/locale/de.json +++ b/locale/de.json @@ -111,6 +111,7 @@ "Votes and comments are locked": "Abstimmungen und Kommentare sind gesperrt", "Votes and comments are open": "Abstimmungen und Kommentare sind möglich", "Votes are editable": "Die Abstimmungen können geändert werden", + "Votes are editable solely by their owner.": "DE_Les votes sont modifiables uniquement par leur créateur", "Save the new rules": "Neue Regeln speichern", "Cancel the rules edit": "Neue Regeln nicht speichern", "The name is invalid.": "Der Name ist ungültig." @@ -144,7 +145,8 @@ "If you want to vote in this poll, you have to give your name, choose the values that fit best for you and validate with the plus button at the end of the line.": "Wenn Sie bei dieser Umfrage abstimmen möchten, müssen Sie ihren Namen angeben. Wählen Sie die Optionen, die für Sie am besten passen und bestätigen Sie diese über den Plus-Button am Ende der Zeile.", "POLL_LOCKED_WARNING": "Die Administration gesperrt diese Umfrage. Bewertungen und Kommentare werden eingefroren, es ist nicht mehr möglich, teilzunehmen", "The poll is expired, it will be deleted soon.": "Die Umfrage ist abgelaufen, es wird bald gelöscht werden.", - "Deletion date:": "Löschdatum:" + "Deletion date:": "Löschdatum:", + "Your vote has been registered successfully, but be careful : regarding this poll options, you need to keep this personal link to edit your own vote : ": "DE_Votre vote a bien été pris en compte, mais faites attention : ce sondage n'autorise l'édition de votre vote qu'avec le lien personnalisé suivant ; conservez le précieusement ! " }, "adminstuds": { "As poll administrator, you can change all the lines of this poll with this button": "Als Administrator der Umfrage, können Sie alle Zeilen der Umfrage über diesen Button ändern", diff --git a/locale/en.json b/locale/en.json index 06d0297..b69babf 100644 --- a/locale/en.json +++ b/locale/en.json @@ -112,6 +112,7 @@ "Votes and comments are locked": "Votes and comments are locked", "Votes and comments are open": "Votes and comments are open", "Votes are editable": "Votes are editable", + "Votes are editable solely by their owner.": "Votes are editable solely by their owner", "Save the new rules": "Save the new rules", "Cancel the rules edit": "Cancel the rules edit", "The name is invalid.": "The name is invalid." @@ -145,7 +146,8 @@ "If you want to vote in this poll, you have to give your name, choose the values that fit best for you and validate with the plus button at the end of the line.": "If you want to vote in this poll, you have to give your name, choose the values that fit best for you and validate with the plus button at the end of the line.", "POLL_LOCKED_WARNING": "The administration locked this poll. Votes and comments are frozen, it is no longer possible to participate", "The poll is expired, it will be deleted soon.": "The poll is expired, it will be deleted soon.", - "Deletion date:": "Deletion date:" + "Deletion date:": "Deletion date:", + "Your vote has been registered successfully, but be careful : regarding this poll options, you need to keep this personal link to edit your own vote : ": "Your vote has been registered successfully, but be careful : regarding this poll options, you need to keep this personal link to edit your own vote : " }, "adminstuds": { "As poll administrator, you can change all the lines of this poll with this button": "As poll administrator, you can change all the lines of this poll with this button", diff --git a/locale/es.json b/locale/es.json index 55aa455..ad35a9a 100644 --- a/locale/es.json +++ b/locale/es.json @@ -111,6 +111,7 @@ "Votes and comments are locked": "ES_Les votes et commentaires sont verrouillés", "Votes and comments are open": "ES_Les votes et commentaires sont ouverts", "Votes are editable": "ES_Les votes sont modifiables", + "Votes are editable solely by their owner.": "ES_Les votes sont modifiables uniquement par leur créateur", "Save the new rules": "ES_Enregistrer les nouvelles permissions", "Cancel the rules edit": "ES_Annuler le changement de permissions", "The name is invalid.": "ES_Le nom n'est pas valide." @@ -144,7 +145,8 @@ "If you want to vote in this poll, you have to give your name, choose the values that fit best for you and validate with the plus button at the end of the line.": "Para participar a esta encuesta, introduzca su nombre, elige todas las valores que son apriopriadas y validar su seleccion con el botón verde a la fin de línea.", "POLL_LOCKED_WARNING": "ES_L'administrateur a verrouillé ce sondage. Les votes et commentaires sont gelés, il n'est plus possible de participer", "The poll is expired, it will be deleted soon.": "ES_Le sondage a expiré, il sera bientôt supprimé.", - "Deletion date:": "ES_Date de suppression :" + "Deletion date:": "ES_Date de suppression :", + "Your vote has been registered successfully, but be careful : regarding this poll options, you need to keep this personal link to edit your own vote : ": "ES_Votre vote a bien été pris en compte, mais faites attention : ce sondage n'autorise l'édition de votre vote qu'avec le lien personnalisé suivant ; conservez le précieusement ! " }, "adminstuds": { "As poll administrator, you can change all the lines of this poll with this button": "En calidad de administrador, Usted puede cambiar todas la líneas de este encuesta con este botón", diff --git a/locale/fr.json b/locale/fr.json index 21261d1..241836d 100644 --- a/locale/fr.json +++ b/locale/fr.json @@ -111,6 +111,7 @@ "Votes and comments are locked": "Les votes et commentaires sont verrouillés", "Votes and comments are open": "Les votes et commentaires sont ouverts", "Votes are editable": "Les votes sont modifiables", + "Votes are editable solely by their owner.": "Les votes sont modifiables uniquement par leur créateur", "Save the new rules": "Enregistrer les nouvelles permissions", "Cancel the rules edit": "Annuler le changement de permissions", "The name is invalid.": "Le nom n'est pas valide." @@ -144,7 +145,8 @@ "If you want to vote in this poll, you have to give your name, choose the values that fit best for you and validate with the plus button at the end of the line.": "Pour participer à ce sondage, veuillez entrer votre nom, choisir toutes les valeurs qui vous conviennent et valider votre choix avec le bouton en bout de ligne.", "POLL_LOCKED_WARNING": "L'administrateur a verrouillé ce sondage. Les votes et commentaires sont gelés, il n'est plus possible de participer", "The poll is expired, it will be deleted soon.": "Le sondage a expiré, il sera bientôt supprimé.", - "Deletion date:": "Date de suppression :" + "Deletion date:": "Date de suppression :", + "Your vote has been registered successfully, but be careful : regarding this poll options, you need to keep this personal link to edit your own vote : ": "Votre vote a bien été pris en compte, mais faites attention : ce sondage n'autorise l'édition de votre vote qu'avec le lien personnalisé suivant ; conservez le précieusement ! " }, "adminstuds": { "As poll administrator, you can change all the lines of this poll with this button": "En tant qu'administrateur, vous pouvez modifier toutes les lignes de ce sondage avec ce bouton", diff --git a/studs.php b/studs.php index c965917..142a371 100644 --- a/studs.php +++ b/studs.php @@ -22,6 +22,7 @@ use Framadate\Services\InputService; use Framadate\Services\MailService; use Framadate\Message; use Framadate\Utils; +use Framadate\Editable; include_once __DIR__ . '/app/inc/init.php'; @@ -155,7 +156,12 @@ if (!empty($_POST['save'])) { // Save edition of an old vote // Add vote $result = $pollService->addVote($poll_id, $name, $choices); if ($result) { - $message = new Message('success', _('Update vote successfully.')); + if ($poll->editable == Editable::EDITABLE_BY_OWN) { + $urlEditVote = Utils::getUrlSondage($poll_id, false, $result->uniqId); + $message = new Message('success', __('studs', "Your vote has been registered successfully, but be careful : regarding this poll options, you need to keep this personal link to edit your own vote : "), $urlEditVote); + } else { + $message = new Message('success', _('Update vote successfully.')); + } sendUpdateNotification($poll, $mailService, $name, ADD_VOTE); } else { $message = new Message('danger', _('Update vote failed.')); diff --git a/tpl/part/poll_info.tpl b/tpl/part/poll_info.tpl index b39d1c9..645f9b1 100644 --- a/tpl/part/poll_info.tpl +++ b/tpl/part/poll_info.tpl @@ -144,6 +144,7 @@ + diff --git a/tpl/part/vote_table_classic.tpl b/tpl/part/vote_table_classic.tpl index 786ab3d..3183a11 100644 --- a/tpl/part/vote_table_classic.tpl +++ b/tpl/part/vote_table_classic.tpl @@ -37,7 +37,7 @@ {if $editingVoteId === $vote->uniqId} -
+
@@ -86,7 +86,7 @@ {/foreach} - {if $active && $poll->editable && !$expired} + {if $active && !$expired && ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL') or $admin)} {__('Generic', 'Edit')} diff --git a/tpl/part/vote_table_date.tpl b/tpl/part/vote_table_date.tpl index c081576..49f19a5 100644 --- a/tpl/part/vote_table_date.tpl +++ b/tpl/part/vote_table_date.tpl @@ -82,9 +82,8 @@ {* Edited line *} {if $editingVoteId === $vote->uniqId && !$expired} - -