Fix the update of poll infos

This commit is contained in:
Olivier PEREZ 2015-03-18 00:46:19 +01:00
parent 779af07c60
commit 0efc3d4bcc
3 changed files with 8 additions and 8 deletions

View File

@ -63,7 +63,7 @@ if (!$poll) {
if (isset($_POST['update_poll_info'])) { if (isset($_POST['update_poll_info'])) {
$updated = false; $updated = false;
$field = $inputService->filterAllowedValues($_POST['update_poll_info'], ['title', 'admin_mail', 'comment', 'rules', 'expiration_date', 'name']); $field = $inputService->filterAllowedValues($_POST['update_poll_info'], ['title', 'admin_mail', 'description', 'rules', 'expiration_date', 'name']);
// Update the right poll field // Update the right poll field
if ($field == 'title') { if ($field == 'title') {
@ -78,10 +78,10 @@ if (isset($_POST['update_poll_info'])) {
$poll->admin_mail = $admin_mail; $poll->admin_mail = $admin_mail;
$updated = true; $updated = true;
} }
} elseif ($field == 'comment') { } elseif ($field == 'description') {
$comment = strip_tags($_POST['comment']); $description = strip_tags($_POST['description']);
if ($comment) { if ($description) {
$poll->comment = $comment; $poll->description = $description;
$updated = true; $updated = true;
} }
} elseif ($field == 'rules') { } elseif ($field == 'rules') {

View File

@ -90,7 +90,7 @@ class FramaDB {
} }
function updatePoll($poll) { function updatePoll($poll) {
$prepared = $this->prepare('UPDATE `' . Utils::table('poll') . '` SET title=?, admin_name=?, admin_mail=?, description=?, end_date=FROM_UNIXTIME(?), active=?, editable=? WHERE id = ?'); $prepared = $this->prepare('UPDATE `' . Utils::table('poll') . '` SET title=?, admin_name=?, admin_mail=?, description=?, end_date=?, active=?, editable=? WHERE id = ?');
return $prepared->execute([$poll->title, $poll->admin_name, $poll->admin_mail, $poll->description, $poll->end_date, $poll->active, $poll->editable, $poll->id]); return $prepared->execute([$poll->title, $poll->admin_name, $poll->admin_mail, $poll->description, $poll->end_date, $poll->active, $poll->editable, $poll->id]);
} }

View File

@ -80,8 +80,8 @@
{if $admin && !$expired} {if $admin && !$expired}
<div class="hidden js-desc text-right"> <div class="hidden js-desc text-right">
<label class="sr-only" for="newdescription">{_('Description')}</label> <label class="sr-only" for="newdescription">{_('Description')}</label>
<textarea class="form-control" id="newdescription" name="comment" rows="2" cols="40">{$poll->description|html}</textarea> <textarea class="form-control" id="newdescription" name="description" rows="2" cols="40">{$poll->description|html}</textarea>
<button type="submit" id="btn-new-desc" name="update_poll_info" value="comment" class="btn btn-sm btn-success" title="{_('Save the description')}"><span class="glyphicon glyphicon-ok"></span><span class="sr-only">{_('Save')}</span></button> <button type="submit" id="btn-new-desc" name="update_poll_info" value="description" class="btn btn-sm btn-success" title="{_('Save the description')}"><span class="glyphicon glyphicon-ok"></span><span class="sr-only">{_('Save')}</span></button>
<button class="btn btn-default btn-sm btn-cancel" title="{_('Cancel the description edit')}"><span class="glyphicon glyphicon-remove"></span><span class="sr-only">{_('Cancel')}</span></button> <button class="btn btn-default btn-sm btn-cancel" title="{_('Cancel the description edit')}"><span class="glyphicon glyphicon-remove"></span><span class="sr-only">{_('Cancel')}</span></button>
</div> </div>
{/if} {/if}