New edition possibility is taken into account

- Also added Framadate\Message à link attribute
	- Added local anchor #edit with vote edition
	- For now, when the poll owner check the new edit option (ie: "Votes are editable solely by their owner"), users get their update link on vote creation
This commit is contained in:
Antonin 2015-04-05 17:44:29 +02:00
parent 1f55167e2c
commit a3f5763edd
14 changed files with 42 additions and 20 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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";
}
}
}

View File

@ -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.

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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.'));

View File

@ -144,6 +144,7 @@
<option value="0"{if $rule_id==0} selected="selected"{/if}>{__('PollInfo', 'Votes and comments are locked')}</option>
<option value="1"{if $rule_id==1} selected="selected"{/if}>{__('PollInfo', 'Votes and comments are open')}</option>
<option value="2"{if $rule_id==2} selected="selected"{/if}>{__('PollInfo', 'Votes are editable')}</option>
<option value="3"{if $rule_id==3} selected="selected"{/if}>{__('PollInfo', 'Votes are editable solely by their owner.')}</option>
</select>
<span class="input-group-btn">
<button type="submit" name="update_poll_info" value="rules" class="btn btn-success" title="{__('PollInfo', 'Save the new rules')}"><span class="glyphicon glyphicon-ok"></span><span class="sr-only">{__('Generic', 'Save')}</span></button>

View File

@ -37,7 +37,7 @@
{if $editingVoteId === $vote->uniqId}
<td class="bg-info" style="padding:5px">
<div class="input-group input-group-sm">
<div class="input-group input-group-sm" id="edit">
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
<input type="text" id="name" name="name" value="{$vote->name|html}" class="form-control" title="{__('Genric', 'Your name')}" placeholder="{__('Genric', 'Your name')}" />
</div>
@ -86,7 +86,7 @@
{/foreach}
{if $active && $poll->editable && !$expired}
{if $active && !$expired && ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL') or $admin)}
<td>
<a href="{poll_url id=$poll->id vote_id=$vote->uniqId}" class="btn btn-link btn-sm" title="{__('Poll results', 'Edit the line:')|html} {$vote->name|html}">
<span class="glyphicon glyphicon-pencil"></span><span class="sr-only">{__('Generic', 'Edit')}</span>

View File

@ -82,9 +82,8 @@
{* Edited line *}
{if $editingVoteId === $vote->uniqId && !$expired}
<td class="bg-info" style="padding:5px">
<div class="input-group input-group-sm">
<div class="input-group input-group-sm" id="edit">
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
<input type="text" id="name" name="name" value="{$vote->name|html}" class="form-control" title="{__('Generic', 'Your name')}" placeholder="{__('Generic', 'Your name')}" />
</div>
@ -134,7 +133,7 @@
{/foreach}
{if $active && $poll->editable && !$expired}
{if $active && !$expired && ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL') or $admin)}
<td>
<a href="{poll_url id=$poll->id vote_id=$vote->uniqId}" class="btn btn-link btn-sm" title="{__('Poll results', 'Edit the line:')|escape} {$vote->name|html}">
<span class="glyphicon glyphicon-pencil"></span><span class="sr-only">{__('Generic', 'Edit')}</span>

View File

@ -9,7 +9,7 @@
<div id="message-container">
{if !empty($message)}
<div class="alert alert-dismissible alert-{$message->type|html}" role="alert">{$message->message|html}<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>
<div class="alert alert-dismissible alert-{$message->type|html}" role="alert">{$message->message|html}{if $message->link != null}<br/><a href="{$message->link}">{$message->link}</a>{/if}<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>
{/if}
</div>
<div id="nameErrorMessage" class="hidden alert alert-dismissible alert-danger" role="alert">{__('PollInfo', 'The name is invalid.')}<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>