A big part of refactoring
* Use Smarty to split View and Controller on studs page (work in progress) * Add field "active" to Poll * And some other stuff...
This commit is contained in:
parent
3743ad55f1
commit
fcaea63b84
4
.gitignore
vendored
4
.gitignore
vendored
@ -8,3 +8,7 @@ framanav
|
||||
nav
|
||||
app/inc/constants.php
|
||||
vendor
|
||||
.settings/
|
||||
.project
|
||||
cache/
|
||||
tpl_c/
|
||||
|
131
adminstuds.php
131
adminstuds.php
@ -29,10 +29,6 @@ if (file_exists('bandeaux_local.php')) {
|
||||
include_once('bandeaux.php');
|
||||
}
|
||||
|
||||
// Initialisation des variables
|
||||
$numsondageadmin = false;
|
||||
$sondage = false;
|
||||
|
||||
// recuperation du numero de sondage admin (24 car.) dans l'URL
|
||||
if (!empty($_GET['sondage']) && is_string($_GET['sondage']) && strlen($_GET['sondage']) === 24) {
|
||||
$admin_poll_id = $_GET["sondage"];
|
||||
@ -45,7 +41,7 @@ if (preg_match(";[\w\d]{24};i", $admin_poll_id)) {
|
||||
$prepared->execute(array($admin_poll_id));
|
||||
$poll = $prepared->fetch();
|
||||
$prepared->closeCursor();
|
||||
|
||||
|
||||
$prepared = $connect->prepare('SELECT * FROM sujet_studs WHERE id_sondage = ?');
|
||||
$prepared->execute(array($poll_id));
|
||||
$sujets = $prepared->fetchAll();
|
||||
@ -79,14 +75,14 @@ $smtp_allowed = $config['use_smtp'];
|
||||
function send_mail_admin() {
|
||||
global $email_admin;
|
||||
global $poll_title;
|
||||
global $numsondageadmin;
|
||||
global $admin_poll_id;
|
||||
global $smtp_allowed;
|
||||
if($smtp_allowed==true){
|
||||
if(!isset($_SESSION['mail_admin_sent'])) {
|
||||
Utils::sendEmail( $email_admin,
|
||||
_("[ADMINISTRATOR] New settings for your poll") . ' ' . stripslashes( $poll_title ),
|
||||
_("You have changed the settings of your poll. \nYou can modify this poll with this link") .
|
||||
" :\n\n" . Utils::getUrlSondage($numsondageadmin, true) . "\n\n" .
|
||||
" :\n\n" . Utils::getUrlSondage($admin_poll_id, true) . "\n\n" .
|
||||
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION
|
||||
);
|
||||
$_SESSION["mail_admin_sent"]=true;
|
||||
@ -106,7 +102,7 @@ if (isset($_POST["boutonnouveautitre"])) {
|
||||
$sql = $connect->Prepare($sql);
|
||||
|
||||
//Email sent to the admin
|
||||
if ($connect->Execute($sql, array($nouveautitre, $numsondage))) {
|
||||
if ($connect->Execute($sql, array($nouveautitre, $poll_id))) {
|
||||
send_mail_admin();
|
||||
}
|
||||
}
|
||||
@ -124,7 +120,7 @@ if (isset($_POST['boutonnouveauxcommentaires'])) {
|
||||
$prepared->execute(array($commentaires, $poll_id));
|
||||
|
||||
//Email sent to the admin
|
||||
if ($connect->Execute($sql, array($commentaires, $numsondage))) {
|
||||
if ($connect->Execute($sql, array($commentaires, $poll_id))) {
|
||||
send_mail_admin();
|
||||
}
|
||||
}
|
||||
@ -176,7 +172,7 @@ if (isset($_POST["btn_poll_rules"])) {
|
||||
// $dsondage= $sondage->FetchObject(false);
|
||||
|
||||
if (isset($_POST['ajoutsujet'])) {
|
||||
Utils::print_header( _('Add a column') .' - ' . stripslashes( $poll->title));
|
||||
Utils::print_header( _('Add a column') .' - ' . stripslashes($poll->title));
|
||||
|
||||
bandeau_titre(_('Make your polls'));
|
||||
|
||||
@ -185,10 +181,10 @@ if (isset($_POST['ajoutsujet'])) {
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-md-offset-3">
|
||||
<form name="formulaire" class="form-horizontal" action="' . Utils::getUrlSondage($numsondageadmin, true) . '" method="POST">
|
||||
<form name="formulaire" class="form-horizontal" action="' . Utils::getUrlSondage($admin_poll_id, true) . '" method="POST">
|
||||
<h2>' . _("Column's adding") . '</h2>'."\n";
|
||||
|
||||
if (substr($dsondage->format, 0, 1)=="A"){
|
||||
if ($poll->format == "A"){
|
||||
echo '
|
||||
<div class="form-group">
|
||||
<label for="nouvellecolonne" class="col-md-6">' . _("Add a column") .' :</label>
|
||||
@ -197,7 +193,7 @@ if (isset($_POST['ajoutsujet'])) {
|
||||
</div>
|
||||
</div>'."\n";
|
||||
} else {
|
||||
//ajout d'une date avec creneau horaire
|
||||
// ajout d'une date avec creneau horaire
|
||||
echo '
|
||||
<p>'. _("You can add a new scheduling date to your poll.").'<br />'._("If you just want to add a new hour to an existant date, put the same date and choose a new hour.") .'</p>
|
||||
|
||||
@ -233,12 +229,12 @@ if (isset($_POST['ajoutsujet'])) {
|
||||
}
|
||||
|
||||
if (isset($_POST["suppressionsondage"])) {
|
||||
Utils::print_header( _("Confirm removal of your poll") .' - ' . stripslashes( $dsondage->titre ));
|
||||
Utils::print_header( _("Confirm removal of your poll") .' - ' . stripslashes( $dsondage->title ));
|
||||
|
||||
bandeau_titre(_("Confirm removal of your poll"));
|
||||
|
||||
echo '
|
||||
<form name="formulaire" action="' . Utils::getUrlSondage($numsondageadmin, true) . '" method="POST">
|
||||
<form name="formulaire" action="' . Utils::getUrlSondage($admin_poll_id, true) . '" method="POST">
|
||||
<div class="alert alert-warning text-center">
|
||||
<h2>' . _("Confirm removal of your poll") . '</h2>
|
||||
<p><button class="btn btn-default" type="submit" value="" name="annullesuppression">'._("Keep this poll!").'</button>
|
||||
@ -255,14 +251,14 @@ if (isset($_POST["suppressionsondage"])) {
|
||||
if (isset($_POST['removecomments'])) {
|
||||
$sql = 'DELETE FROM comments WHERE id_sondage='.$connect->Param('numsondage');
|
||||
$sql = $connect->Prepare($sql);
|
||||
$cleaning = $connect->Execute($sql, array($numsondage));
|
||||
$cleaning = $connect->Execute($sql, array($poll_id));
|
||||
}
|
||||
|
||||
// Remove all the votes
|
||||
if (isset($_POST["removevotes"])) {
|
||||
$sql = 'DELETE FROM user_studs WHERE id_sondage='.$connect->Param('numsondage');
|
||||
$sql = $connect->Prepare($sql);
|
||||
$cleaning = $connect->Execute($sql, array($numsondage));
|
||||
$cleaning = $connect->Execute($sql, array($poll_id));
|
||||
}
|
||||
|
||||
//action si bouton confirmation de suppression est activé
|
||||
@ -270,7 +266,7 @@ if (isset($_POST["confirmesuppression"])) {
|
||||
$nbuser=$user_studs->RecordCount();
|
||||
$date=date('H:i:s d/m/Y:');
|
||||
|
||||
if (Utils::remove_sondage($connect, $numsondage)) {
|
||||
if (Utils::remove_sondage($connect, $poll_id)) {
|
||||
// on ecrit dans le fichier de logs la suppression du sondage
|
||||
error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\n", 3, 'admin/logs_studs.txt');
|
||||
|
||||
@ -313,7 +309,7 @@ if (isset($_POST['ajoutcomment'])) {
|
||||
$comment_doublon = false;
|
||||
$req = 'SELECT * FROM comments WHERE id_sondage='.$connect->Param('numsondage').' ORDER BY id_comment';
|
||||
$sql = $connect->Prepare($req);
|
||||
$comment_user_doublon = $connect->Execute($sql, array($numsondage));
|
||||
$comment_user_doublon = $connect->Execute($sql, array($poll_id));
|
||||
if ($comment_user_doublon->RecordCount() != 0) {
|
||||
while ( $dcomment_user_doublon=$comment_user_doublon->FetchNextObject(false)) {
|
||||
if($dcomment_user_doublon->comment == $comment && $dcomment_user_doublon->usercomment == $comment_user) {
|
||||
@ -329,7 +325,7 @@ if (isset($_POST['ajoutcomment'])) {
|
||||
$connect->Param('comment_user').')';
|
||||
$sql = $connect->Prepare($req);
|
||||
|
||||
$comments = $connect->Execute($sql, array($numsondage, $comment, $comment_user));
|
||||
$comments = $connect->Execute($sql, array($poll_id, $comment, $comment_user));
|
||||
if ($comments === false) {
|
||||
$err |= COMMENT_INSERT_FAILED;
|
||||
}
|
||||
@ -345,7 +341,7 @@ $nblignes = count($users);
|
||||
//action si le bouton participer est cliqué
|
||||
if (isset($_POST["boutonp"])) {
|
||||
//si on a un nom dans la case texte
|
||||
if (Utils::issetAndNoEmpty('nom')){
|
||||
if (!empty($_POST['nom'])){
|
||||
$nouveauchoix = '';
|
||||
$erreur_prenom = false;
|
||||
|
||||
@ -376,14 +372,14 @@ if (isset($_POST["boutonp"])) {
|
||||
$connect->Param('nouveauchoix').')';
|
||||
|
||||
$sql = $connect->Prepare($sql);
|
||||
$connect->Execute($sql, array($nom, $numsondage, $nouveauchoix));
|
||||
$connect->Execute($sql, array($nom, $poll_id, $nouveauchoix));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//action quand on ajoute une colonne au format AUTRE
|
||||
if (isset($_POST["ajoutercolonne"]) && Utils::issetAndNoEmpty('nouvellecolonne') && (substr($dsondage->format, 0, 1) == "A" )) {
|
||||
if (isset($_POST["ajoutercolonne"]) && !empty($_POST['nouvellecolonne']) && $poll->format == "A") {
|
||||
$nouveauxsujets=$dsujet->sujet;
|
||||
|
||||
//on rajoute la valeur a la fin de tous les sujets deja entrés
|
||||
@ -394,24 +390,32 @@ if (isset($_POST["ajoutercolonne"]) && Utils::issetAndNoEmpty('nouvellecolonne')
|
||||
//mise a jour avec les nouveaux sujets dans la base
|
||||
$sql = 'UPDATE sujet_studs SET sujet = '.$connect->Param('nouveauxsujets').' WHERE id_sondage = '.$connect->Param('numsondage');
|
||||
$sql = $connect->Prepare($sql);
|
||||
if ($connect->Execute($sql, array($nouveauxsujets, $numsondage))) {
|
||||
if ($connect->Execute($sql, array($nouveauxsujets, $poll_id))) {
|
||||
send_mail_admin();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//action quand on ajoute une colonne au format DATE
|
||||
if (isset($_POST["ajoutercolonne"]) && (substr($dsondage->format, 0, 1) == "D")) {
|
||||
$nouveauxsujets=$dsujet->sujet;
|
||||
// [begin] action quand on ajoute une colonne au format DATE
|
||||
if (isset($_POST['ajoutercolonne']) && $dsondage->format == 'D') {
|
||||
|
||||
if (isset($_POST["newdate"]) && $_POST["newdate"] != "vide") {
|
||||
$nouvelledate=mktime(0, 0, 0, substr($_POST["newdate"],3,2), substr($_POST["newdate"],0,2), substr($_POST["newdate"],6,4));
|
||||
if (!empty($_POST["newdate"])) {
|
||||
$new_choice = mktime(0, 0, 0, substr($_POST["newdate"],3,2), substr($_POST["newdate"],0,2), substr($_POST["newdate"],6,4));
|
||||
|
||||
if (isset($_POST["newhour"]) && $_POST["newhour"]!="vide"){
|
||||
$nouvelledate.="@";
|
||||
$nouvelledate.=$_POST["newhour"];
|
||||
if (!empty($_POST["newhour"])){
|
||||
$new_choice .= '@' . $_POST["newhour"];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO OPZ Delete the code below
|
||||
// TODO OPZ Insert new choice
|
||||
// TODO OPZ Update users votes (add "0" in the right column^^)
|
||||
|
||||
|
||||
|
||||
//on rajoute la valeur dans les valeurs
|
||||
$datesbase = explode(",",$dsujet->sujet);
|
||||
$taillebase = sizeof($datesbase);
|
||||
@ -444,13 +448,13 @@ if (isset($_POST["ajoutercolonne"]) && (substr($dsondage->format, 0, 1) == "D"))
|
||||
//if (isset($erreur_ajout_date) && !$erreur_ajout_date){
|
||||
$sql = 'UPDATE sujet_studs SET sujet = '.$connect->Param('dateinsertion').' WHERE id_sondage = '.$connect->Param('numsondage');
|
||||
$sql = $connect->Prepare($sql);
|
||||
$connect->Execute($sql, array($dateinsertion, $numsondage));
|
||||
$connect->Execute($sql, array($dateinsertion, $poll_id));
|
||||
|
||||
if ($nouvelledate > strtotime($dsondage->date_fin)) {
|
||||
$date_fin=$nouvelledate+200000;
|
||||
$sql = 'UPDATE sondage SET date_fin = '.$connect->Param('date_fin').' WHERE id_sondage = '.$connect->Param('numsondage');
|
||||
$sql = $connect->Prepare($sql);
|
||||
$connect->Execute($sql, array($date_fin, $numsondage));
|
||||
$connect->Execute($sql, array($date_fin, $poll_id));
|
||||
}
|
||||
//}
|
||||
|
||||
@ -486,6 +490,7 @@ if (isset($_POST["ajoutercolonne"]) && (substr($dsondage->format, 0, 1) == "D"))
|
||||
$erreur_ajout_date="yes";
|
||||
}
|
||||
}
|
||||
// [end] action quand on ajoute une colonne au format DATE
|
||||
|
||||
|
||||
//suppression de ligne dans la base
|
||||
@ -508,7 +513,7 @@ for ($i = 0; $i < $nblignes; $i++) {
|
||||
// TODO OPZ Revoir toute cette partie suppression d'un commentaire utilisateur
|
||||
/*$sql = 'SELECT * FROM comments WHERE id_sondage='.$connect->Param('numsondage').' ORDER BY id_comment';
|
||||
$sql = $connect->Prepare($sql);
|
||||
$comment_user = $connect->Execute($sql, array($numsondage));
|
||||
$comment_user = $connect->Execute($sql, array($poll_id));
|
||||
$i = 0;
|
||||
while ($dcomment = $comment_user->FetchNextObject(false)) {
|
||||
if (isset($_POST['suppressioncomment'.$i])) {
|
||||
@ -571,17 +576,17 @@ if ($testmodifier) {
|
||||
//suppression de colonnes dans la base
|
||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
if ((isset($_POST["effacecolonne$i"])) && $nbcolonnes > 1){
|
||||
$toutsujet = explode(",",$dsujet->sujet);
|
||||
$sujets = explode(",",$dsujet->sujet);
|
||||
//sort($toutsujet, SORT_NUMERIC);
|
||||
$j = 0;
|
||||
$nouveauxsujets = '';
|
||||
|
||||
//parcours de tous les sujets actuels
|
||||
while (isset($toutsujet[$j])) {
|
||||
while (isset($sujets[$j])) {
|
||||
//si le sujet n'est pas celui qui a été effacé alors on concatene
|
||||
if ($i != $j) {
|
||||
$nouveauxsujets .= ',';
|
||||
$nouveauxsujets .= $toutsujet[$j];
|
||||
$nouveauxsujets .= $sujets[$j];
|
||||
}
|
||||
|
||||
$j++;
|
||||
@ -617,7 +622,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
//mise a jour des sujets dans la base
|
||||
$sql = 'UPDATE sujet_studs SET sujet = '.$connect->Param('nouveauxsujets').' WHERE id_sondage = '.$connect->Param('numsondage');
|
||||
$sql = $connect->Prepare($sql);
|
||||
$connect->Execute($sql, array($nouveauxsujets, $numsondage));
|
||||
$connect->Execute($sql, array($nouveauxsujets, $poll_id));
|
||||
}
|
||||
}
|
||||
|
||||
@ -625,16 +630,16 @@ for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
// TODO OPZ Déjà fait en début de fichier recuperation des donnes de la base
|
||||
/*$sql = 'SELECT * FROM sondage WHERE id_sondage_admin = '.$connect->Param('numsondageadmin');
|
||||
$sql = $connect->Prepare($sql);
|
||||
$sondage = $connect->Execute($sql, array($numsondageadmin));
|
||||
$sondage = $connect->Execute($sql, array($admin_poll_id));
|
||||
|
||||
if ($sondage !== false) {
|
||||
$sql = 'SELECT * FROM sujet_studs WHERE id_sondage = '.$connect->Param('numsondage');
|
||||
$sql = $connect->Prepare($sql);
|
||||
$sujets = $connect->Execute($sql, array($numsondage));
|
||||
$sujets = $connect->Execute($sql, array($poll_id));
|
||||
|
||||
$sql = 'SELECT * FROM user_studs WHERE id_sondage = '.$connect->Param('numsondage').' order by id_users';
|
||||
$sql = $connect->Prepare($sql);
|
||||
$user_studs = $connect->Execute($sql, array($numsondage));
|
||||
$user_studs = $connect->Execute($sql, array($poll_id));
|
||||
} else {
|
||||
|
||||
Utils::print_header(_("Error!"));
|
||||
@ -672,7 +677,7 @@ $description = (isset($_POST["nouveauxcommentaires"])) ? stripslashes(htmlentiti
|
||||
$email_admin = (isset($_POST["boutonnouvelleadresse"]) && !empty($_POST['nouvelleadresse'])) ? htmlentities(html_entity_decode($_POST['nouvelleadresse'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8') : stripslashes( $poll->admin_mail );
|
||||
|
||||
//Poll format (locked A-/D-, open A/D, editable A+/D+)
|
||||
$poll_rules = (isset($_POST["poll_rules"]) && !empty($_POST['btn_poll_rules'])) ? $_POST["poll_rules"] : substr($poll->format, 1, 1);
|
||||
$poll_rules = (isset($_POST["poll_rules"]) && !empty($_POST['btn_poll_rules'])) ? $_POST["poll_rules"] : substr($poll->format, 1, 1); // TODO OPZ Handle comment disabling
|
||||
$poll_rules_opt1 = '';$poll_rules_opt2 = '';$poll_rules_opt3 = '';
|
||||
if($poll->editable) {
|
||||
$poll_rules_text = '<span class="glyphicon glyphicon-edit"></span> '. _("Votes are editable");
|
||||
@ -699,7 +704,7 @@ if ($errors!='') {
|
||||
}
|
||||
|
||||
echo '
|
||||
<form name="formulaire4" action="' . Utils::getUrlSondage($numsondageadmin, true) . '" method="POST">
|
||||
<form name="formulaire4" action="' . Utils::getUrlSondage($admin_poll_id, true) . '" method="POST">
|
||||
<div class="jumbotron bg-danger">
|
||||
<div class="row">
|
||||
<div class="col-md-7" id="title-form">
|
||||
@ -770,7 +775,7 @@ echo '
|
||||
<input class="form-control" id="public-link" type="text" readonly="readonly" value="' . Utils::getUrlSondage($poll->poll_id) . '" />
|
||||
</div>
|
||||
<div class="form-group col-md-5">
|
||||
<label for="admin-link"><a class="admin-link" href="' . Utils::getUrlSondage($numsondageadmin, true) . '">'._("Admin link of the poll") .' <span class="btn-link glyphicon glyphicon-link"></span></a></label>
|
||||
<label for="admin-link"><a class="admin-link" href="' . Utils::getUrlSondage($admin_poll_id, true) . '">'._("Admin link of the poll") .' <span class="btn-link glyphicon glyphicon-link"></span></a></label>
|
||||
<input class="form-control" id="admin-link" type="text" readonly="readonly" value="' . Utils::getUrlSondage($admin_poll_id, true) . '" />
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
@ -802,15 +807,6 @@ echo '
|
||||
</div>
|
||||
</form>'."\n"; // .jumbotron
|
||||
|
||||
// TODO OPZ : Pourquoi ? on recupere les données et les sujets du sondage
|
||||
/*$dsujet=$sujets->FetchObject(false);
|
||||
$dsondage=$sondage->FetchObject(false);*/
|
||||
|
||||
// TODO OPZ : Déjà présent sous la bonne forme : reformatage des données des sujets du sondage
|
||||
/*$toutsujet=explode(",",$dsujet->sujet);
|
||||
$toutsujet=str_replace("°","'",$toutsujet);
|
||||
$nbcolonnes=substr_count($dsujet->sujet,',')+1;*/
|
||||
|
||||
// Table headers
|
||||
$thead = '<thead>';
|
||||
|
||||
@ -821,8 +817,8 @@ $border = array(); // bordure pour distinguer les mois
|
||||
$td_headers = array(); // for a11y, headers="M1 D4 H5" on each td
|
||||
$radio_title = array(); // date for
|
||||
|
||||
// Dates poll
|
||||
if (substr($poll->format, 0, 1)=="D") {
|
||||
// Display dates poll
|
||||
if ($poll->format == "D") {
|
||||
|
||||
$tr_months = '<tr><th role="presentation"></th>';
|
||||
$tr_days = '<tr><th role="presentation"></th>';
|
||||
@ -831,23 +827,22 @@ if (substr($poll->format, 0, 1)=="D") {
|
||||
// Headers
|
||||
$colspan_month = 1;
|
||||
$colspan_day = 1;
|
||||
|
||||
for ($i = 0; $i < count($sujets); $i++) {
|
||||
|
||||
foreach ($sujets as $i=>$sujet) {
|
||||
|
||||
// Current date
|
||||
$current = $toutsujet[$i];//format date@hour. ex : 2020292820@10:00
|
||||
$horoCur = explode("@",$current); //horoCur[0] = date, horoCur[1] = hour
|
||||
if (isset($toutsujet[$i+1])){
|
||||
$next = $toutsujet[$i+1];
|
||||
$horoNext = explode("@",$next);
|
||||
$horoCur = explode('@', $sujet->sujet); //horoCur[0] = date, horoCur[1] = hour
|
||||
if (isset($sujets[$i+1])){
|
||||
$next = $sujets[$i+1]->sujet;
|
||||
$horoNext = explode('@', $next);
|
||||
}
|
||||
$border[$i] = false;
|
||||
$radio_title[$i] = strftime($date_format['txt_short'],$horoCur[0]);
|
||||
$radio_title[$i] = strftime($date_format['txt_short'], $horoCur[0]);
|
||||
|
||||
// Months
|
||||
$td_headers[$i] = 'M'.($i+1-$colspan_month);
|
||||
|
||||
if (isset($toutsujet[$i+1]) && strftime("%B", $horoCur[0]) == strftime("%B", $horoNext[0]) && strftime("%Y", $horoCur[0]) == strftime("%Y", $horoNext[0])){
|
||||
if (isset($sujets[$i+1]) && strftime("%B", $horoCur[0]) == strftime("%B", $horoNext[0]) && strftime("%Y", $horoCur[0]) == strftime("%Y", $horoNext[0])){
|
||||
$colspan_month++;
|
||||
} else {
|
||||
$border[$i] = true;
|
||||
@ -858,7 +853,7 @@ if (substr($poll->format, 0, 1)=="D") {
|
||||
// Days
|
||||
$td_headers[$i] .= ' D'.($i+1-$colspan_day);
|
||||
|
||||
if (isset($toutsujet[$i+1]) && strftime($date_format['txt_day'],$horoCur[0])==strftime($date_format['txt_day'],$horoNext[0]) && strftime("%B",$horoCur[0])==strftime("%B",$horoNext[0])){
|
||||
if (isset($sujets[$i+1]) && strftime($date_format['txt_day'],$horoCur[0])==strftime($date_format['txt_day'],$horoNext[0]) && strftime("%B",$horoCur[0])==strftime("%B",$horoNext[0])){
|
||||
$colspan_day++;
|
||||
} else {
|
||||
$rbd = ($border[$i]) ? ' rbd' : '';
|
||||
@ -877,7 +872,7 @@ if (substr($poll->format, 0, 1)=="D") {
|
||||
}
|
||||
|
||||
// Remove col
|
||||
$tr_add_remove_col .= (count($toutsujet) > 2 ) ? '<td headers="'.$td_headers[$i].'"><button type="submit" name="effacecolonne'.$i.'" class="btn btn-link btn-sm" title="' . _('Remove the column') . ' ' .$radio_title[$i]. '"><span class="glyphicon glyphicon-remove text-danger"></span><span class="sr-only">'. _("Remove") .'</span></button></td>' : '<td role="presentation"></td>';
|
||||
$tr_add_remove_col .= (count($sujets) > 2 ) ? '<td headers="'.$td_headers[$i].'"><button type="submit" name="effacecolonne'.$i.'" class="btn btn-link btn-sm" title="' . _('Remove the column') . ' ' .$radio_title[$i]. '"><span class="glyphicon glyphicon-remove text-danger"></span><span class="sr-only">'. _("Remove") .'</span></button></td>' : '<td role="presentation"></td>';
|
||||
|
||||
}
|
||||
|
||||
@ -943,7 +938,7 @@ if (substr($poll->format, 0, 1)=="D") {
|
||||
|
||||
// Print headers
|
||||
echo '
|
||||
<form name="formulaire" action="' . Utils::getUrlSondage($numsondageadmin, true) . '" method="POST">
|
||||
<form name="formulaire" action="' . Utils::getUrlSondage($admin_poll_id, true) . '" method="POST">
|
||||
|
||||
<div class="alert alert-info">
|
||||
<p>' . _('As poll administrator, you can change all the lines of this poll with this button ').'<span class="glyphicon glyphicon-pencil"></span><span class="sr-only">' . _('Edit') . '</span>,
|
||||
|
@ -16,7 +16,7 @@ class Form
|
||||
* Tells if users can modify their choices.
|
||||
*/
|
||||
public $editable;
|
||||
|
||||
|
||||
/**
|
||||
* If true, notify poll administrator when new vote is made.
|
||||
*/
|
||||
@ -28,6 +28,7 @@ class Form
|
||||
private $choices;
|
||||
|
||||
public function __construct(){
|
||||
$this->editable = true;
|
||||
$this->clearChoices();
|
||||
}
|
||||
|
||||
|
@ -61,27 +61,27 @@ class FramaDB
|
||||
return $prepared->fetchAll();
|
||||
}
|
||||
|
||||
function allUsersByPollId($poll_id) {
|
||||
function allUserVotesByPollId($poll_id) {
|
||||
$prepared = $this->prepare('SELECT * FROM user_studs WHERE id_sondage = ? ORDER BY id_users');
|
||||
$prepared->execute(array($poll_id));
|
||||
return $prepared->fetchAll();
|
||||
}
|
||||
|
||||
function allSujetsByPollId($poll_id) {
|
||||
function allSlotsByPollId($poll_id) {
|
||||
$prepared = $this->prepare('SELECT * FROM sujet_studs WHERE id_sondage = ? ORDER BY sujet');
|
||||
$prepared->execute(array($poll_id));
|
||||
return $prepared->fetchAll();
|
||||
}
|
||||
|
||||
function insertVote($name, $poll_id, $choice) {
|
||||
function insertVote($name, $poll_id, $votes) {
|
||||
$prepared = $this->prepare('INSERT INTO user_studs (nom,id_sondage,reponses) VALUES (?,?,?)');
|
||||
$prepared->execute([$name, $poll_id, $choice]);
|
||||
$prepared->execute([$name, $poll_id, $votes]);
|
||||
|
||||
$newVote = new \stdClass();
|
||||
$newVote->id_sondage = $poll_id;
|
||||
$newVote->id_users = $this->pdo->lastInsertId();
|
||||
$newVote->nom = $name;
|
||||
$newVote->reponse = $choice;
|
||||
$newVote->reponse = $votes;
|
||||
|
||||
return $newVote;
|
||||
}
|
||||
|
@ -189,9 +189,9 @@ class Utils
|
||||
}
|
||||
} else {
|
||||
if ($admin === true) {
|
||||
$url = str_replace('/admin', '', self::get_server_name()) . 'adminstuds.php?sondage=' . $id;
|
||||
$url = str_replace('/admin', '', self::get_server_name()) . 'adminstuds.php?poll=' . $id;
|
||||
} else {
|
||||
$url = str_replace('/admin', '', self::get_server_name()) . 'studs.php?sondage=' . $id;
|
||||
$url = str_replace('/admin', '', self::get_server_name()) . 'studs.php?poll=' . $id;
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,12 +216,12 @@ class Utils
|
||||
|
||||
$prepared = $connect->prepare('DELETE FROM sondage WHERE poll_id = ?');
|
||||
$prepared->execute(array($poll_id));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static function cleaningOldPolls($log_txt) {
|
||||
global $connect;
|
||||
|
||||
|
||||
$resultSet = $connect->query('SELECT poll_id, format, admin_name FROM sondage WHERE end_date < NOW() LIMIT 20');
|
||||
$toClean = $resultSet->fetchAll(\PDO::FETCH_CLASS);
|
||||
|
||||
@ -233,7 +233,7 @@ class Utils
|
||||
}
|
||||
$connect->commit();
|
||||
}
|
||||
|
||||
|
||||
public static function debug($object)
|
||||
{
|
||||
echo '<pre>';
|
||||
|
@ -20,18 +20,40 @@
|
||||
if (ini_get('date.timezone') == '') {
|
||||
date_default_timezone_set('Europe/Paris');
|
||||
}
|
||||
include_once __DIR__ . '/constants.php';
|
||||
include_once __DIR__ . '/i18n.php';
|
||||
include_once __DIR__ . '/studs.inc.php';
|
||||
|
||||
// Autoloading of dependencies with Composer
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
include_once __DIR__ . '/constants.php';
|
||||
include_once __DIR__ . '/i18n.php';
|
||||
// Smarty
|
||||
require_once __DIR__ . '/../../vendor/smarty/smarty/libs/Smarty.class.php';
|
||||
$smarty = new \Smarty();
|
||||
$smarty->template_dir = 'tpl/';
|
||||
$smarty->compile_dir = 'tpl_c/';
|
||||
$smarty->cache_dir = 'cache/';
|
||||
$smarty->caching = false;
|
||||
|
||||
$smarty->assign('APPLICATION_NAME', NOMAPPLICATION);
|
||||
$smarty->assign('SERVER_URL', \Framadate\Utils::get_server_name());
|
||||
$smarty->assign('TITLE_IMAGE', IMAGE_TITRE);
|
||||
$smarty->assign('use_nav_js', file_exists($_SERVER['DOCUMENT_ROOT'] . '/nav/nav.js'));
|
||||
$smarty->assign('lang', $lang);
|
||||
$smarty->assign('langs', $ALLOWED_LANGUAGES);
|
||||
$smarty->assign('day_format', $date_format['txt_day']);
|
||||
|
||||
function smarty_modifier_poll_url($poll_id, $admin=false){return \Framadate\Utils::getUrlSondage($poll_id, $admin);}
|
||||
//$smarty->registerPlugin('modifier', 'poll_url', 'sqqmarty_modifier_poll_url');
|
||||
// End- Smarty
|
||||
|
||||
|
||||
use Framadate\FramaDB;
|
||||
use Framadate\Form;
|
||||
use Framadate\Choice;
|
||||
use Framadate\Utils;
|
||||
|
||||
if (session_id() == "") {
|
||||
if (session_id() == '') {
|
||||
session_start();
|
||||
}
|
||||
|
||||
|
10
app/inc/studs.inc.php
Normal file
10
app/inc/studs.inc.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
function countStuds($subjects)
|
||||
{
|
||||
$nb = 0;
|
||||
foreach($subjects as $subject) {
|
||||
$nb += substr_count($subject->sujet, ',')+1;
|
||||
}
|
||||
return $nb;
|
||||
}
|
@ -39,13 +39,13 @@ if (!isset($_SESSION['form']->titre) || !isset($_SESSION['form']->nom) || (($con
|
||||
<h3>' . _("You haven't filled the first section of the poll creation.") . ' !</h3>
|
||||
<p>' . _("Back to the homepage of ") . ' ' . '<a href="' . Utils::get_server_name() . '">' . NOMAPPLICATION . '</a>.</p>
|
||||
</div>';
|
||||
|
||||
|
||||
|
||||
bandeau_pied();
|
||||
|
||||
} else {
|
||||
// Step 4 : Data prepare before insert in DB
|
||||
if (Utils::issetAndNoEmpty('confirmation')) {
|
||||
if (!empty($_POST['confirmation'])) {
|
||||
|
||||
// Define expiration date
|
||||
if (!empty($_POST['champdatefin']))
|
||||
@ -59,14 +59,14 @@ if (!isset($_SESSION['form']->titre) || !isset($_SESSION['form']->nom) || (($con
|
||||
$_SESSION['form']->champdatefin=$time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(empty($_SESSION['form']->champdatefin))
|
||||
{
|
||||
// By default, expiration date is 6 months after last day
|
||||
$_SESSION['form']->champdatefin=end($temp_results)+(86400 * $config['default_poll_duration']);
|
||||
}
|
||||
|
||||
|
||||
// Insert poll in database
|
||||
$admin_poll_id = ajouter_sondage(
|
||||
$_SESSION['form']->titre,
|
||||
@ -79,27 +79,27 @@ if (!isset($_SESSION['form']->titre) || !isset($_SESSION['form']->nom) || (($con
|
||||
$_SESSION['form']->receiveNewVotes,
|
||||
$_SESSION['form']->getChoices()
|
||||
);
|
||||
|
||||
|
||||
// Clean Form data in $_SESSION
|
||||
unset($_SESSION['form']);
|
||||
|
||||
// Delete old polls
|
||||
Utils::cleaningOldPolls($connect, 'admin/logs_studs.txt');
|
||||
|
||||
|
||||
// Redirect to poll administration
|
||||
header('Location:' . Utils::getUrlSondage($admin_poll_id, true));
|
||||
exit;
|
||||
|
||||
} else {
|
||||
|
||||
if (Utils::issetAndNoEmpty('days')) {
|
||||
|
||||
|
||||
if (!empty($_POST['days'])) {
|
||||
|
||||
// Clear previous choices
|
||||
$_SESSION['form']->clearChoices();
|
||||
|
||||
for ($i = 0; $i < count($_POST['days']); $i++) {
|
||||
$day = $_POST['days'][$i];
|
||||
|
||||
|
||||
if (!empty($day)) {
|
||||
// Add choice to Form data
|
||||
$time = mktime(0, 0, 0, substr($_POST["days"][$i],3,2),substr($_POST["days"][$i],0,2),substr($_POST["days"][$i],6,4));
|
||||
@ -121,7 +121,7 @@ if (!isset($_SESSION['form']->titre) || !isset($_SESSION['form']->nom) || (($con
|
||||
$_SESSION['form']->formatsondage = 'D';
|
||||
|
||||
// Step 3/4 : Confirm poll creation
|
||||
if (Utils::issetAndNoEmpty('choixheures') && !isset($_SESSION['form']->totalchoixjour)) {
|
||||
if (!empty($_POST['choixheures']) && !isset($_SESSION['form']->totalchoixjour)) {
|
||||
|
||||
Utils::print_header ( _("Removal date and confirmation (3 on 3)") );
|
||||
bandeau_titre(_("Removal date and confirmation (3 on 3)"));
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"require": {
|
||||
"adodb/adodb-php": "5.19"
|
||||
"smarty/smarty": "3.1.21"
|
||||
},
|
||||
|
||||
"autoload": {
|
||||
|
@ -41,12 +41,12 @@ function random($car)
|
||||
function ajouter_sondage($title, $comment, $adminName, $adminMail, $format, $editable, $endDate, $receiveNewVotes, $choices)
|
||||
{
|
||||
global $connect;
|
||||
global $config;
|
||||
|
||||
global $config;
|
||||
|
||||
// Generate poll ids
|
||||
$poll_id = random(16);
|
||||
$admin_poll_id = $poll_id.random(8);
|
||||
|
||||
|
||||
// Insert poll + slots
|
||||
$connect->beginTransaction();
|
||||
|
||||
@ -58,20 +58,33 @@ function ajouter_sondage($title, $comment, $adminName, $adminMail, $format, $edi
|
||||
|
||||
$prepared = $connect->prepare('INSERT INTO sujet_studs (id_sondage, sujet) VALUES (?, ?)');
|
||||
foreach ($choices as $choice) {
|
||||
|
||||
// We prepared the slots (joined by comas)
|
||||
$joinedSlots = '';
|
||||
$first = true;
|
||||
foreach ($choice->getSlots() as $slot) {
|
||||
if ($first) {
|
||||
$joinedSlots = $slot;
|
||||
$first = false;
|
||||
|
||||
// We prepared the slots (joined by comas)
|
||||
$joinedSlots = '';
|
||||
$first = true;
|
||||
foreach ($choice->getSlots() as $slot) {
|
||||
if ($first) {
|
||||
$joinedSlots = $slot;
|
||||
$first = false;
|
||||
} else {
|
||||
$joinedSlots .= ',' . $slot;
|
||||
}
|
||||
}
|
||||
|
||||
// We execute the insertion
|
||||
if (empty($joinedSlots)) {
|
||||
$prepared->execute(array($poll_id, $choice->getName()));
|
||||
} else {
|
||||
$joinedSlots .= ',' . $slot;
|
||||
$prepared->execute(array($poll_id, $choice->getName().'@'.$joinedSlots));
|
||||
}
|
||||
|
||||
}
|
||||
if (empty($joinedSlots)) {
|
||||
$prepared->execute(array($poll_id, $choice->getName()));
|
||||
} else {
|
||||
$prepared->execute(array($poll_id, $choice->getName().'@'.$joinedSlots));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$connect->commit();
|
||||
@ -94,7 +107,7 @@ function ajouter_sondage($title, $comment, $adminName, $adminMail, $format, $edi
|
||||
Utils::sendEmail( $adminMail, "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($title,ENT_QUOTES)), $message, $_SESSION['adresse'] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
error_log(date('H:i:s d/m/Y:') . ' CREATION: '.$poll_id."\t".$format."\t".$adminName."\t".$adminMail."\n", 3, 'admin/logs_studs.txt');
|
||||
|
||||
return $admin_poll_id;
|
||||
|
@ -34,6 +34,7 @@ CREATE TABLE IF NOT EXISTS `sondage` (
|
||||
`format` varchar(1) DEFAULT NULL,
|
||||
`editable` tinyint(1) DEFAULT '0',
|
||||
`receiveNewVotes` tinyint(1) DEFAULT '0',
|
||||
`active` tinyint(1) DEFAULT '1',
|
||||
`statut` int(11) NOT NULL DEFAULT '1' COMMENT '1 = actif ; 0 = inactif ; ',
|
||||
UNIQUE KEY `poll_id` (`poll_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
706
old_studs.php
Normal file
706
old_studs.php
Normal file
@ -0,0 +1,706 @@
|
||||
<?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;
|
||||
|
||||
session_start();
|
||||
|
||||
if (file_exists('bandeaux_local.php')) {
|
||||
include_once('bandeaux_local.php');
|
||||
} else {
|
||||
include_once('bandeaux.php');
|
||||
}
|
||||
|
||||
include_once __DIR__ . '/app/inc/init.php';
|
||||
|
||||
// Le fichier studs.php sert a afficher les résultats d'un sondage à un simple utilisateur.
|
||||
// C'est également l'interface pour ajouter une valeur à un sondage deja créé.
|
||||
$numsondage = false;
|
||||
|
||||
//On récupère le numéro de sondage par le lien web.
|
||||
if(!empty($_GET['sondage'])) {
|
||||
$numsondage = $_GET["sondage"];
|
||||
$_SESSION["numsondage"] = $numsondage;
|
||||
}
|
||||
|
||||
if(!empty($_POST['sondage'])) {
|
||||
$numsondage = $_POST["sondage"];
|
||||
$_SESSION["numsondage"] = $numsondage;
|
||||
} elseif(!empty($_COOKIE['sondage'])) {
|
||||
$numsondage = $_COOKIE["sondage"];
|
||||
} elseif(!empty($_SESSION['sondage'])) {
|
||||
$numsondage = $_SESSION["numsondage"];
|
||||
}
|
||||
|
||||
$dsondage = $connect->findPollById($numsondage);
|
||||
if ($dsondage){
|
||||
$sujets = $connect->allSujetsByPollId($numsondage);
|
||||
$users = $connect->allUsersByPollId($numsondage);
|
||||
} else {
|
||||
Utils::print_header( _("Error!"));
|
||||
|
||||
bandeau_titre(_("Error!"));
|
||||
|
||||
echo '
|
||||
<div class="alert alert-warning">
|
||||
<h2>' . _("This poll doesn't exist !") . '</h2>
|
||||
<p>' . _('Back to the homepage of ') . ' <a href="' . Utils::get_server_name() . '"> ' . NOMAPPLICATION . '</a></p>
|
||||
</div>'."\n";
|
||||
|
||||
bandeau_pied();
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
//output a CSV and die()
|
||||
if(!empty($_GET['export']) && $dsondage) {
|
||||
if($_GET['export'] == 'csv') {
|
||||
require_once('exportcsv.php');
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
// quand on ajoute un commentaire utilisateur
|
||||
if(isset($_POST['ajoutcomment'])) {
|
||||
if (isset($_SESSION['nom']) && Utils::issetAndNoEmpty('commentuser') === false) {
|
||||
// Si le nom vient de la session, on le de-htmlentities
|
||||
$comment_user = html_entity_decode($_SESSION['nom'], ENT_QUOTES, 'UTF-8');
|
||||
} elseif(Utils::issetAndNoEmpty('commentuser')) {
|
||||
$comment_user = $_POST["commentuser"];
|
||||
} elseif(isset($_POST["commentuser"])) {
|
||||
$err |= COMMENT_USER_EMPTY;
|
||||
} else {
|
||||
$comment_user = _('anonyme');
|
||||
}
|
||||
|
||||
if(Utils::issetAndNoEmpty('comment') === false) {
|
||||
$err |= COMMENT_EMPTY;
|
||||
}
|
||||
|
||||
if (isset($_POST["comment"]) && !Utils::is_error(COMMENT_EMPTY) && !Utils::is_error(NO_POLL) && !Utils::is_error(COMMENT_USER_EMPTY)) {
|
||||
// protection contre les XSS : htmlentities
|
||||
$comment = htmlentities($_POST['comment'], ENT_QUOTES, 'UTF-8');
|
||||
$comment_user = htmlentities($comment_user, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
// Check for doublons
|
||||
$comment_doublon = false;
|
||||
$req = 'SELECT * FROM comments WHERE id_sondage='.$connect->Param('numsondage').' ORDER BY id_comment';
|
||||
$sql = $connect->Prepare($req);
|
||||
$comment_user_doublon = $connect->Execute($sql, array($numsondage));
|
||||
if ($comment_user_doublon->RecordCount() != 0) {
|
||||
while ( $dcomment_user_doublon=$comment_user_doublon->FetchNextObject(false)) {
|
||||
if($dcomment_user_doublon->comment == $comment && $dcomment_user_doublon->usercomment == $comment_user) {
|
||||
$comment_doublon = true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if(!$comment_doublon) {
|
||||
$req = 'INSERT INTO comments (id_sondage, comment, usercomment) VALUES ('.
|
||||
$connect->Param('id_sondage').','.
|
||||
$connect->Param('comment').','.
|
||||
$connect->Param('comment_user').')';
|
||||
$sql = $connect->Prepare($req);
|
||||
|
||||
$comments = $connect->Execute($sql, array($numsondage, $comment, $comment_user));
|
||||
if ($comments === false) {
|
||||
$err |= COMMENT_INSERT_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Action quand on clique le bouton participer
|
||||
$user_studs = $connect->allUsersByPollId($numsondage);
|
||||
|
||||
$nbcolonnes = countStuds($sujets);
|
||||
if (!Utils::is_error(NO_POLL) && (isset($_POST["boutonp"]))) {
|
||||
//Si le nom est bien entré
|
||||
if (empty($_POST['nom'])) {
|
||||
$err |= NAME_EMPTY;
|
||||
}
|
||||
|
||||
if(!Utils::is_error(NAME_EMPTY) && (! ( USE_REMOTE_USER && isset($_SERVER['REMOTE_USER']) ) || $_POST["nom"] == $_SESSION["nom"])) {
|
||||
$nouveauchoix = '';
|
||||
for ($i=0;$i<$nbcolonnes;$i++) {
|
||||
// radio checked 1 = Yes, 2 = Ifneedbe, 0 = No
|
||||
if (isset($_POST["choix$i"])) {
|
||||
switch ($_POST["choix$i"]) {
|
||||
case 1: $nouveauchoix .= "1";break;
|
||||
case 2: $nouveauchoix .= "2";break;
|
||||
default: $nouveauchoix .= "0";break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$nom=substr($_POST["nom"],0,64);
|
||||
|
||||
// protection contre les XSS : htmlentities
|
||||
$nom = htmlentities($nom, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
foreach ($users as $user) {
|
||||
if ($nom == $user->nom) {
|
||||
$err |= NAME_TAKEN;
|
||||
}
|
||||
}
|
||||
|
||||
// Ecriture des choix de l'utilisateur dans la base
|
||||
if (!Utils::is_error(NAME_TAKEN) && !Utils::is_error(NAME_EMPTY)) {
|
||||
|
||||
// Todo : Il faudrait lever une erreur en cas d'erreur d'insertion
|
||||
$newVote = $connect->insertVote($nom, $numsondage, $nouveauchoix);
|
||||
$user_studs[] = $newVote;
|
||||
|
||||
if ($dsondage->receiveNewVotes || /* compatibility for non boolean DB */ $dsondage->receiveNewVotes==="yes" || $dsondage->receiveNewVotes==="true") {
|
||||
if($config['use_smtp']==true){
|
||||
Utils::sendEmail( $dsondage->admin_mail,
|
||||
"[".NOMAPPLICATION."] "._("Poll's participation")." : ".html_entity_decode($dsondage->title, ENT_QUOTES, 'UTF-8') . ' ',
|
||||
html_entity_decode($nom, ENT_QUOTES, 'UTF-8'). ' ' .
|
||||
_("has filled a line.\nYou can find your poll at the link") . " :\n\n".
|
||||
Utils::getUrlSondage($numsondage) . " \n\n" .
|
||||
_("Thanks for your confidence.") . "\n". NOMAPPLICATION );
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$err |= NAME_EMPTY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($err != 0) {
|
||||
Utils::print_header(_("Error!").' - '.$dsondage->title);
|
||||
bandeau_titre(_("Error!"));
|
||||
|
||||
echo '<div class="alert alert-danger"><ul class="list-unstyled">'."\n";
|
||||
|
||||
if(Utils::is_error(NAME_EMPTY)) {
|
||||
echo '<li>' . _("Enter a name") . "</li>\n";
|
||||
}
|
||||
if(Utils::is_error(NAME_TAKEN)) {
|
||||
echo '<li>' . _("The name you've chosen already exist in this poll!") . "</li>\n";
|
||||
}
|
||||
if(Utils::is_error(COMMENT_EMPTY) || Utils::is_error(COMMENT_USER_EMPTY)) {
|
||||
echo '<li>' . _("Enter a name and a comment!") . "</li>\n";
|
||||
}
|
||||
if(Utils::is_error(COMMENT_INSERT_FAILED) ) {
|
||||
echo '<li>' . _("Failed to insert the comment!") . "</li>\n";
|
||||
}
|
||||
|
||||
echo '</ul></div>';
|
||||
|
||||
} else {
|
||||
Utils::print_header(_('Poll').' - '.$dsondage->title);
|
||||
bandeau_titre(_('Poll').' - '.$dsondage->title);
|
||||
}
|
||||
|
||||
$title=stripslashes(str_replace("\\","",$dsondage->title));
|
||||
echo '
|
||||
<div class="jumbotron">
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<h3>'.$title.'</h3>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="btn-group pull-right">
|
||||
<button onclick="javascript:print(); return false;" class="btn btn-default"><span class="glyphicon glyphicon-print"></span> ' . _('Print') . '</button>
|
||||
<button onclick="window.location.href=\'' . Utils::get_server_name() . 'exportcsv.php?numsondage=' . $numsondage . '\';return false;" class="btn btn-default"><span class="glyphicon glyphicon-download-alt"></span> ' . _('Export to CSV') . '</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="form-group">
|
||||
<h4 class="control-label">'. _("Initiator of the poll") .'</h4>
|
||||
<p class="form-control-static"> '.stripslashes($dsondage->admin_name).'</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="public-link"><a class="public-link" href="' . Utils::getUrlSondage($dsondage->poll_id) . '">'._("Public link of the poll") .' <span class="btn-link glyphicon glyphicon-link"></span></a></label>
|
||||
<input class="form-control" id="public-link" type="text" readonly="readonly" value="' . Utils::getUrlSondage($dsondage->poll_id) . '" />
|
||||
</div>
|
||||
</div>'."\n";
|
||||
|
||||
//affichage de la description du sondage
|
||||
if ($dsondage->comment) {
|
||||
$commentaires = $dsondage->comment;
|
||||
$commentaires=nl2br(str_replace("\\","",$comment));
|
||||
echo '
|
||||
<div class="form-group col-md-7">
|
||||
<h4 class="control-label">'._("Description") .'</h4><br />
|
||||
<p class="form-control-static well">'. $commentaires .'</p>
|
||||
</div>';
|
||||
}
|
||||
echo '
|
||||
</div>
|
||||
</div>'."\n"; // .jumbotron
|
||||
|
||||
//On récupere les données et les sujets du sondage
|
||||
$nblignes = count($users);
|
||||
|
||||
//on teste pour voir si une ligne doit etre modifiée
|
||||
$testmodifier = false;
|
||||
$ligneamodifier = -1;
|
||||
for ($i=0;$i<$nblignes;$i++) {
|
||||
if (isset($_POST["modifierligne$i"])) {
|
||||
$ligneamodifier = $i;
|
||||
}
|
||||
|
||||
//test pour voir si une ligne est a modifier
|
||||
if (isset($_POST['validermodifier'.$i])) {
|
||||
$modifier = $i;
|
||||
$testmodifier = true;
|
||||
}
|
||||
}
|
||||
|
||||
//si le test est valide alors on affiche des checkbox pour entrer de nouvelles valeurs
|
||||
if ($testmodifier) {
|
||||
$nouveauchoix = '';
|
||||
for ($i=0;$i<$nbcolonnes;$i++) {
|
||||
// radio checked 1 = Yes, 2 = Ifneedbe, 0 = No
|
||||
if (isset($_POST["choix$i"])) {
|
||||
switch ($_POST["choix$i"]) {
|
||||
case 1: $nouveauchoix .= "1";break;
|
||||
case 2: $nouveauchoix .= "2";break;
|
||||
default: $nouveauchoix .= "0";break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$compteur=0;
|
||||
while ($data = $user_studs->FetchNextObject(false) ) {
|
||||
//mise a jour des données de l'utilisateur dans la base SQL
|
||||
if ($compteur == $modifier) {
|
||||
$sql = 'UPDATE user_studs SET reponses='.$connect->Param('nouveauchoix').' WHERE nom='.$connect->Param('nom').' AND id_users='.$connect->Param('id_users');
|
||||
$sql = $connect->Prepare($sql);
|
||||
$connect->Execute($sql, array($nouveauchoix, $data->nom, $data->id_users));
|
||||
|
||||
if ($dsondage->mailsonde=="yes") {
|
||||
Utils::sendEmail( "$dsondage->mail_admin", "[".NOMAPPLICATION."] " . _("Poll's participation") . " : ".html_entity_decode($dsondage->title, ENT_QUOTES, 'UTF-8'), "\"".html_entity_decode($data->nom, ENT_QUOTES, 'UTF-8')."\""."" . _("has filled a line.\nYou can find your poll at the link") . " :\n\n" . Utils::getUrlSondage($numsondage) . " \n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION );
|
||||
}
|
||||
}
|
||||
$compteur++;
|
||||
}
|
||||
}
|
||||
|
||||
// Table headers
|
||||
$thead = '<thead>';
|
||||
|
||||
// Button in the first td to avoid remove col on "Return" keypress)
|
||||
$border = array(); // bordure pour distinguer les mois
|
||||
$td_headers = array(); // for a11y, headers="M1 D4 H5" on each td
|
||||
$radio_title = array(); // date for
|
||||
|
||||
// Dates poll
|
||||
if ($dsondage->format === 'D') {
|
||||
|
||||
$tr_months = '<tr><th role="presentation"></th>';
|
||||
$tr_days = '<tr><th role="presentation"></th>';
|
||||
$tr_hours = '<tr><th role="presentation"></th>';
|
||||
|
||||
// Headers
|
||||
$colspan_month = 0;
|
||||
|
||||
$col_number = 0;
|
||||
foreach ($sujets as $i=>$sujet) {
|
||||
|
||||
// Current date
|
||||
$horoCur = explode("@", $sujet->sujet); //horoCur[0] = date, horoCur[1] = hour,hour,hour
|
||||
if (isset($sujets[$i+1])){
|
||||
$next = $sujets[$i+1];
|
||||
$horoNext = explode("@", $next->sujet);
|
||||
} else {
|
||||
unset($next);
|
||||
}
|
||||
|
||||
|
||||
$border[$col_number] = false;
|
||||
$current_radio_title = strftime($date_format['txt_short'], $horoCur[0]);
|
||||
|
||||
// Months
|
||||
$current_td_headers = 'M'.($i+1-$colspan_month);
|
||||
|
||||
$currentYearMonth = strftime("%B%Y", $horoCur[0]);
|
||||
$nextYearMonth = strftime("%B%Y", $horoNext[0]);
|
||||
if (isset($next) && $currentYearMonth == $nextYearMonth) {
|
||||
$colspan_month += substr_count($horoCur[1], ',') + 1;
|
||||
} else {
|
||||
$border[$i] = true;
|
||||
$colspan_month += substr_count($horoCur[1], ',') + 1;
|
||||
$tr_months .= '<th colspan="'.$colspan_month.'" class="bg-primary month" id="M'.($i+1-$colspan_month).'">'.strftime("%B",$horoCur[0]).' '.strftime("%Y", $horoCur[0]).'</th>';
|
||||
$colspan_month=0;
|
||||
}
|
||||
|
||||
// Days
|
||||
|
||||
$colspan_day = substr_count($horoCur[1], ',') + 1;
|
||||
$current_td_headers .= ' D'.($col_number+1-$colspan_day);
|
||||
$tr_days .= '<th colspan="'.$colspan_day.'" class="bg-primary day rbd" id="D'.($current_radio_title+1-$colspan_day).'">'.strftime($date_format['txt_day'],$horoCur[0]).'</th>';
|
||||
|
||||
// Hours
|
||||
if (!empty($horoCur[1])) {
|
||||
$hours = explode(',', $horoCur[1]);
|
||||
foreach($hours as $hour) {
|
||||
if (end($hours) == $hour) {
|
||||
$border[$col_number] = false;
|
||||
} else {
|
||||
$border[$col_number] = true;
|
||||
}
|
||||
|
||||
$rbd = ($border[$col_number]) ? ' rbd' : '';
|
||||
|
||||
$tr_hours .= '<th class="bg-info'.$rbd.'" id="H'.$col_number.'" title="'.$hour.'">'.$hour.'</th>';
|
||||
$radio_title[$col_number] = $current_radio_title . ' - '.$hour;
|
||||
$td_headers[$col_number] = $current_td_headers . ' H'.$col_number;
|
||||
$col_number++;
|
||||
}
|
||||
} else {
|
||||
$tr_hours .= '<th class="bg-info'.$rbd.'"></th>';
|
||||
}
|
||||
}
|
||||
|
||||
$border[count($border)-1] = false; // suppression de la bordure droite du dernier mois
|
||||
|
||||
$tr_months .= '<th></th></tr>';
|
||||
$tr_days .= '<th></th></tr>';
|
||||
$tr_hours .= '<th></th></tr>';
|
||||
|
||||
$thead = "\n".$tr_months."\n".$tr_days."\n".$tr_hours."\n";
|
||||
|
||||
// Subjects poll
|
||||
} else {
|
||||
|
||||
$tr_subjects = '<tr><th role="presentation"></th>';
|
||||
|
||||
foreach ($sujets as $i=>$sujet) {
|
||||
|
||||
$td_headers[$i]='';$radio_title[$i]=''; // init before concatenate
|
||||
|
||||
// Subjects
|
||||
preg_match_all('/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/',$sujet->sujet,$md_a_img); // Markdown [![alt](src)](href)
|
||||
preg_match_all('/!\[(.*?)\]\((.*?)\)/',$sujet->sujet,$md_img); // Markdown ![alt](src)
|
||||
preg_match_all('/\[(.*?)\]\((.*?)\)/',$sujet->sujet,$md_a); // Markdown [text](href)
|
||||
if (isset($md_a_img[2][0]) && $md_a_img[2][0]!='' && isset($md_a_img[3][0]) && $md_a_img[3][0]!='') { // [![alt](src)](href)
|
||||
|
||||
$th_subject_text = (isset($md_a_img[1][0]) && $md_a_img[1][0]!='') ? stripslashes($md_a_img[1][0]) : _("Choice") .' '.($i+1);
|
||||
$th_subject_html = '<a href="'.$md_a_img[3][0].'"><img src="'.$md_a_img[2][0].'" class="img-responsive" alt="'.$th_subject_text.'" /></a>';
|
||||
|
||||
} elseif (isset($md_img[2][0]) && $md_img[2][0]!='') { // ![alt](src)
|
||||
|
||||
$th_subject_text = (isset($md_img[1][0]) && $md_img[1][0]!='') ? stripslashes($md_img[1][0]) : _("Choice") .' '.($i+1);
|
||||
$th_subject_html = '<img src="'.$md_img[2][0].'" class="img-responsive" alt="'.$th_subject_text.'" />';
|
||||
|
||||
} elseif (isset($md_a[2][0]) && $md_a[2][0]!='') { // [text](href)
|
||||
|
||||
$th_subject_text = (isset($md_a[1][0]) && $md_a[1][0]!='') ? stripslashes($md_a[1][0]) : _("Choice") .' '.($i+1);
|
||||
$th_subject_html = '<a href="'.$md_a[2][0].'">'.$th_subject_text.'</a>';
|
||||
|
||||
} else { // text only
|
||||
|
||||
$th_subject_text = stripslashes($sujet->sujet);
|
||||
$th_subject_html = $th_subject_text;
|
||||
|
||||
}
|
||||
$tr_subjects .= '<th class="bg-info" id="S'.$i.'" title="'.$th_subject_text.'">'.$th_subject_html.'</th>';
|
||||
|
||||
$border[$i] = false;
|
||||
$td_headers[$i] .= 'S'.$i;
|
||||
$radio_title[$i] .= $th_subject_text;
|
||||
|
||||
}
|
||||
|
||||
$thead = $tr_subjects.'<th></th></tr>';
|
||||
}
|
||||
|
||||
// Print headers
|
||||
echo '
|
||||
<form name="formulaire" action="' . Utils::getUrlSondage($dsondage->poll_id) . '" method="POST">
|
||||
<input type="hidden" name="sondage" value="' . $numsondage . '"/>
|
||||
';
|
||||
if ($dsondage->format=="A-" || $dsondage->format=="D-") {
|
||||
echo '
|
||||
<div class="alert alert-danger">
|
||||
<p>' . _("The administrator locked this poll, votes and comments are frozen, it's not possible to participate anymore.") . '</p>
|
||||
<p aria-hidden="true"><b>' . _('Legend:'). '</b> <span class="glyphicon glyphicon-ok"></span> =' . _('Yes') . ', <b>(<span class="glyphicon glyphicon-ok"></span>)</b> = ' . _('Ifneedbe') . ', <span class="glyphicon glyphicon-ban-circle"></span> = ' . _('No') . '</p>
|
||||
</div>';
|
||||
} else {
|
||||
echo '
|
||||
<div class="alert alert-info">
|
||||
<p>' . _("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.") . '</p>
|
||||
<p aria-hidden="true"><b>' . _('Legend:'). '</b> <span class="glyphicon glyphicon-ok"></span> =' . _('Yes') . ', <b>(<span class="glyphicon glyphicon-ok"></span>)</b> = ' . _('Ifneedbe') . ', <span class="glyphicon glyphicon-ban-circle"></span> = ' . _('No') . '</p>
|
||||
</div>';
|
||||
}
|
||||
echo'
|
||||
<div class="hidden row scroll-buttons" aria-hidden="true">
|
||||
<div class="btn-group pull-right">
|
||||
<button class="btn btn-sm btn-link scroll-left" title="' . _('Scroll to the left') . '">
|
||||
<span class="glyphicon glyphicon-chevron-left"></span>
|
||||
</button>
|
||||
<button class="btn btn-sm btn-link scroll-right" title="' . _('Scroll to the right') . '">
|
||||
<span class="glyphicon glyphicon-chevron-right"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>'._('Votes of the poll ').'</h3>
|
||||
<div id="tableContainer" class="tableContainer">
|
||||
<table class="results">
|
||||
<caption class="sr-only">'._('Votes of the poll ').$title.'</caption>
|
||||
<thead>'. $thead . '</thead>
|
||||
<tbody>';
|
||||
|
||||
// Print poll results
|
||||
|
||||
//Usager pré-authentifié dans la liste?
|
||||
$user_mod = false;
|
||||
|
||||
//affichage des resultats actuels
|
||||
$somme[] = 0;
|
||||
$compteur = 0;
|
||||
|
||||
foreach ($users as $user) {
|
||||
|
||||
$ensemblereponses = $user->reponses;
|
||||
|
||||
//affichage du nom
|
||||
$nombase=str_replace("°","'",$user->nom);
|
||||
echo '<tr>
|
||||
<th class="bg-info">'.stripslashes($nombase).'</th>'."\n";
|
||||
|
||||
// ligne d'un usager pré-authentifié
|
||||
$mod_ok = !( USE_REMOTE_USER && isset($_SERVER['REMOTE_USER']) ) || ($nombase == $_SESSION['nom']);
|
||||
$user_mod |= $mod_ok;
|
||||
|
||||
// pour chaque colonne
|
||||
for ($k=0; $k < $nbcolonnes; $k++) {
|
||||
// on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs
|
||||
if ($compteur == $ligneamodifier) {
|
||||
|
||||
$car = substr($ensemblereponses, $k , 1);
|
||||
|
||||
// variable pour afficher la valeur cochée
|
||||
$car_html[0]='value="0"';$car_html[1]='value="1"';$car_html[2]='value="2"';
|
||||
switch ($car) {
|
||||
case "1": $car_html[1]='value="1" checked';break;
|
||||
case "2": $car_html[2]='value="2" checked';break;
|
||||
default: $car_html[0]='value="0" checked';break;
|
||||
}
|
||||
|
||||
echo '
|
||||
<td class="bg-info" headers="'.$td_headers[$k ].'">
|
||||
<ul class="list-unstyled choice">
|
||||
<li class="yes">
|
||||
<input type="radio" id="y-choice-'.$k.'" name="choix'.$k.'" '.$car_html[1].' />
|
||||
<label class="btn btn-default btn-xs" for="y-choice-'.$k.'" title="' . _('Vote "yes" for ') . $radio_title[$k] . '">
|
||||
<span class="glyphicon glyphicon-ok"></span><span class="sr-only">' . _('Yes') . '</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="ifneedbe">
|
||||
<input type="radio" id="i-choice-'.$k.'" name="choix'.$k.'" '.$car_html[2].' />
|
||||
<label class="btn btn-default btn-xs" for="i-choice-'.$k.'" title="' . _('Vote "ifneedbe" for ') . $radio_title[$k] . '">
|
||||
(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only">' . _('Ifneedbe') . '</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="no">
|
||||
<input type="radio" id="n-choice-'.$k.'" name="choix'.$k.'" '.$car_html[0].'/>
|
||||
<label class="btn btn-default btn-xs" for="n-choice-'.$k.'" title="' . _('Vote "no" for ') . $radio_title[$k] . '">
|
||||
<span class="glyphicon glyphicon-ban-circle"></span><span class="sr-only">' . _('No') . '</span>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</td>'."\n";
|
||||
|
||||
} else {
|
||||
$rbd = ($border[$k]) ? ' rbd' : '';
|
||||
$car = substr($ensemblereponses, $k, 1);
|
||||
switch ($car) {
|
||||
case "1": echo '<td class="bg-success text-success'.$rbd.'" headers="'.$td_headers[$k].'"><span class="glyphicon glyphicon-ok"></span><span class="sr-only"> ' . _('Yes') . '</span></td>'."\n";
|
||||
if (isset($somme[$k]) === false) {
|
||||
$somme[$k] = 0;
|
||||
}
|
||||
$somme[$k]++; break;
|
||||
case "2": echo '<td class="bg-warning text-warning'.$rbd.'" headers="'.$td_headers[$k].'">(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only"> ' . _('Yes') . _(', ifneedbe') . '</span></td>'."\n"; break;
|
||||
default: echo '<td class="bg-danger'.$rbd.'" headers="'.$td_headers[$k].'"><span class="sr-only">' . _('No') . '</span></td>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//a la fin de chaque ligne se trouve les boutons modifier
|
||||
if ($compteur != $ligneamodifier && ($dsondage->format=="A+"||$dsondage->format=="D+") && $mod_ok) {
|
||||
echo '
|
||||
<td>
|
||||
<button type="submit" class="btn btn-link btn-sm" name="modifierligne'.$compteur.'" title="'. _('Edit the line:') .' '.stripslashes($nombase).'">
|
||||
<span class="glyphicon glyphicon-pencil"></span><span class="sr-only">' . _('Edit') . '</span>
|
||||
</button>
|
||||
</td>'."\n";
|
||||
}
|
||||
|
||||
//demande de confirmation pour modification de ligne
|
||||
for ($i=0;$i<$nblignes;$i++) {
|
||||
if (isset($_POST["modifierligne$i"])) {
|
||||
if ($compteur == $i) {
|
||||
echo '<td style="padding:5px"><button type="submit" class="btn btn-success btn-xs" name="validermodifier'.$compteur.'" title="'. _('Save the choices') .' '.stripslashes($nombase).'">'. _('Save') .'</button></td>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$compteur++;
|
||||
echo '</tr>'."\n";
|
||||
}
|
||||
|
||||
// affichage de la ligne pour un nouvel utilisateur
|
||||
if (( !(USE_REMOTE_USER && isset($_SERVER['REMOTE_USER'])) || !$user_mod) && $ligneamodifier==-1 && ($dsondage->format!="A-" && $dsondage->format!="D-")) {
|
||||
//affichage de la case vide de texte pour un nouvel utilisateur
|
||||
echo '<tr id="vote-form">
|
||||
<td class="bg-info" style="padding:5px">
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
|
||||
<input type="text" id="nom" name="nom" class="form-control" title="'. _('Your name') .'" placeholder="'. _('Your name') .'" />
|
||||
</div>
|
||||
</td>'."\n";
|
||||
|
||||
//une ligne de checkbox pour le choix du nouvel utilisateur
|
||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
echo '
|
||||
<td class="bg-info" headers="'.$td_headers[$i].'">
|
||||
<ul class="list-unstyled choice">
|
||||
<li class="yes">
|
||||
<input type="radio" id="y-choice-'.$i.'" name="choix'.$i.'" value="1" />
|
||||
<label class="btn btn-default btn-xs" for="y-choice-'.$i.'" title="' . _('Vote "yes" for ') . $radio_title[$i] . '">
|
||||
<span class="glyphicon glyphicon-ok"></span><span class="sr-only">' . _('Yes') . '</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="ifneedbe">
|
||||
<input type="radio" id="i-choice-'.$i.'" name="choix'.$i.'" value="2" />
|
||||
<label class="btn btn-default btn-xs" for="i-choice-'.$i.'" title="' . _('Vote "ifneedbe" for ') . $radio_title[$i] . '">
|
||||
(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only">' . _('Ifneedbe') . '</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="no">
|
||||
<input type="radio" id="n-choice-'.$i.'" name="choix'.$i.'" value="0" checked/>
|
||||
<label class="btn btn-default btn-xs" for="n-choice-'.$i.'" title="' . _('Vote "no" for ') . $radio_title[$i] . '">
|
||||
<span class="glyphicon glyphicon-ban-circle"></span><span class="sr-only">' . _('No') . '</span>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</td>'."\n";
|
||||
}
|
||||
|
||||
// Affichage du bouton de formulaire pour inscrire un nouvel utilisateur dans la base
|
||||
echo '<td><button type="submit" class="btn btn-success btn-sm" name="boutonp" title="'. _('Save the choices') .'">'. _('Save') .'</button></td>
|
||||
</tr>'."\n";
|
||||
|
||||
}
|
||||
|
||||
// Addition and Best choice
|
||||
//affichage de la ligne contenant les sommes de chaque colonne
|
||||
$tr_addition = '<tr id="addition"><td>'. _("Addition") .'</td>';
|
||||
$meilleurecolonne = max($somme);
|
||||
$compteursujet = 0;
|
||||
$meilleursujet = '<ul style="list-style:none">';
|
||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
if (isset($somme[$i]) && $somme[$i] > 0 ) {
|
||||
if (in_array($i, array_keys($somme, max($somme)))){
|
||||
|
||||
$tr_addition .= '<td><span class="glyphicon glyphicon-star text-warning"></span><span>'.$somme[$i].'</span></td>';
|
||||
|
||||
$meilleursujet.= '<li><b>'.$radio_title[$i].'</b></li>';
|
||||
$compteursujet++;
|
||||
|
||||
} else {
|
||||
$tr_addition .= '<td>'.$somme[$i].'</td>';
|
||||
}
|
||||
} else {
|
||||
$tr_addition .= '<td></td>';
|
||||
}
|
||||
}
|
||||
$tr_addition .= '<td></td></tr>';
|
||||
|
||||
$meilleursujet = str_replace("°", "'", $meilleursujet).'</ul>';
|
||||
$vote_str = ($meilleurecolonne > 1) ? $vote_str = _('votes') : _('vote');
|
||||
|
||||
// Print Addition and Best choice
|
||||
echo $tr_addition.'
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="row">'."\n";
|
||||
|
||||
if ($compteursujet == 1) {
|
||||
echo '
|
||||
<div class="col-sm-12"><h3>' . _("Best choice") . '</h3></div>
|
||||
<div class="col-sm-6 col-sm-offset-3 alert alert-success">
|
||||
<p><span class="glyphicon glyphicon-star text-warning"></span> ' . _("The best choice at this time is:") . '</p>
|
||||
' . $meilleursujet . '
|
||||
<p>' . _("with") . ' <b>' . $meilleurecolonne . '</b> ' . $vote_str . '.</p>
|
||||
</div>'."\n";
|
||||
} elseif ($compteursujet > 1) {
|
||||
echo '
|
||||
<div class="col-sm-12"><h3>' . _("Best choices") . '</h3></div>
|
||||
<div class="col-sm-6 col-sm-offset-3 alert alert-success">
|
||||
<p><span class="glyphicon glyphicon-star text-warning"></span> ' . _("The bests choices at this time are:") . '</p>
|
||||
' . $meilleursujet . '
|
||||
<p>' . _("with") . ' <b>' . $meilleurecolonne . '</b> ' . $vote_str . '.</p>
|
||||
</div>'."\n";
|
||||
}
|
||||
|
||||
echo '
|
||||
</div>
|
||||
<hr role="presentation" />';
|
||||
|
||||
// Comments
|
||||
$comments = $connect->allCommentsByPollId($numsondage);
|
||||
|
||||
if (count($comments) != 0) {
|
||||
echo '<div><h3>' . _("Comments of polled people") . '</h3>'."\n";
|
||||
|
||||
while($dcomment = $comment_user->FetchNextObject(false)) {
|
||||
echo '
|
||||
<div class="comment">
|
||||
<b>'.stripslashes($dcomment->usercomment). ' :</b>
|
||||
<span class="comment">' . stripslashes(nl2br($dcomment->comment)) . '</span>
|
||||
</div>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
if ($dsondage->format!="A-" && $dsondage->format!="D-") {
|
||||
echo '
|
||||
<div class="hidden-print alert alert-info">
|
||||
<div class="col-md-6 col-md-offset-3">
|
||||
<fieldset id="add-comment"><legend>' . _("Add a comment in the poll") . '</legend>
|
||||
<div class="form-group">
|
||||
<p><label for="commentuser">'. _("Your name") .'</label><input type=text class="form-control" name="commentuser" id="commentuser" /></p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<p><label for="comment">'. _("Your comment") .'</label><br />
|
||||
<textarea name="comment" id="comment" class="form-control" rows="2" cols="40"></textarea></p>
|
||||
</div>
|
||||
<p class="text-center"><input type="submit" name="ajoutcomment" value="'. _("Send the comment") .'" class="btn btn-success"></p>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</form>';
|
||||
|
||||
bandeau_pied();
|
703
studs.php
703
studs.php
@ -18,678 +18,65 @@
|
||||
*/
|
||||
namespace Framadate;
|
||||
|
||||
session_start();
|
||||
|
||||
if (file_exists('bandeaux_local.php')) {
|
||||
include_once('bandeaux_local.php');
|
||||
} else {
|
||||
include_once('bandeaux.php');
|
||||
}
|
||||
|
||||
include_once __DIR__ . '/app/inc/init.php';
|
||||
|
||||
// Le fichier studs.php sert a afficher les résultats d'un sondage à un simple utilisateur.
|
||||
// C'est également l'interface pour ajouter une valeur à un sondage deja créé.
|
||||
$numsondage = false;
|
||||
/* Functions */
|
||||
/* --------- */
|
||||
|
||||
//On récupère le numéro de sondage par le lien web.
|
||||
if(!empty($_GET['sondage'])) {
|
||||
$numsondage = $_GET["sondage"];
|
||||
$_SESSION["numsondage"] = $numsondage;
|
||||
function split_slots($slots) {
|
||||
$splitted = array();
|
||||
foreach ($slots as $slot) {
|
||||
$ex = explode('@', $slot->sujet);
|
||||
$obj = new \stdClass();
|
||||
$obj->day = $ex[0];
|
||||
$obj->moments = explode(',', $ex[1]);
|
||||
|
||||
$splitted[] = $obj;
|
||||
}
|
||||
return $splitted;
|
||||
}
|
||||
|
||||
if(!empty($_POST['sondage'])) {
|
||||
$numsondage = $_POST["sondage"];
|
||||
$_SESSION["numsondage"] = $numsondage;
|
||||
} elseif(!empty($_COOKIE['sondage'])) {
|
||||
$numsondage = $_COOKIE["sondage"];
|
||||
} elseif(!empty($_SESSION['sondage'])) {
|
||||
$numsondage = $_SESSION["numsondage"];
|
||||
function split_votes($votes) {
|
||||
$splitted = array();
|
||||
foreach ($votes as $vote) {
|
||||
$obj = new \stdClass();
|
||||
$obj->id = $vote->id_users;
|
||||
$obj->name = $vote->nom;
|
||||
$obj->choices = str_split($vote->reponses);
|
||||
|
||||
$splitted[] = $obj;
|
||||
}
|
||||
return $splitted;
|
||||
}
|
||||
|
||||
$dsondage = $connect->findPollById($numsondage);
|
||||
if ($dsondage){
|
||||
$sujets = $connect->allSujetsByPollId($numsondage);
|
||||
$users = $connect->allUsersByPollId($numsondage);
|
||||
} else {
|
||||
Utils::print_header( _("Error!"));
|
||||
/* PAGE */
|
||||
/* ---- */
|
||||
|
||||
bandeau_titre(_("Error!"));
|
||||
|
||||
echo '
|
||||
<div class="alert alert-warning">
|
||||
<h2>' . _("This poll doesn't exist !") . '</h2>
|
||||
<p>' . _('Back to the homepage of ') . ' <a href="' . Utils::get_server_name() . '"> ' . NOMAPPLICATION . '</a></p>
|
||||
</div>'."\n";
|
||||
|
||||
bandeau_pied();
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
//output a CSV and die()
|
||||
if(!empty($_GET['export']) && $dsondage) {
|
||||
if($_GET['export'] == 'csv') {
|
||||
require_once('exportcsv.php');
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
// quand on ajoute un commentaire utilisateur
|
||||
if(isset($_POST['ajoutcomment'])) {
|
||||
if (isset($_SESSION['nom']) && Utils::issetAndNoEmpty('commentuser') === false) {
|
||||
// Si le nom vient de la session, on le de-htmlentities
|
||||
$comment_user = html_entity_decode($_SESSION['nom'], ENT_QUOTES, 'UTF-8');
|
||||
} elseif(Utils::issetAndNoEmpty('commentuser')) {
|
||||
$comment_user = $_POST["commentuser"];
|
||||
} elseif(isset($_POST["commentuser"])) {
|
||||
$err |= COMMENT_USER_EMPTY;
|
||||
} else {
|
||||
$comment_user = _('anonyme');
|
||||
}
|
||||
|
||||
if(Utils::issetAndNoEmpty('comment') === false) {
|
||||
$err |= COMMENT_EMPTY;
|
||||
}
|
||||
|
||||
if (isset($_POST["comment"]) && !Utils::is_error(COMMENT_EMPTY) && !Utils::is_error(NO_POLL) && !Utils::is_error(COMMENT_USER_EMPTY)) {
|
||||
// protection contre les XSS : htmlentities
|
||||
$comment = htmlentities($_POST['comment'], ENT_QUOTES, 'UTF-8');
|
||||
$comment_user = htmlentities($comment_user, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
// Check for doublons
|
||||
$comment_doublon = false;
|
||||
$req = 'SELECT * FROM comments WHERE id_sondage='.$connect->Param('numsondage').' ORDER BY id_comment';
|
||||
$sql = $connect->Prepare($req);
|
||||
$comment_user_doublon = $connect->Execute($sql, array($numsondage));
|
||||
if ($comment_user_doublon->RecordCount() != 0) {
|
||||
while ( $dcomment_user_doublon=$comment_user_doublon->FetchNextObject(false)) {
|
||||
if($dcomment_user_doublon->comment == $comment && $dcomment_user_doublon->usercomment == $comment_user) {
|
||||
$comment_doublon = true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if(!$comment_doublon) {
|
||||
$req = 'INSERT INTO comments (id_sondage, comment, usercomment) VALUES ('.
|
||||
$connect->Param('id_sondage').','.
|
||||
$connect->Param('comment').','.
|
||||
$connect->Param('comment_user').')';
|
||||
$sql = $connect->Prepare($req);
|
||||
|
||||
$comments = $connect->Execute($sql, array($numsondage, $comment, $comment_user));
|
||||
if ($comments === false) {
|
||||
$err |= COMMENT_INSERT_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!empty($_GET['poll'])) {
|
||||
$poll_id = $_GET['poll'];
|
||||
}
|
||||
|
||||
|
||||
// Action quand on clique le bouton participer
|
||||
$user_studs = $connect->allUsersByPollId($numsondage);
|
||||
|
||||
$nbcolonnes = count($sujets);
|
||||
if (!Utils::is_error(NO_POLL) && (isset($_POST["boutonp"]))) {
|
||||
//Si le nom est bien entré
|
||||
if (empty($_POST['nom'])) {
|
||||
$err |= NAME_EMPTY;
|
||||
}
|
||||
|
||||
if(!Utils::is_error(NAME_EMPTY) && (! ( USE_REMOTE_USER && isset($_SERVER['REMOTE_USER']) ) || $_POST["nom"] == $_SESSION["nom"])) {
|
||||
$nouveauchoix = '';
|
||||
for ($i=0;$i<$nbcolonnes;$i++) {
|
||||
// radio checked 1 = Yes, 2 = Ifneedbe, 0 = No
|
||||
if (isset($_POST["choix$i"])) {
|
||||
switch ($_POST["choix$i"]) {
|
||||
case 1: $nouveauchoix .= "1";break;
|
||||
case 2: $nouveauchoix .= "2";break;
|
||||
default: $nouveauchoix .= "0";break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$nom=substr($_POST["nom"],0,64);
|
||||
|
||||
// protection contre les XSS : htmlentities
|
||||
$nom = htmlentities($nom, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
foreach ($users as $user) {
|
||||
if ($nom == $user->nom) {
|
||||
$err |= NAME_TAKEN;
|
||||
}
|
||||
}
|
||||
|
||||
// Ecriture des choix de l'utilisateur dans la base
|
||||
if (!Utils::is_error(NAME_TAKEN) && !Utils::is_error(NAME_EMPTY)) {
|
||||
|
||||
// Todo : Il faudrait lever une erreur en cas d'erreur d'insertion
|
||||
$newVote = $connect->insertVote($nom, $numsondage, $nouveauchoix);
|
||||
$user_studs[] = $newVote;
|
||||
|
||||
if ($dsondage->receiveNewVotes || /* compatibility for non boolean DB */ $dsondage->receiveNewVotes==="yes" || $dsondage->receiveNewVotes==="true") {
|
||||
if($config['use_smtp']==true){
|
||||
Utils::sendEmail( $dsondage->admin_mail,
|
||||
"[".NOMAPPLICATION."] "._("Poll's participation")." : ".html_entity_decode($dsondage->title, ENT_QUOTES, 'UTF-8') . ' ',
|
||||
html_entity_decode($nom, ENT_QUOTES, 'UTF-8'). ' ' .
|
||||
_("has filled a line.\nYou can find your poll at the link") . " :\n\n".
|
||||
Utils::getUrlSondage($numsondage) . " \n\n" .
|
||||
_("Thanks for your confidence.") . "\n". NOMAPPLICATION );
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$err |= NAME_EMPTY;
|
||||
}
|
||||
$poll = $connect->findPollById($poll_id);
|
||||
|
||||
if (!$poll) {
|
||||
$smarty->assign('error', 'This poll doesn\'t exist');
|
||||
$smarty->display('error.tpl');
|
||||
exit;
|
||||
}
|
||||
|
||||
if($err != 0) {
|
||||
Utils::print_header(_("Error!").' - '.$dsondage->title);
|
||||
bandeau_titre(_("Error!"));
|
||||
// Retrieve data
|
||||
$slots = $connect->allSlotsByPollId($poll_id);
|
||||
$votes = $connect->allUserVotesByPollId($poll_id);
|
||||
|
||||
echo '<div class="alert alert-danger"><ul class="list-unstyled">'."\n";
|
||||
// Assign data to template
|
||||
$smarty->assign('poll_id', $poll_id);
|
||||
$smarty->assign('poll', $poll);
|
||||
$smarty->assign('title', _('Poll') . ' - ' . $poll->title);
|
||||
$smarty->assign('slots', split_slots($slots));
|
||||
$smarty->assign('votes', split_votes($votes));
|
||||
$smarty->assign('editingVoteId', 0); // TODO Replace by the right ID
|
||||
|
||||
if(Utils::is_error(NAME_EMPTY)) {
|
||||
echo '<li>' . _("Enter a name") . "</li>\n";
|
||||
}
|
||||
if(Utils::is_error(NAME_TAKEN)) {
|
||||
echo '<li>' . _("The name you've chosen already exist in this poll!") . "</li>\n";
|
||||
}
|
||||
if(Utils::is_error(COMMENT_EMPTY) || Utils::is_error(COMMENT_USER_EMPTY)) {
|
||||
echo '<li>' . _("Enter a name and a comment!") . "</li>\n";
|
||||
}
|
||||
if(Utils::is_error(COMMENT_INSERT_FAILED) ) {
|
||||
echo '<li>' . _("Failed to insert the comment!") . "</li>\n";
|
||||
}
|
||||
//Utils::debug(split_votes($votes));exit;
|
||||
|
||||
echo '</ul></div>';
|
||||
|
||||
} else {
|
||||
Utils::print_header(_('Poll').' - '.$dsondage->title);
|
||||
bandeau_titre(_('Poll').' - '.$dsondage->title);
|
||||
}
|
||||
|
||||
$title=stripslashes(str_replace("\\","",$dsondage->title));
|
||||
echo '
|
||||
<div class="jumbotron">
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<h3>'.$title.'</h3>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="btn-group pull-right">
|
||||
<button onclick="javascript:print(); return false;" class="btn btn-default"><span class="glyphicon glyphicon-print"></span> ' . _('Print') . '</button>
|
||||
<button onclick="window.location.href=\'' . Utils::get_server_name() . 'exportcsv.php?numsondage=' . $numsondage . '\';return false;" class="btn btn-default"><span class="glyphicon glyphicon-download-alt"></span> ' . _('Export to CSV') . '</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="form-group">
|
||||
<h4 class="control-label">'. _("Initiator of the poll") .'</h4>
|
||||
<p class="form-control-static"> '.stripslashes($dsondage->admin_name).'</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="public-link"><a class="public-link" href="' . Utils::getUrlSondage($dsondage->poll_id) . '">'._("Public link of the poll") .' <span class="btn-link glyphicon glyphicon-link"></span></a></label>
|
||||
<input class="form-control" id="public-link" type="text" readonly="readonly" value="' . Utils::getUrlSondage($dsondage->poll_id) . '" />
|
||||
</div>
|
||||
</div>'."\n";
|
||||
|
||||
//affichage de la description du sondage
|
||||
if ($dsondage->comment) {
|
||||
$commentaires = $dsondage->comment;
|
||||
$commentaires=nl2br(str_replace("\\","",$comment));
|
||||
echo '
|
||||
<div class="form-group col-md-7">
|
||||
<h4 class="control-label">'._("Description") .'</h4><br />
|
||||
<p class="form-control-static well">'. $commentaires .'</p>
|
||||
</div>';
|
||||
}
|
||||
echo '
|
||||
</div>
|
||||
</div>'."\n"; // .jumbotron
|
||||
|
||||
//On récupere les données et les sujets du sondage
|
||||
$nblignes = count($users);
|
||||
|
||||
//on teste pour voir si une ligne doit etre modifiée
|
||||
$testmodifier = false;
|
||||
$ligneamodifier = -1;
|
||||
for ($i=0;$i<$nblignes;$i++) {
|
||||
if (isset($_POST["modifierligne$i"])) {
|
||||
$ligneamodifier = $i;
|
||||
}
|
||||
|
||||
//test pour voir si une ligne est a modifier
|
||||
if (isset($_POST['validermodifier'.$i])) {
|
||||
$modifier = $i;
|
||||
$testmodifier = true;
|
||||
}
|
||||
}
|
||||
|
||||
//si le test est valide alors on affiche des checkbox pour entrer de nouvelles valeurs
|
||||
if ($testmodifier) {
|
||||
$nouveauchoix = '';
|
||||
for ($i=0;$i<$nbcolonnes;$i++) {
|
||||
// radio checked 1 = Yes, 2 = Ifneedbe, 0 = No
|
||||
if (isset($_POST["choix$i"])) {
|
||||
switch ($_POST["choix$i"]) {
|
||||
case 1: $nouveauchoix .= "1";break;
|
||||
case 2: $nouveauchoix .= "2";break;
|
||||
default: $nouveauchoix .= "0";break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$compteur=0;
|
||||
while ($data = $user_studs->FetchNextObject(false) ) {
|
||||
//mise a jour des données de l'utilisateur dans la base SQL
|
||||
if ($compteur == $modifier) {
|
||||
$sql = 'UPDATE user_studs SET reponses='.$connect->Param('nouveauchoix').' WHERE nom='.$connect->Param('nom').' AND id_users='.$connect->Param('id_users');
|
||||
$sql = $connect->Prepare($sql);
|
||||
$connect->Execute($sql, array($nouveauchoix, $data->nom, $data->id_users));
|
||||
|
||||
if ($dsondage->mailsonde=="yes") {
|
||||
Utils::sendEmail( "$dsondage->mail_admin", "[".NOMAPPLICATION."] " . _("Poll's participation") . " : ".html_entity_decode($dsondage->title, ENT_QUOTES, 'UTF-8'), "\"".html_entity_decode($data->nom, ENT_QUOTES, 'UTF-8')."\""."" . _("has filled a line.\nYou can find your poll at the link") . " :\n\n" . Utils::getUrlSondage($numsondage) . " \n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION );
|
||||
}
|
||||
}
|
||||
$compteur++;
|
||||
}
|
||||
}
|
||||
|
||||
// Table headers
|
||||
$thead = '<thead>';
|
||||
|
||||
// Button in the first td to avoid remove col on "Return" keypress)
|
||||
$border = array(); // bordure pour distinguer les mois
|
||||
$td_headers = array(); // for a11y, headers="M1 D4 H5" on each td
|
||||
$radio_title = array(); // date for
|
||||
|
||||
// Dates poll
|
||||
if ($dsondage->format=="D"||$dsondage->format=="D+"||$dsondage->format=="D-") {
|
||||
|
||||
$tr_months = '<tr><th role="presentation"></th>';
|
||||
$tr_days = '<tr><th role="presentation"></th>';
|
||||
$tr_hours = '<tr><th role="presentation"></th>';
|
||||
|
||||
// Headers
|
||||
$colspan_month = 1;
|
||||
$colspan_day = 1;
|
||||
|
||||
for ($i = 0; $i < count($toutsujet); $i++) {
|
||||
|
||||
// Current date
|
||||
$current = $toutsujet[$i];
|
||||
$horoCur = explode("@",$current); //horoCur[0] = date, horoCur[1] = hour
|
||||
if (isset($toutsujet[$i+1])){
|
||||
$next = $toutsujet[$i+1];
|
||||
$horoNext = explode("@",$next);
|
||||
}
|
||||
|
||||
$border[$i] = false;
|
||||
$radio_title[$i] = strftime($date_format['txt_short'],$horoCur[0]);
|
||||
|
||||
// Months
|
||||
$td_headers[$i] = 'M'.($i+1-$colspan_month);
|
||||
|
||||
if (isset($toutsujet[$i+1]) && strftime("%B", $horoCur[0]) == strftime("%B", $horoNext[0]) && strftime("%Y", $horoCur[0]) == strftime("%Y", $horoNext[0])){
|
||||
$colspan_month++;
|
||||
} else {
|
||||
$border[$i] = true;
|
||||
$tr_months .= '<th colspan="'.$colspan_month.'" class="bg-primary month" id="M'.($i+1-$colspan_month).'">'.strftime("%B",$horoCur[0]).' '.strftime("%Y", $horoCur[0]).'</th>';
|
||||
$colspan_month=1;
|
||||
}
|
||||
|
||||
// Days
|
||||
$td_headers[$i] .= ' D'.($i+1-$colspan_day);
|
||||
|
||||
if (isset($toutsujet[$i+1]) && strftime($date_format['txt_day'],$horoCur[0])==strftime($date_format['txt_day'],$horoNext[0])&&strftime("%B",$horoCur[0])==strftime("%B",$horoNext[0])){
|
||||
$colspan_day++;
|
||||
} else {
|
||||
$rbd = ($border[$i]) ? ' rbd' : '';
|
||||
$tr_days .= '<th colspan="'.$colspan_day.'" class="bg-primary day'.$rbd.'" id="D'.($i+1-$colspan_day).'">'.strftime($date_format['txt_day'],$horoCur[0]).'</th>';
|
||||
$colspan_day=1;
|
||||
}
|
||||
|
||||
// Hours
|
||||
$rbd = ($border[$i]) ? ' rbd' : '';
|
||||
if ($horoCur[1] !== "") {
|
||||
$tr_hours .= '<th class="bg-info'.$rbd.'" id="H'.$i.'" title="'.$horoCur[1].'">'.$horoCur[1].'</th>';
|
||||
$radio_title[$i] .= ' - '.$horoCur[1];
|
||||
$td_headers[$i] .= ' H'.$i;
|
||||
} else {
|
||||
$tr_hours .= '<th class="bg-info'.$rbd.'"></th>';
|
||||
}
|
||||
}
|
||||
|
||||
$border[count($border)-1] = false; // suppression de la bordure droite du dernier mois
|
||||
|
||||
$tr_months .= '<th></th></tr>';
|
||||
$tr_days .= '<th></th></tr>';
|
||||
$tr_hours .= '<th></th></tr>';
|
||||
|
||||
$thead = "\n".$tr_months."\n".$tr_days."\n".$tr_hours."\n";
|
||||
|
||||
// Subjects poll
|
||||
} else {
|
||||
|
||||
$tr_subjects = '<tr><th role="presentation"></th>';
|
||||
|
||||
foreach ($sujets as $i=>$sujet) {
|
||||
|
||||
$td_headers[$i]='';$radio_title[$i]=''; // init before concatenate
|
||||
|
||||
// Subjects
|
||||
preg_match_all('/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/',$sujet->sujet,$md_a_img); // Markdown [![alt](src)](href)
|
||||
preg_match_all('/!\[(.*?)\]\((.*?)\)/',$sujet->sujet,$md_img); // Markdown ![alt](src)
|
||||
preg_match_all('/\[(.*?)\]\((.*?)\)/',$sujet->sujet,$md_a); // Markdown [text](href)
|
||||
if (isset($md_a_img[2][0]) && $md_a_img[2][0]!='' && isset($md_a_img[3][0]) && $md_a_img[3][0]!='') { // [![alt](src)](href)
|
||||
|
||||
$th_subject_text = (isset($md_a_img[1][0]) && $md_a_img[1][0]!='') ? stripslashes($md_a_img[1][0]) : _("Choice") .' '.($i+1);
|
||||
$th_subject_html = '<a href="'.$md_a_img[3][0].'"><img src="'.$md_a_img[2][0].'" class="img-responsive" alt="'.$th_subject_text.'" /></a>';
|
||||
|
||||
} elseif (isset($md_img[2][0]) && $md_img[2][0]!='') { // ![alt](src)
|
||||
|
||||
$th_subject_text = (isset($md_img[1][0]) && $md_img[1][0]!='') ? stripslashes($md_img[1][0]) : _("Choice") .' '.($i+1);
|
||||
$th_subject_html = '<img src="'.$md_img[2][0].'" class="img-responsive" alt="'.$th_subject_text.'" />';
|
||||
|
||||
} elseif (isset($md_a[2][0]) && $md_a[2][0]!='') { // [text](href)
|
||||
|
||||
$th_subject_text = (isset($md_a[1][0]) && $md_a[1][0]!='') ? stripslashes($md_a[1][0]) : _("Choice") .' '.($i+1);
|
||||
$th_subject_html = '<a href="'.$md_a[2][0].'">'.$th_subject_text.'</a>';
|
||||
|
||||
} else { // text only
|
||||
|
||||
$th_subject_text = stripslashes($sujet->sujet);
|
||||
$th_subject_html = $th_subject_text;
|
||||
|
||||
}
|
||||
$tr_subjects .= '<th class="bg-info" id="S'.$i.'" title="'.$th_subject_text.'">'.$th_subject_html.'</th>';
|
||||
|
||||
$border[$i] = false;
|
||||
$td_headers[$i] .= 'S'.$i;
|
||||
$radio_title[$i] .= $th_subject_text;
|
||||
|
||||
}
|
||||
|
||||
$thead = $tr_subjects.'<th></th></tr>';
|
||||
}
|
||||
|
||||
// Print headers
|
||||
echo '
|
||||
<form name="formulaire" action="' . Utils::getUrlSondage($dsondage->poll_id) . '" method="POST">
|
||||
<input type="hidden" name="sondage" value="' . $numsondage . '"/>
|
||||
';
|
||||
if ($dsondage->format=="A-" || $dsondage->format=="D-") {
|
||||
echo '
|
||||
<div class="alert alert-danger">
|
||||
<p>' . _("The administrator locked this poll, votes and comments are frozen, it's not possible to participate anymore.") . '</p>
|
||||
<p aria-hidden="true"><b>' . _('Legend:'). '</b> <span class="glyphicon glyphicon-ok"></span> =' . _('Yes') . ', <b>(<span class="glyphicon glyphicon-ok"></span>)</b> = ' . _('Ifneedbe') . ', <span class="glyphicon glyphicon-ban-circle"></span> = ' . _('No') . '</p>
|
||||
</div>';
|
||||
} else {
|
||||
echo '
|
||||
<div class="alert alert-info">
|
||||
<p>' . _("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.") . '</p>
|
||||
<p aria-hidden="true"><b>' . _('Legend:'). '</b> <span class="glyphicon glyphicon-ok"></span> =' . _('Yes') . ', <b>(<span class="glyphicon glyphicon-ok"></span>)</b> = ' . _('Ifneedbe') . ', <span class="glyphicon glyphicon-ban-circle"></span> = ' . _('No') . '</p>
|
||||
</div>';
|
||||
}
|
||||
echo'
|
||||
<div class="hidden row scroll-buttons" aria-hidden="true">
|
||||
<div class="btn-group pull-right">
|
||||
<button class="btn btn-sm btn-link scroll-left" title="' . _('Scroll to the left') . '">
|
||||
<span class="glyphicon glyphicon-chevron-left"></span>
|
||||
</button>
|
||||
<button class="btn btn-sm btn-link scroll-right" title="' . _('Scroll to the right') . '">
|
||||
<span class="glyphicon glyphicon-chevron-right"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>'._('Votes of the poll ').'</h3>
|
||||
<div id="tableContainer" class="tableContainer">
|
||||
<table class="results">
|
||||
<caption class="sr-only">'._('Votes of the poll ').$title.'</caption>
|
||||
<thead>'. $thead . '</thead>
|
||||
<tbody>';
|
||||
|
||||
// Print poll results
|
||||
|
||||
//Usager pré-authentifié dans la liste?
|
||||
$user_mod = false;
|
||||
|
||||
//affichage des resultats actuels
|
||||
$somme[] = 0;
|
||||
$compteur = 0;
|
||||
|
||||
foreach ($users as $user) {
|
||||
|
||||
$ensemblereponses = $user->reponses;
|
||||
|
||||
//affichage du nom
|
||||
$nombase=str_replace("°","'",$user->nom);
|
||||
echo '<tr>
|
||||
<th class="bg-info">'.stripslashes($nombase).'</th>'."\n";
|
||||
|
||||
// ligne d'un usager pré-authentifié
|
||||
$mod_ok = !( USE_REMOTE_USER && isset($_SERVER['REMOTE_USER']) ) || ($nombase == $_SESSION['nom']);
|
||||
$user_mod |= $mod_ok;
|
||||
|
||||
// pour chaque colonne
|
||||
for ($k=0; $k < $nbcolonnes; $k++) {
|
||||
// on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs
|
||||
if ($compteur == $ligneamodifier) {
|
||||
|
||||
$car = substr($ensemblereponses, $k , 1);
|
||||
|
||||
// variable pour afficher la valeur cochée
|
||||
$car_html[0]='value="0"';$car_html[1]='value="1"';$car_html[2]='value="2"';
|
||||
switch ($car) {
|
||||
case "1": $car_html[1]='value="1" checked';break;
|
||||
case "2": $car_html[2]='value="2" checked';break;
|
||||
default: $car_html[0]='value="0" checked';break;
|
||||
}
|
||||
|
||||
echo '
|
||||
<td class="bg-info" headers="'.$td_headers[$k ].'">
|
||||
<ul class="list-unstyled choice">
|
||||
<li class="yes">
|
||||
<input type="radio" id="y-choice-'.$k.'" name="choix'.$k.'" '.$car_html[1].' />
|
||||
<label class="btn btn-default btn-xs" for="y-choice-'.$k.'" title="' . _('Vote "yes" for ') . $radio_title[$k] . '">
|
||||
<span class="glyphicon glyphicon-ok"></span><span class="sr-only">' . _('Yes') . '</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="ifneedbe">
|
||||
<input type="radio" id="i-choice-'.$k.'" name="choix'.$k.'" '.$car_html[2].' />
|
||||
<label class="btn btn-default btn-xs" for="i-choice-'.$k.'" title="' . _('Vote "ifneedbe" for ') . $radio_title[$k] . '">
|
||||
(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only">' . _('Ifneedbe') . '</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="no">
|
||||
<input type="radio" id="n-choice-'.$k.'" name="choix'.$k.'" '.$car_html[0].'/>
|
||||
<label class="btn btn-default btn-xs" for="n-choice-'.$k.'" title="' . _('Vote "no" for ') . $radio_title[$k] . '">
|
||||
<span class="glyphicon glyphicon-ban-circle"></span><span class="sr-only">' . _('No') . '</span>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</td>'."\n";
|
||||
|
||||
} else {
|
||||
$rbd = ($border[$k]) ? ' rbd' : '';
|
||||
$car = substr($ensemblereponses, $k, 1);
|
||||
switch ($car) {
|
||||
case "1": echo '<td class="bg-success text-success'.$rbd.'" headers="'.$td_headers[$k].'"><span class="glyphicon glyphicon-ok"></span><span class="sr-only"> ' . _('Yes') . '</span></td>'."\n";
|
||||
if (isset($somme[$k]) === false) {
|
||||
$somme[$k] = 0;
|
||||
}
|
||||
$somme[$k]++; break;
|
||||
case "2": echo '<td class="bg-warning text-warning'.$rbd.'" headers="'.$td_headers[$k].'">(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only"> ' . _('Yes') . _(', ifneedbe') . '</span></td>'."\n"; break;
|
||||
default: echo '<td class="bg-danger'.$rbd.'" headers="'.$td_headers[$k].'"><span class="sr-only">' . _('No') . '</span></td>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//a la fin de chaque ligne se trouve les boutons modifier
|
||||
if ($compteur != $ligneamodifier && ($dsondage->format=="A+"||$dsondage->format=="D+") && $mod_ok) {
|
||||
echo '
|
||||
<td>
|
||||
<button type="submit" class="btn btn-link btn-sm" name="modifierligne'.$compteur.'" title="'. _('Edit the line:') .' '.stripslashes($nombase).'">
|
||||
<span class="glyphicon glyphicon-pencil"></span><span class="sr-only">' . _('Edit') . '</span>
|
||||
</button>
|
||||
</td>'."\n";
|
||||
}
|
||||
|
||||
//demande de confirmation pour modification de ligne
|
||||
for ($i=0;$i<$nblignes;$i++) {
|
||||
if (isset($_POST["modifierligne$i"])) {
|
||||
if ($compteur == $i) {
|
||||
echo '<td style="padding:5px"><button type="submit" class="btn btn-success btn-xs" name="validermodifier'.$compteur.'" title="'. _('Save the choices') .' '.stripslashes($nombase).'">'. _('Save') .'</button></td>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$compteur++;
|
||||
echo '</tr>'."\n";
|
||||
}
|
||||
|
||||
// affichage de la ligne pour un nouvel utilisateur
|
||||
if (( !(USE_REMOTE_USER && isset($_SERVER['REMOTE_USER'])) || !$user_mod) && $ligneamodifier==-1 && ($dsondage->format!="A-" && $dsondage->format!="D-")) {
|
||||
//affichage de la case vide de texte pour un nouvel utilisateur
|
||||
echo '<tr id="vote-form">
|
||||
<td class="bg-info" style="padding:5px">
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
|
||||
<input type="text" id="nom" name="nom" class="form-control" title="'. _('Your name') .'" placeholder="'. _('Your name') .'" />
|
||||
</div>
|
||||
</td>'."\n";
|
||||
|
||||
//une ligne de checkbox pour le choix du nouvel utilisateur
|
||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
echo '
|
||||
<td class="bg-info" headers="'.$td_headers[$i].'">
|
||||
<ul class="list-unstyled choice">
|
||||
<li class="yes">
|
||||
<input type="radio" id="y-choice-'.$i.'" name="choix'.$i.'" value="1" />
|
||||
<label class="btn btn-default btn-xs" for="y-choice-'.$i.'" title="' . _('Vote "yes" for ') . $radio_title[$i] . '">
|
||||
<span class="glyphicon glyphicon-ok"></span><span class="sr-only">' . _('Yes') . '</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="ifneedbe">
|
||||
<input type="radio" id="i-choice-'.$i.'" name="choix'.$i.'" value="2" />
|
||||
<label class="btn btn-default btn-xs" for="i-choice-'.$i.'" title="' . _('Vote "ifneedbe" for ') . $radio_title[$i] . '">
|
||||
(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only">' . _('Ifneedbe') . '</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="no">
|
||||
<input type="radio" id="n-choice-'.$i.'" name="choix'.$i.'" value="0" checked/>
|
||||
<label class="btn btn-default btn-xs" for="n-choice-'.$i.'" title="' . _('Vote "no" for ') . $radio_title[$i] . '">
|
||||
<span class="glyphicon glyphicon-ban-circle"></span><span class="sr-only">' . _('No') . '</span>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</td>'."\n";
|
||||
}
|
||||
|
||||
// Affichage du bouton de formulaire pour inscrire un nouvel utilisateur dans la base
|
||||
echo '<td><button type="submit" class="btn btn-success btn-sm" name="boutonp" title="'. _('Save the choices') .'">'. _('Save') .'</button></td>
|
||||
</tr>'."\n";
|
||||
|
||||
}
|
||||
|
||||
// Addition and Best choice
|
||||
//affichage de la ligne contenant les sommes de chaque colonne
|
||||
$tr_addition = '<tr id="addition"><td>'. _("Addition") .'</td>';
|
||||
$meilleurecolonne = max($somme);
|
||||
$compteursujet = 0;
|
||||
$meilleursujet = '<ul style="list-style:none">';
|
||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
if (isset($somme[$i]) && $somme[$i] > 0 ) {
|
||||
if (in_array($i, array_keys($somme, max($somme)))){
|
||||
|
||||
$tr_addition .= '<td><span class="glyphicon glyphicon-star text-warning"></span><span>'.$somme[$i].'</span></td>';
|
||||
|
||||
$meilleursujet.= '<li><b>'.$radio_title[$i].'</b></li>';
|
||||
$compteursujet++;
|
||||
|
||||
} else {
|
||||
$tr_addition .= '<td>'.$somme[$i].'</td>';
|
||||
}
|
||||
} else {
|
||||
$tr_addition .= '<td></td>';
|
||||
}
|
||||
}
|
||||
$tr_addition .= '<td></td></tr>';
|
||||
|
||||
$meilleursujet = str_replace("°", "'", $meilleursujet).'</ul>';
|
||||
$vote_str = ($meilleurecolonne > 1) ? $vote_str = _('votes') : _('vote');
|
||||
|
||||
// Print Addition and Best choice
|
||||
echo $tr_addition.'
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="row">'."\n";
|
||||
|
||||
if ($compteursujet == 1) {
|
||||
echo '
|
||||
<div class="col-sm-12"><h3>' . _("Best choice") . '</h3></div>
|
||||
<div class="col-sm-6 col-sm-offset-3 alert alert-success">
|
||||
<p><span class="glyphicon glyphicon-star text-warning"></span> ' . _("The best choice at this time is:") . '</p>
|
||||
' . $meilleursujet . '
|
||||
<p>' . _("with") . ' <b>' . $meilleurecolonne . '</b> ' . $vote_str . '.</p>
|
||||
</div>'."\n";
|
||||
} elseif ($compteursujet > 1) {
|
||||
echo '
|
||||
<div class="col-sm-12"><h3>' . _("Best choices") . '</h3></div>
|
||||
<div class="col-sm-6 col-sm-offset-3 alert alert-success">
|
||||
<p><span class="glyphicon glyphicon-star text-warning"></span> ' . _("The bests choices at this time are:") . '</p>
|
||||
' . $meilleursujet . '
|
||||
<p>' . _("with") . ' <b>' . $meilleurecolonne . '</b> ' . $vote_str . '.</p>
|
||||
</div>'."\n";
|
||||
}
|
||||
|
||||
echo '
|
||||
</div>
|
||||
<hr role="presentation" />';
|
||||
|
||||
// Comments
|
||||
$comments = $connect->allCommentsByPollId($numsondage);
|
||||
|
||||
if (count($comments) != 0) {
|
||||
echo '<div><h3>' . _("Comments of polled people") . '</h3>'."\n";
|
||||
|
||||
while($dcomment = $comment_user->FetchNextObject(false)) {
|
||||
echo '
|
||||
<div class="comment">
|
||||
<b>'.stripslashes($dcomment->usercomment). ' :</b>
|
||||
<span class="comment">' . stripslashes(nl2br($dcomment->comment)) . '</span>
|
||||
</div>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
if ($dsondage->format!="A-" && $dsondage->format!="D-") {
|
||||
echo '
|
||||
<div class="hidden-print alert alert-info">
|
||||
<div class="col-md-6 col-md-offset-3">
|
||||
<fieldset id="add-comment"><legend>' . _("Add a comment in the poll") . '</legend>
|
||||
<div class="form-group">
|
||||
<p><label for="commentuser">'. _("Your name") .'</label><input type=text class="form-control" name="commentuser" id="commentuser" /></p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<p><label for="comment">'. _("Your comment") .'</label><br />
|
||||
<textarea name="comment" id="comment" class="form-control" rows="2" cols="40"></textarea></p>
|
||||
</div>
|
||||
<p class="text-center"><input type="submit" name="ajoutcomment" value="'. _("Send the comment") .'" class="btn btn-success"></p>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</form>';
|
||||
|
||||
bandeau_pied();
|
||||
$smarty->display('studs.tpl');
|
||||
|
4
tpl/footer.tpl
Normal file
4
tpl/footer.tpl
Normal file
@ -0,0 +1,4 @@
|
||||
</main>
|
||||
</div> <!-- .container -->
|
||||
</body>
|
||||
</html>
|
29
tpl/head.tpl
Normal file
29
tpl/head.tpl
Normal file
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{$lang}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
{if !empty($title)}
|
||||
<title>{$title} - {$APPLICATION_NAME}</title>
|
||||
{else}
|
||||
<title>{$APPLICATION_NAME}</title>
|
||||
{/if}
|
||||
|
||||
<link rel="stylesheet" href="{$SERVER_URL}css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="{$SERVER_URL}css/datepicker3.css">
|
||||
<link rel="stylesheet" href="{$SERVER_URL}css/style.css">
|
||||
<link rel="stylesheet" href="{$SERVER_URL}css/frama.css">
|
||||
<link rel="stylesheet" href="{$SERVER_URL}css/print.css" media="print">
|
||||
<script type="text/javascript" src="{$SERVER_URL}js/jquery-1.11.1.min.js"></script>
|
||||
<script type="text/javascript" src="{$SERVER_URL}js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="{$SERVER_URL}js/bootstrap-datepicker.js"></script>
|
||||
<script type="text/javascript" src="{$SERVER_URL}js/locales/bootstrap-datepicker.{$lang}.js"></script>
|
||||
<script type="text/javascript" src="{$SERVER_URL}js/core.js"></script>
|
||||
|
||||
{if !empty($nav_js)}
|
||||
<script src="/nav/nav.js" id="nav_js" type="text/javascript" charset="utf-8"></script><!-- /Framanav -->
|
||||
{/if}
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="container ombre">
|
21
tpl/header.tpl
Normal file
21
tpl/header.tpl
Normal file
@ -0,0 +1,21 @@
|
||||
<header role="banner">
|
||||
{if count($langs)>1}
|
||||
<form method="post" action="#">
|
||||
<div class="input-group input-group-sm pull-right col-md-2 col-xs-4">
|
||||
<select name="lang" class="form-control" title="${_("Select the language")}" >
|
||||
{foreach $langs as $lang_key=>$lang_value}
|
||||
<option lang="{$lang_key|truncate:2:''}" selected value="{$lang_key}">{$lang_value}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-default btn-sm" title="{_("Change the language")}">OK</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
{/if}
|
||||
|
||||
<h1><a href="{$SERVER_URL}" title="{_("Home")} - {$APPLICATION_NAME}"><img src="{$TITLE_IMAGE}" alt="{$APPLICATION_NAME}"/></a></h1>
|
||||
{if !empty($title)}<h2 class="lead"><i>{$title}</i></h2>{/if}
|
||||
<hr class="trait" role="presentation" />
|
||||
</header>
|
||||
<main role="main">
|
163
tpl/studs.tpl
Normal file
163
tpl/studs.tpl
Normal file
@ -0,0 +1,163 @@
|
||||
{include file='head.tpl'}
|
||||
{include file='header.tpl'}
|
||||
|
||||
{* Global informations about the current poll *}
|
||||
|
||||
<div class="jumbotron">
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<h3>{$poll->title}</h3>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="btn-group pull-right">
|
||||
<button onclick="javascript:print(); return false;" class="btn btn-default"><span class="glyphicon glyphicon-print"></span>{_('Print')}</button>
|
||||
<button onclick="window.location.href='{$SERVER_URL}exportcsv.php?poll={$poll_id}';return false;" class="btn btn-default"><span class="glyphicon glyphicon-download-alt"></span>{_('Export to CSV')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="form-group">
|
||||
<h4 class="control-label">{_("Initiator of the poll")}</h4>
|
||||
<p class="form-control-static">{$poll->admin_name}</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="public-link"><a class="public-link" href="{$poll_id|poll_url}">{_("Public link of the poll")}<span class="btn-link glyphicon glyphicon-link"></span></a></label>
|
||||
<input class="form-control" id="public-link" type="text" readonly="readonly" value="{$poll_id|poll_url}" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if !empty($poll->comment)}
|
||||
<div class="form-group col-md-7">
|
||||
<h4 class="control-label">{_("Description")}</h4><br />
|
||||
<p class="form-control-static well">{$poll->comment}</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{* Information about voting *}
|
||||
|
||||
{if $poll->active}
|
||||
<div class="alert alert-info">
|
||||
<p>{_("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.")}</p>
|
||||
<p aria-hidden="true"><b>{_('Legend:')}</b> <span class="glyphicon glyphicon-ok"></span> = {_('Yes')}, <b>(<span class="glyphicon glyphicon-ok"></span>)</b> = {_('Ifneedbe')}, <span class="glyphicon glyphicon-ban-circle"></span> = {_('No')}</p>
|
||||
</div>
|
||||
{else}
|
||||
<div class="alert alert-danger">
|
||||
<p>{_("The administrator locked this poll, votes and comments are frozen, it's not possible to participate anymore.")}</p>
|
||||
<p aria-hidden="true"><b>{_('Legend:')}</b> <span class="glyphicon glyphicon-ok"></span> = {_('Yes')}, <b>(<span class="glyphicon glyphicon-ok"></span>)</b> = {_('Ifneedbe')}, <span class="glyphicon glyphicon-ban-circle"></span> = {_('No')}</p>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{* Scroll left and right *}
|
||||
|
||||
<div class="hidden row scroll-buttons" aria-hidden="true">
|
||||
<div class="btn-group pull-right">
|
||||
<button class="btn btn-sm btn-link scroll-left" title="{_('Scroll to the left')}">
|
||||
<span class="glyphicon glyphicon-chevron-left"></span>
|
||||
</button>
|
||||
<button class="btn btn-sm btn-link scroll-right" title="{_('Scroll to the right')}">
|
||||
<span class="glyphicon glyphicon-chevron-right"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{* Vote table *}
|
||||
|
||||
<h3>{_('Votes of the poll')}</h3>
|
||||
<div id="tableContainer" class="tableContainer">
|
||||
<table class="results">
|
||||
<caption class="sr-only">{_('Votes of the poll')} {$poll->title}</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th role="presentation"></th>
|
||||
{foreach $slots as $id=>$slot}
|
||||
<th colspan="{$slot->moments|count}" class="bg-primary month" id="M{$id}">{$slot->day|date_format:'%B %Y'}</th>
|
||||
{/foreach}
|
||||
<th></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th role="presentation"></th>
|
||||
{foreach $slots as $id=>$slot}
|
||||
<th colspan="{$slot->moments|count}" class="bg-primary day" id="D{$id}">{$slot->day|date_format:$day_format}</th>
|
||||
{/foreach}
|
||||
<th></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th role="presentation"></th>
|
||||
{foreach $slots as $slot}
|
||||
{foreach $slot->moments as $id=>$moment}
|
||||
<th colspan="1" class="bg-info" id="H{$id}">{$moment}</th>
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach $votes as $vote}
|
||||
<tr>
|
||||
<th class="bg-info">{$vote->name}</th>
|
||||
|
||||
{if $editingVoteId == $vote->id}
|
||||
{foreach $vote->choices as $k=>$choice}
|
||||
{* Edited line *}
|
||||
|
||||
<td class="bg-info" headers="'.$td_headers[$k ].'">
|
||||
<ul class="list-unstyled choice">
|
||||
<li class="yes">
|
||||
<input type="radio" id="y-choice-{$k}" name="choix{$k}" '.$car_html[1].' />
|
||||
<label class="btn btn-default btn-xs" for="y-choice-{$k}" title="{_('Vote "yes" for ')} . $radio_title[$k] . '">
|
||||
<span class="glyphicon glyphicon-ok"></span><span class="sr-only">{_('Yes')}</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="ifneedbe">
|
||||
<input type="radio" id="i-choice-{$k}" name="choix{$k}" '.$car_html[2].' />
|
||||
<label class="btn btn-default btn-xs" for="i-choice-{$k}" title="{_('Vote "ifneedbe" for ')} . $radio_title[$k] . '">
|
||||
(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only">{_('Ifneedbe')}</span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="no">
|
||||
<input type="radio" id="n-choice-{$k}" name="choix{$k}" '.$car_html[0].'/>
|
||||
<label class="btn btn-default btn-xs" for="n-choice-{$k}" title="{_('Vote "no" for ')} . $radio_title[$k] . '">
|
||||
<span class="glyphicon glyphicon-ban-circle"></span><span class="sr-only">{_('No')}</span>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
<td></td>
|
||||
{/foreach}
|
||||
{else}
|
||||
{foreach $vote->choices as $k=>$choice}
|
||||
{* Voted line *}
|
||||
|
||||
{if $choice==1}
|
||||
<td class="bg-success text-success" headers="'.$td_headers[$k].'"><span class="glyphicon glyphicon-ok"></span><span class="sr-only">{_('Yes')}</span></td>
|
||||
{else if $choice==2}
|
||||
<td class="bg-warning text-warning" headers="'.$td_headers[$k].'">(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only">{_('Ifneedbe')}</span></td>
|
||||
{else}
|
||||
<td class="bg-danger" headers="'.$td_headers[$k].'"><span class="sr-only">{_('No')}</span></td>
|
||||
{/if}
|
||||
|
||||
{/foreach}
|
||||
|
||||
{if $poll->active && $poll->editable}
|
||||
<td>
|
||||
<form action="{$poll_id|poll_url}" method="POST">
|
||||
<input type="hidden" name="edit_vote" value="{$vote->id}"/>
|
||||
<button type="submit" class="btn btn-link btn-sm" title="{_('Edit the line:')} {$vote->name}">
|
||||
<span class="glyphicon glyphicon-pencil"></span><span class="sr-only">' . _('Edit') . '</span>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
{else}
|
||||
<td></td>
|
||||
{/if}
|
||||
{/if}
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{include file='footer.tpl'}
|
Loading…
Reference in New Issue
Block a user