Added option of poll with hidden results.
This commit is contained in:
parent
a3f5763edd
commit
0c2ba20bfa
@ -21,6 +21,7 @@ use Framadate\Migration\From_0_0_to_0_8_Migration;
|
||||
use Framadate\Migration\From_0_8_to_0_9_Migration;
|
||||
use Framadate\Migration\AddColumn_receiveNewComments_For_0_9;
|
||||
use Framadate\Migration\AddColumn_uniqId_In_vote_For_0_9;
|
||||
use Framadate\Migration\AddColumn_hidden_In_poll_For_0_9;
|
||||
use Framadate\Migration\Migration;
|
||||
use Framadate\Utils;
|
||||
|
||||
@ -33,7 +34,8 @@ $migrations = [
|
||||
new From_0_0_to_0_8_Migration(),
|
||||
new From_0_8_to_0_9_Migration(),
|
||||
new AddColumn_receiveNewComments_For_0_9(),
|
||||
new AddColumn_uniqId_In_vote_For_0_9()
|
||||
new AddColumn_uniqId_In_vote_For_0_9(),
|
||||
new AddColumn_hidden_In_poll_For_0_9(),
|
||||
];
|
||||
// ---------------------------------------
|
||||
|
||||
|
@ -47,6 +47,12 @@ class Form
|
||||
*/
|
||||
public $receiveNewComments;
|
||||
|
||||
/**
|
||||
* If true, only the poll maker can see the poll's results
|
||||
* @var boolean
|
||||
*/
|
||||
public $hidden;
|
||||
|
||||
/**
|
||||
* List of available choices
|
||||
*/
|
||||
|
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* This software is governed by the CeCILL-B license. If a copy of this license
|
||||
* is not distributed with this file, you can obtain one at
|
||||
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
|
||||
*
|
||||
* Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
|
||||
* Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft)
|
||||
*
|
||||
* =============================
|
||||
*
|
||||
* Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence
|
||||
* ne se trouve pas avec ce fichier vous pouvez l'obtenir sur
|
||||
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
|
||||
*
|
||||
* Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
|
||||
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
||||
*/
|
||||
namespace Framadate\Migration;
|
||||
|
||||
use Framadate\Utils;
|
||||
|
||||
/**
|
||||
* This migration adds the field hidden on the poll table.
|
||||
*
|
||||
* @package Framadate\Migration
|
||||
* @version 0.9
|
||||
*/
|
||||
class AddColumn_hidden_In_poll_For_0_9 implements Migration {
|
||||
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should describe in english what is the purpose of the migration class.
|
||||
*
|
||||
* @return string The description of the migration class
|
||||
*/
|
||||
function description() {
|
||||
return "Add column \"hidden\" in table \"vote\" for version 0.9";
|
||||
}
|
||||
|
||||
/**
|
||||
* This method could check if the execute method should be called.
|
||||
* It is called before the execute method.
|
||||
*
|
||||
* @param \PDO $pdo The connection to database
|
||||
* @return bool true is the Migration should be executed.
|
||||
*/
|
||||
function preCondition(\PDO $pdo) {
|
||||
$stmt = $pdo->query('SHOW TABLES');
|
||||
$tables = $stmt->fetchAll(\PDO::FETCH_COLUMN);
|
||||
|
||||
// Check if tables of v0.9 are presents
|
||||
$diff = array_diff([Utils::table('poll'), Utils::table('slot'), Utils::table('vote'), Utils::table('comment')], $tables);
|
||||
return count($diff) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This methode is called only one time in the migration page.
|
||||
*
|
||||
* @param \PDO $pdo The connection to database
|
||||
* @return bool true is the execution succeeded
|
||||
*/
|
||||
function execute(\PDO $pdo) {
|
||||
$this->alterPollTable($pdo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function alterPollTable(\PDO $pdo) {
|
||||
$pdo->exec('
|
||||
ALTER TABLE `' . Utils::table('poll') . '`
|
||||
ADD `hidden` TINYINT( 1 ) NOT NULL DEFAULT "0"');
|
||||
}
|
||||
|
||||
}
|
@ -49,6 +49,7 @@ $description = filter_input(INPUT_POST, 'description', FILTER_SANITIZE_STRING);
|
||||
$editable = filter_input(INPUT_POST, 'editable', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => EDITABLE_CHOICE_REGEX]]);
|
||||
$receiveNewVotes = filter_input(INPUT_POST, 'receiveNewVotes', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
|
||||
$receiveNewComments = filter_input(INPUT_POST, 'receiveNewComments', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
|
||||
$hidden = filter_input(INPUT_POST, 'hidden', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
|
||||
|
||||
|
||||
// On initialise <20>galement les autres variables
|
||||
@ -57,7 +58,7 @@ $error_on_title = false;
|
||||
$error_on_name = false;
|
||||
$error_on_description = false;
|
||||
|
||||
//
|
||||
|
||||
if (!empty($_POST[GO_TO_STEP_2])) {
|
||||
$_SESSION['form']->title = $title;
|
||||
$_SESSION['form']->admin_name = $name;
|
||||
@ -66,6 +67,7 @@ if (!empty($_POST[GO_TO_STEP_2])) {
|
||||
$_SESSION['form']->editable = $editable;
|
||||
$_SESSION['form']->receiveNewVotes = ($receiveNewVotes !== null);
|
||||
$_SESSION['form']->receiveNewComments = ($receiveNewComments !== null);
|
||||
$_SESSION['form']->hidden = ($hidden !== null);
|
||||
|
||||
if ($config['use_smtp'] == true) {
|
||||
if (empty($mail)) {
|
||||
@ -175,15 +177,6 @@ if (!empty($_POST[GO_TO_STEP_2])) {
|
||||
}
|
||||
}
|
||||
|
||||
// Checkbox checked ?
|
||||
if ($_SESSION['form']->receiveNewVotes) {
|
||||
$receiveNewVotes = 'checked';
|
||||
}
|
||||
|
||||
if ($_SESSION['form']->receiveNewComments) {
|
||||
$receiveNewComments = 'checked';
|
||||
}
|
||||
|
||||
$useRemoteUser = USE_REMOTE_USER && isset($_SERVER['REMOTE_USER']);
|
||||
|
||||
$smarty->assign('title', $title);
|
||||
@ -200,6 +193,7 @@ $smarty->assign('poll_mail', Utils::fromPostOrDefault('mail', $_SESSION['form']-
|
||||
$smarty->assign('poll_editable', Utils::fromPostOrDefault('editable', $_SESSION['form']->editable));
|
||||
$smarty->assign('poll_receiveNewVotes', Utils::fromPostOrDefault('receiveNewVotes', $_SESSION['form']->receiveNewVotes));
|
||||
$smarty->assign('poll_receiveNewComments', Utils::fromPostOrDefault('receiveNewComments', $_SESSION['form']->receiveNewComments));
|
||||
$smarty->assign('poll_hidden', Utils::fromPostOrDefault('hidden', $_SESSION['form']->hidden));
|
||||
$smarty->assign('form', $_SESSION['form']);
|
||||
|
||||
$smarty->display('create_poll.tpl');
|
||||
|
54
js/app/create_poll.js
Normal file
54
js/app/create_poll.js
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* This software is governed by the CeCILL-B license. If a copy of this license
|
||||
* is not distributed with this file, you can obtain one at
|
||||
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
|
||||
*
|
||||
* Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
|
||||
* Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft)
|
||||
*
|
||||
* =============================
|
||||
*
|
||||
* Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence
|
||||
* ne se trouve pas avec ce fichier vous pouvez l'obtenir sur
|
||||
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
|
||||
*
|
||||
* Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
|
||||
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$("#formulaire").submit(function (event) {
|
||||
var isHidden = $("#hidden").prop('checked');
|
||||
var isOptionAllUserCanModifyEverything = $("#editableByAll").is(":checked");
|
||||
|
||||
if (isHidden && isOptionAllUserCanModifyEverything) {
|
||||
event.preventDefault();
|
||||
$("#hiddenWithBadEditionModeError").removeClass("hidden");
|
||||
} else {
|
||||
$("#hiddenWithBadEditionModeError").addClass("hidden");
|
||||
}
|
||||
});
|
||||
|
||||
// Check cookies are enabled too
|
||||
var cookieEnabled = function () {
|
||||
var cookieEnabled = navigator.cookieEnabled;
|
||||
|
||||
// if not IE4+ nor NS6+
|
||||
if (!cookieEnabled && typeof navigator.cookieEnabled === "undefined") {
|
||||
document.cookie = "testcookie";
|
||||
cookieEnabled = document.cookie.indexOf("testcookie") != -1;
|
||||
}
|
||||
|
||||
return cookieEnabled;
|
||||
};
|
||||
|
||||
if (cookieEnabled()) {
|
||||
// Show the form block
|
||||
document.getElementById("form-block").setAttribute("style", "");
|
||||
} else {
|
||||
// Show the warning about cookies
|
||||
document.getElementById("cookie-warning").setAttribute("style", "");
|
||||
}
|
||||
|
||||
});
|
@ -193,6 +193,7 @@
|
||||
"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": {
|
||||
@ -302,5 +303,6 @@
|
||||
"Failed to save poll": "Fehlgeschlagen Umfrage sparen",
|
||||
"Update vote failed": "Update vote failed",
|
||||
"Adding vote failed": "Adding vote failed"
|
||||
"You can't create a poll with hidden results with the following edition option : ": "DE_Vous ne pouvez pas créer de sondage avec résulats cachés avec les options d'éditions suivantes : "
|
||||
}
|
||||
}
|
@ -194,6 +194,7 @@
|
||||
"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": {
|
||||
@ -302,6 +303,7 @@
|
||||
"Framadate is not properly installed, please check the \"INSTALL\" to setup the database before continuing.": "Framadate is not properly installed, please check the 'INSTALL' to setup the database before continuing.",
|
||||
"Failed to save poll": "Failed to save poll",
|
||||
"Update vote failed": "Update vote failed",
|
||||
"Adding vote failed": "Adding vote failed"
|
||||
"Adding vote failed": "Adding vote 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 : "
|
||||
}
|
||||
}
|
@ -193,6 +193,7 @@
|
||||
"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": {
|
||||
@ -301,6 +302,7 @@
|
||||
"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",
|
||||
"Update vote failed": "ES_Mise à jour du vote échoué",
|
||||
"Adding vote failed": "ES_Ajout d'un vote échoué"
|
||||
"Adding vote failed": "ES_Ajout d'un vote é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 : "
|
||||
}
|
||||
}
|
@ -193,6 +193,7 @@
|
||||
"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": {
|
||||
@ -301,6 +302,7 @@
|
||||
"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",
|
||||
"Update vote failed": "Mise à jour du vote échoué",
|
||||
"Adding vote failed": "Ajout d'un vote échoué"
|
||||
"Adding vote failed": "Ajout d'un vote é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 : "
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
{extends file='page.tpl'}
|
||||
|
||||
{block name="header"}
|
||||
<script src="{"js/app/create_poll.js"|resource}" type="text/javascript"></script>
|
||||
{/block}
|
||||
|
||||
{block name=main}
|
||||
<div class="row" style="display:none" id="form-block">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
@ -96,7 +100,7 @@
|
||||
{__('Step 1', 'Votes cannot be modified.')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio" name="editable" {if $poll_editable==constant("Framadate\Editable::EDITABLE_BY_ALL")}checked{/if} value="{constant("Framadate\Editable::EDITABLE_BY_ALL")}">
|
||||
<input type="radio" name="editable" id="editableByAll" {if $poll_editable==constant("Framadate\Editable::EDITABLE_BY_ALL")}checked{/if} value="{constant("Framadate\Editable::EDITABLE_BY_ALL")}">
|
||||
{__('Step 1', 'All voters can modify any vote.')}
|
||||
</label>
|
||||
<label>
|
||||
@ -113,7 +117,7 @@
|
||||
<div class="col-sm-offset-4 col-sm-8">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type=checkbox name="receiveNewVotes" {if $poll_receiveNewVotes}checked{/if}
|
||||
<input type="checkbox" name="receiveNewVotes" {if $poll_receiveNewVotes}checked{/if}
|
||||
id="receiveNewVotes">
|
||||
{__('Step 1', 'To receive an email for each new vote.')}
|
||||
</label>
|
||||
@ -124,13 +128,29 @@
|
||||
<div class="col-sm-offset-4 col-sm-8">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type=checkbox name="receiveNewComments" {if $poll_receiveNewComments}checked{/if}
|
||||
<input type="checkbox" name="receiveNewComments" {if $poll_receiveNewComments}checked{/if}
|
||||
id="receiveNewComments">
|
||||
{__('Step 1', 'To receive an email for each new comment.')}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-4 col-sm-8">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="hidden" {if $poll_hidden}checked{/if}
|
||||
id="hidden">
|
||||
{__('Step 1', "Only the poll maker can see the poll's results.")}
|
||||
</label>
|
||||
</div>
|
||||
<div id="hiddenWithBadEditionModeError" class="alert alert-danger hidden">
|
||||
<p>
|
||||
{__('Error', "You can't create a poll with hidden results with the following edition option : ")}"{__('Step 1', 'All voters can modify any vote.')}"
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
@ -158,30 +178,4 @@
|
||||
<div id="cookie-warning" class="alert alert-danger" style="display:none">
|
||||
{__('Step 1', 'Cookies are disabled on your browser. Theirs activation is required to create a poll.')}
|
||||
</div>
|
||||
<script>
|
||||
{* TODO Put this in a JS file *}
|
||||
// Check Javascript is enabled, if it is it will execute this script
|
||||
(function () {
|
||||
// Check cookies are enabled too
|
||||
var cookieEnabled = function () {
|
||||
var cookieEnabled = navigator.cookieEnabled;
|
||||
|
||||
// if not IE4+ nor NS6+
|
||||
if (!cookieEnabled && typeof navigator.cookieEnabled === "undefined") {
|
||||
document.cookie = "testcookie";
|
||||
cookieEnabled = document.cookie.indexOf("testcookie") != -1;
|
||||
}
|
||||
|
||||
return cookieEnabled;
|
||||
};
|
||||
|
||||
if (cookieEnabled()) {
|
||||
// Show the form block
|
||||
document.getElementById("form-block").setAttribute("style", "");
|
||||
} else {
|
||||
// Show the warning about cookies
|
||||
document.getElementById("cookie-warning").setAttribute("style", "");
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
{/block}
|
Loading…
Reference in New Issue
Block a user