2011-05-15 01:32:47 +02:00
< ? php
2014-09-04 17:52:18 +02:00
/**
* 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 )
*
2014-07-04 11:21:31 +02:00
* =============================
2014-09-04 17:52:18 +02:00
*
* 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
*
2014-07-04 11:21:31 +02:00
* Auteurs de STUdS ( projet initial ) : Guilhem BORGHESI ( borghesi @ unistra . fr ) et Raphaël DROZ
2014-09-04 17:52:18 +02:00
* Auteurs de Framadate / OpenSondage : Framasoft ( https :// github . com / framasoft )
2014-07-04 11:21:31 +02:00
*/
2014-09-04 17:52:18 +02:00
namespace Framadate ;
2011-05-15 01:32:47 +02:00
session_start ();
//setlocale(LC_TIME, "fr_FR");
2014-09-04 17:52:18 +02:00
include_once __DIR__ . '/app/inc/init.php' ;
2011-05-15 03:56:54 +02:00
if ( file_exists ( 'bandeaux_local.php' )) {
2014-09-04 17:52:18 +02:00
include_once ( 'bandeaux_local.php' );
2011-05-15 03:56:54 +02:00
} else {
2014-09-04 17:52:18 +02:00
include_once ( 'bandeaux.php' );
2011-05-15 03:56:54 +02:00
}
2011-05-15 01:32:47 +02:00
2011-05-15 01:49:29 +02:00
// recuperation du numero de sondage admin (24 car.) dans l'URL
2014-12-07 16:47:35 +01:00
if ( ! empty ( $_GET [ 'sondage' ]) && is_string ( $_GET [ 'sondage' ]) && strlen ( $_GET [ 'sondage' ]) === 24 ) {
$admin_poll_id = $_GET [ " sondage " ];
// on découpe le résultat pour avoir le numéro de sondage (16 car.)
$poll_id = substr ( $admin_poll_id , 0 , 16 );
2011-05-15 01:49:29 +02:00
}
2011-05-15 01:32:47 +02:00
2014-12-07 16:47:35 +01:00
if ( preg_match ( " ;[ \ w \ d] { 24};i " , $admin_poll_id )) {
$prepared = $connect -> prepare ( 'SELECT * FROM sondage WHERE admin_poll_id = ?' );
$prepared -> execute ( array ( $admin_poll_id ));
$poll = $prepared -> fetch ();
$prepared -> closeCursor ();
2014-12-12 13:43:43 +01:00
2014-12-07 16:47:35 +01:00
$prepared = $connect -> prepare ( 'SELECT * FROM sujet_studs WHERE id_sondage = ?' );
$prepared -> execute ( array ( $poll_id ));
$sujets = $prepared -> fetchAll ();
$prepared = $connect -> prepare ( 'SELECT * FROM user_studs WHERE id_sondage = ? order by id_users' );
$prepared -> execute ( array ( $poll_id ));
$users = $prepared -> fetchAll ();
2011-05-15 01:32:47 +02:00
}
//verification de l'existence du sondage, s'il n'existe pas on met une page d'erreur
2014-12-07 16:47:35 +01:00
if ( ! $poll || ! $sujets ) {
Utils :: print_header ( _ ( 'Error!' ));
2014-09-04 17:52:18 +02:00
2014-12-07 16:47:35 +01:00
bandeau_titre ( _ ( 'Error!' ));
2014-09-04 17:52:18 +02:00
echo '
< div class = " alert alert-warning " >
2014-12-07 16:47:35 +01:00
< h2 > ' . _(' This poll doesn\ 't exist !' ) . ' </ h2 >
2014-09-04 17:52:18 +02:00
< p > ' . _(' Back to the homepage of ') . ' < a href = " ' . Utils::get_server_name() . ' " > ' . NOMAPPLICATION . ' </ a ></ p >
</ div > ' . " \n " ;
bandeau_pied ();
die ();
2011-05-15 01:32:47 +02:00
}
2014-11-14 17:35:22 +01:00
// Send email (only once during the session) to alert admin of the change he made. ==> two modifications (comment, title, description, ...) on differents polls in the same session will generate only one mail.
2014-12-07 16:47:35 +01:00
$email_admin = $poll -> admin_mail ;
$poll_title = $poll -> title ;
2014-11-15 00:59:33 +01:00
$smtp_allowed = $config [ 'use_smtp' ];
2014-10-21 01:31:26 +02:00
function send_mail_admin () {
global $email_admin ;
2014-11-14 17:35:22 +01:00
global $poll_title ;
2014-12-12 13:43:43 +01:00
global $admin_poll_id ;
2014-11-18 18:38:00 +01:00
global $smtp_allowed ;
2014-11-15 00:59:33 +01:00
if ( $smtp_allowed == true ){
2014-12-07 16:47:35 +01:00
if ( ! isset ( $_SESSION [ 'mail_admin_sent' ])) {
2014-11-14 17:35:22 +01:00
Utils :: sendEmail ( $email_admin ,
_ ( " [ADMINISTRATOR] New settings for your poll " ) . ' ' . stripslashes ( $poll_title ),
_ ( " You have changed the settings of your poll. \n You can modify this poll with this link " ) .
2014-12-12 13:43:43 +01:00
" : \n \n " . Utils :: getUrlSondage ( $admin_poll_id , true ) . " \n \n " .
2014-11-14 17:35:22 +01:00
_ ( " Thanks for your confidence. " ) . " \n " . NOMAPPLICATION
);
$_SESSION [ " mail_admin_sent " ] = true ;
}
}
2014-10-21 01:31:26 +02:00
}
2011-05-15 01:32:47 +02:00
//si la valeur du nouveau titre est valide et que le bouton est activé
2014-09-04 17:52:18 +02:00
if ( isset ( $_POST [ " boutonnouveautitre " ])) {
if ( Utils :: issetAndNoEmpty ( 'nouveautitre' ) === false ) {
$err |= TITLE_EMPTY ;
} else {
2014-10-21 01:31:26 +02:00
//Update SQL database with new title
2014-09-04 17:52:18 +02:00
$nouveautitre = htmlentities ( html_entity_decode ( $_POST [ 'nouveautitre' ], ENT_QUOTES , 'UTF-8' ), ENT_QUOTES , 'UTF-8' );
$sql = 'UPDATE sondage SET titre = ' . $connect -> Param ( 'nouveautitre' ) . ' WHERE id_sondage = ' . $connect -> Param ( 'numsondage' );
$sql = $connect -> Prepare ( $sql );
2013-03-04 19:46:06 +01:00
2014-10-21 01:31:26 +02:00
//Email sent to the admin
2014-12-12 13:43:43 +01:00
if ( $connect -> Execute ( $sql , array ( $nouveautitre , $poll_id ))) {
2014-11-14 17:35:22 +01:00
send_mail_admin ();
}
2011-05-22 02:13:44 +02:00
}
2011-05-15 01:32:47 +02:00
}
2013-03-04 19:46:06 +01:00
2011-05-15 01:32:47 +02:00
// si le bouton est activé, quelque soit la valeur du champ textarea
2014-12-07 16:47:35 +01:00
if ( isset ( $_POST [ 'boutonnouveauxcommentaires' ])) {
if ( empty ( $_POST [ 'nouveautitre' ])) {
2014-09-04 17:52:18 +02:00
$err |= COMMENT_EMPTY ;
} else {
$commentaires = htmlentities ( html_entity_decode ( $_POST [ 'nouveauxcommentaires' ], ENT_QUOTES , 'UTF-8' ), ENT_QUOTES , 'UTF-8' );
2013-03-04 19:46:06 +01:00
2014-10-21 01:31:26 +02:00
//Update SQL database with new description
2014-12-07 16:47:35 +01:00
$prepared = $connect -> prepare ( 'UPDATE sondage SET commentaires = ? WHERE id_sondage = ?' );
$prepared -> execute ( array ( $commentaires , $poll_id ));
2014-09-04 17:52:18 +02:00
2014-10-21 01:31:26 +02:00
//Email sent to the admin
2014-12-12 13:43:43 +01:00
if ( $connect -> Execute ( $sql , array ( $commentaires , $poll_id ))) {
2014-10-21 01:31:26 +02:00
send_mail_admin ();
2014-09-04 17:52:18 +02:00
}
2011-05-22 02:13:44 +02:00
}
2011-05-15 01:32:47 +02:00
}
//si la valeur de la nouvelle adresse est valide et que le bouton est activé
2014-09-04 17:52:18 +02:00
if ( isset ( $_POST [ " boutonnouvelleadresse " ])) {
2014-12-07 16:47:35 +01:00
if ( empty ( $_POST [ 'nouvelleadresse' ]) || Utils :: isValidEmail ( $_POST [ " nouvelleadresse " ]) === false ) {
2014-09-04 17:52:18 +02:00
$err |= INVALID_EMAIL ;
} else {
$nouvelleadresse = htmlentities ( html_entity_decode ( $_POST [ 'nouvelleadresse' ], ENT_QUOTES , 'UTF-8' ), ENT_QUOTES , 'UTF-8' );
2013-03-04 19:46:06 +01:00
2014-10-21 01:31:26 +02:00
//Update SQL database with new email
2014-12-07 16:47:35 +01:00
$prepared = $connect -> prepare ( 'UPDATE sondage SET mail_admin = ? WHERE id_sondage = ?' );
$executed = $prepared -> execute ( array ( $nouvelleadresse , $poll_id ));
2014-09-04 17:52:18 +02:00
2014-10-21 01:31:26 +02:00
//Email sent to the admin
2014-12-07 16:47:35 +01:00
if ( $executed ) {
2014-10-21 01:31:26 +02:00
send_mail_admin ();
2014-09-04 17:52:18 +02:00
}
2011-05-22 02:13:44 +02:00
}
2011-05-15 01:32:47 +02:00
}
2014-12-07 16:47:35 +01:00
// TODO OPZ : Revoir ce que fait ce truc exactament
2014-10-21 01:31:26 +02:00
//New poll rules
if ( isset ( $_POST [ " btn_poll_rules " ])) {
echo '<!-- ' ; print_r ( $_POST ); echo ' -->' ;
if ( $_POST [ 'poll_rules' ] == '+' ) {
$new_poll_rules = substr ( $dsondage -> format , 0 , 1 ) . '+' ;
} elseif ( $_POST [ 'poll_rules' ] == '-' ) {
$new_poll_rules = substr ( $dsondage -> format , 0 , 1 ) . '-' ;
} else {
$new_poll_rules = substr ( $dsondage -> format , 0 , 1 );
}
//Update SQL database with new rules
2014-12-07 16:47:35 +01:00
$prepared = $connect -> prepare ( 'UPDATE sondage SET format = ? WHERE id_sondage = ?' );
$executed = $prepared -> execute ( array ( $new_poll_rules , $poll_id ));
2014-10-21 01:31:26 +02:00
//Email sent to the admin
2014-12-07 16:47:35 +01:00
if ( $executed ) {
2014-10-21 01:31:26 +02:00
send_mail_admin ();
}
}
2011-05-15 01:32:47 +02:00
// reload
2014-12-07 16:47:35 +01:00
// TODO OPZ Pourquoi recharger
// $dsujet= $sujets->FetchObject(false);
// $dsondage= $sondage->FetchObject(false);
2011-05-15 01:32:47 +02:00
2014-12-07 16:47:35 +01:00
if ( isset ( $_POST [ 'ajoutsujet' ])) {
2014-12-12 13:43:43 +01:00
Utils :: print_header ( _ ( 'Add a column' ) . ' - ' . stripslashes ( $poll -> title ));
2011-05-15 03:56:54 +02:00
2014-12-07 16:47:35 +01:00
bandeau_titre ( _ ( 'Make your polls' ));
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
//on recupere les données et les sujets du sondage
echo '
< div class = " row " >
< div class = " col-md-6 col-md-offset-3 " >
2014-12-12 13:43:43 +01:00
< form name = " formulaire " class = " form-horizontal " action = " ' . Utils::getUrlSondage( $admin_poll_id , true) . ' " method = " POST " >
2014-09-04 17:52:18 +02:00
< h2 > ' . _("Column' s adding " ) . '</h2>'. " \n " ;
2014-12-12 13:43:43 +01:00
if ( $poll -> format == " A " ){
2014-09-04 17:52:18 +02:00
echo '
< div class = " form-group " >
< label for = " nouvellecolonne " class = " col-md-6 " > ' . _("Add a column") .' :</ label >
< div class = " col-md-6 " >
< input type = " text " id = " nouvellecolonne " name = " nouvellecolonne " class = " form-control " />
</ div >
</ div > ' . " \n " ;
} else {
2014-12-12 13:43:43 +01:00
// ajout d'une date avec creneau horaire
2014-09-04 17:52:18 +02:00
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 >
< div class = " form-group " >
< label for = " newdate " class = " col-md-4 " > '. _("Day") .' </ label >
< div class = " col-md-8 " >
< div class = " input-group date " >
< span class = " input-group-addon " >< i class = " glyphicon glyphicon-calendar " ></ i ></ span >
< input type = " text " id = " newdate " data - date - format = " '. _( " dd / mm / yyyy " ) .' " aria - describedby = " dateformat " name = " newdate " class = " form-control " placeholder = " '. _( " dd / mm / yyyy " ) .' " />
</ div >
< span id = " dateformat " class = " sr-only " > '. _("(dd/mm/yyyy)") .' </ span >
</ div >
</ div >
< div class = " form-group " >
< label for = " newhour " class = " col-md-4 " > '. _("Time") .' </ label >
< div class = " col-md-8 " >
< input type = " text " id = " newhour " name = " newhour " class = " form-control " />
</ div >
</ div > ' ;
2011-05-15 03:56:54 +02:00
}
2014-09-04 17:52:18 +02:00
echo '
< p class = " text-center " >
< button class = " btn btn-default " type = " submit " value = " retoursondage " name = " retoursondage " > '. _(' Back to the poll '). ' </ button >
< button type = " submit " name = " ajoutercolonne " class = " btn btn-success " > '. _(' Add a column '). ' </ button >
</ p >
</ form >
</ div >
</ div > ' ;
2014-07-04 11:21:31 +02:00
2014-09-04 17:52:18 +02:00
bandeau_pied ();
2011-05-15 03:56:54 +02:00
2014-09-04 17:52:18 +02:00
die ();
}
2011-05-15 03:56:54 +02:00
2014-09-04 17:52:18 +02:00
if ( isset ( $_POST [ " suppressionsondage " ])) {
2014-12-12 13:43:43 +01:00
Utils :: print_header ( _ ( " Confirm removal of your poll " ) . ' - ' . stripslashes ( $dsondage -> title ));
2011-06-23 16:52:10 +02:00
2014-09-04 17:52:18 +02:00
bandeau_titre ( _ ( " Confirm removal of your poll " ));
2011-06-23 16:52:10 +02:00
2014-09-04 17:52:18 +02:00
echo '
2014-12-12 13:43:43 +01:00
< form name = " formulaire " action = " ' . Utils::getUrlSondage( $admin_poll_id , true) . ' " method = " POST " >
2014-09-04 17:52:18 +02:00
< 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 >
< button type = " submit " name = " confirmesuppression " value = " " class = " btn btn-danger " > '._("Remove this poll!").' </ button ></ p >
</ div >
</ form > ' ;
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
bandeau_pied ();
2011-05-15 01:32:47 +02:00
2014-09-04 17:52:18 +02:00
die ();
2011-07-03 00:10:13 +02:00
}
2014-10-21 01:31:26 +02:00
// Remove all the comments
2014-12-07 16:47:35 +01:00
if ( isset ( $_POST [ 'removecomments' ])) {
2014-10-21 01:31:26 +02:00
$sql = 'DELETE FROM comments WHERE id_sondage=' . $connect -> Param ( 'numsondage' );
$sql = $connect -> Prepare ( $sql );
2014-12-12 13:43:43 +01:00
$cleaning = $connect -> Execute ( $sql , array ( $poll_id ));
2014-10-21 01:31:26 +02:00
}
// Remove all the votes
if ( isset ( $_POST [ " removevotes " ])) {
$sql = 'DELETE FROM user_studs WHERE id_sondage=' . $connect -> Param ( 'numsondage' );
$sql = $connect -> Prepare ( $sql );
2014-12-12 13:43:43 +01:00
$cleaning = $connect -> Execute ( $sql , array ( $poll_id ));
2014-10-21 01:31:26 +02:00
}
2011-05-15 01:32:47 +02:00
//action si bouton confirmation de suppression est activé
2014-09-04 17:52:18 +02:00
if ( isset ( $_POST [ " confirmesuppression " ])) {
$nbuser = $user_studs -> RecordCount ();
$date = date ( 'H:i:s d/m/Y:' );
2014-12-12 13:43:43 +01:00
if ( Utils :: remove_sondage ( $connect , $poll_id )) {
2014-09-04 17:52:18 +02:00
// 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' );
2014-10-21 01:31:26 +02:00
// Email sent
send_mail_admin ();
2014-09-04 17:52:18 +02:00
//affichage de l'ecran de confirmation de suppression de sondage
2014-09-29 16:33:15 +02:00
Utils :: print_header ( _ ( " Your poll has been removed! " ));
2014-09-04 17:52:18 +02:00
bandeau_titre ( _ ( " Make your polls " ));
echo '
< div class = " alert alert-success text-center " >
< h2 > ' . _("Your poll has been removed!") . ' </ h2 >
< p > ' . _(' Back to the homepage of ') . ' < a href = " ' . Utils::get_server_name() . ' " > ' . NOMAPPLICATION . ' </ a ></ p >
</ div >
</ form > ' . " \n " ;
bandeau_pied ();
die ();
}
2011-05-15 01:32:47 +02:00
}
// quand on ajoute un commentaire utilisateur
2014-09-04 17:52:18 +02:00
if ( isset ( $_POST [ 'ajoutcomment' ])) {
2014-12-07 16:47:35 +01:00
if ( empty ( $_POST [ 'commentuser' ])) {
2014-09-04 17:52:18 +02:00
$err |= COMMENT_USER_EMPTY ;
} else {
$comment_user = htmlentities ( html_entity_decode ( $_POST [ " commentuser " ], ENT_QUOTES , 'UTF-8' ), ENT_QUOTES , 'UTF-8' );
}
2013-03-04 19:46:06 +01:00
2014-12-07 16:47:35 +01:00
if ( empty ( $_POST [ 'comment' ])) {
2014-09-04 17:52:18 +02:00
$err |= COMMENT_EMPTY ;
2011-05-22 02:13:44 +02:00
}
2011-05-15 01:32:47 +02:00
2014-12-07 16:47:35 +01:00
if ( ! empty ( $_POST [ 'comment' ]) && ! Utils :: is_error ( COMMENT_EMPTY ) && ! Utils :: is_error ( NO_POLL ) && ! Utils :: is_error ( COMMENT_USER_EMPTY )) {
2014-09-04 17:52:18 +02:00
$comment = htmlentities ( html_entity_decode ( $_POST [ " comment " ], ENT_QUOTES , 'UTF-8' ), 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 );
2014-12-12 13:43:43 +01:00
$comment_user_doublon = $connect -> Execute ( $sql , array ( $poll_id ));
2014-09-04 17:52:18 +02:00
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 ;
};
}
}
2011-05-15 01:32:47 +02:00
2014-09-04 17:52:18 +02:00
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 );
2014-12-12 13:43:43 +01:00
$comments = $connect -> Execute ( $sql , array ( $poll_id , $comment , $comment_user ));
2014-09-04 17:52:18 +02:00
if ( $comments === false ) {
$err |= COMMENT_INSERT_FAILED ;
}
}
}
2011-05-15 01:32:47 +02:00
}
2014-12-07 16:47:35 +01:00
$nbcolonnes = count ( $sujets );
$nblignes = count ( $users );
2011-05-15 01:32:47 +02:00
//si il n'y a pas suppression alors on peut afficher normalement le tableau
2011-05-15 03:56:54 +02:00
//action si le bouton participer est cliqué
2014-09-04 17:52:18 +02:00
if ( isset ( $_POST [ " boutonp " ])) {
//si on a un nom dans la case texte
2014-12-12 13:43:43 +01:00
if ( ! empty ( $_POST [ 'nom' ])){
2014-09-04 17:52:18 +02:00
$nouveauchoix = '' ;
$erreur_prenom = false ;
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 ;
}
}
}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
$nom = htmlentities ( html_entity_decode ( $_POST [ " nom " ], ENT_QUOTES , 'UTF-8' ), ENT_QUOTES , 'UTF-8' );
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
while ( $user = $user_studs -> FetchNextObject ( false )) {
if ( $nom == $user -> nom ){
$erreur_prenom = " yes " ;
}
}
// Ecriture des choix de l'utilisateur dans la base
if ( ! $erreur_prenom ) {
$sql = 'INSERT INTO user_studs (nom, id_sondage, reponses) VALUES (' .
$connect -> Param ( 'nom' ) . ',' .
$connect -> Param ( 'numsondage' ) . ',' .
$connect -> Param ( 'nouveauchoix' ) . ')' ;
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
$sql = $connect -> Prepare ( $sql );
2014-12-12 13:43:43 +01:00
$connect -> Execute ( $sql , array ( $nom , $poll_id , $nouveauchoix ));
2014-09-04 17:52:18 +02:00
}
2011-05-15 03:56:54 +02:00
}
}
//action quand on ajoute une colonne au format AUTRE
2014-12-12 13:43:43 +01:00
if ( isset ( $_POST [ " ajoutercolonne " ]) && ! empty ( $_POST [ 'nouvellecolonne' ]) && $poll -> format == " A " ) {
2014-09-04 17:52:18 +02:00
$nouveauxsujets = $dsujet -> sujet ;
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
//on rajoute la valeur a la fin de tous les sujets deja entrés
$nouveauxsujets .= " , " ;
$nouveauxsujets .= str_replace ( " , " , " " , $_POST [ " nouvellecolonne " ]);
$nouveauxsujets = htmlentities ( html_entity_decode ( $nouveauxsujets , ENT_QUOTES , 'UTF-8' ), ENT_QUOTES , 'UTF-8' );
2012-01-09 02:18:25 +01:00
2014-09-04 17:52:18 +02:00
//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 );
2014-12-12 13:43:43 +01:00
if ( $connect -> Execute ( $sql , array ( $nouveauxsujets , $poll_id ))) {
2014-10-21 01:31:26 +02:00
send_mail_admin ();
2014-09-04 17:52:18 +02:00
}
2011-05-15 03:56:54 +02:00
}
2014-12-12 13:43:43 +01:00
// [begin] action quand on ajoute une colonne au format DATE
if ( isset ( $_POST [ 'ajoutercolonne' ]) && $dsondage -> format == 'D' ) {
2013-03-04 19:46:06 +01:00
2014-12-12 13:43:43 +01:00
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 ));
2013-03-04 19:46:06 +01:00
2014-12-12 13:43:43 +01:00
if ( ! empty ( $_POST [ " newhour " ])){
$new_choice .= '@' . $_POST [ " newhour " ];
2014-09-04 17:52:18 +02:00
}
2013-03-04 19:46:06 +01:00
2014-12-12 13:43:43 +01:00
// TODO OPZ Delete the code below
// TODO OPZ Insert new choice
// TODO OPZ Update users votes (add "0" in the right column^^)
2014-09-04 17:52:18 +02:00
//on rajoute la valeur dans les valeurs
$datesbase = explode ( " , " , $dsujet -> sujet );
$taillebase = sizeof ( $datesbase );
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
//recherche de l'endroit de l'insertion de la nouvelle date dans les dates deja entrées dans le tableau
if ( $nouvelledate < $datesbase [ 0 ]) {
$cleinsertion = 0 ;
} elseif ( $nouvelledate > $datesbase [ $taillebase - 1 ]) {
$cleinsertion = count ( $datesbase );
} else {
for ( $i = 0 ; $i < count ( $datesbase ); $i ++ ) {
$j = $i + 1 ;
if ( $nouvelledate > $datesbase [ $i ] && $nouvelledate < $datesbase [ $j ]) {
$cleinsertion = $j ;
}
}
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
array_splice ( $datesbase , $cleinsertion , 0 , $nouvelledate );
$cle = array_search ( $nouvelledate , $datesbase );
$dateinsertion = '' ;
for ( $i = 0 ; $i < count ( $datesbase ); $i ++ ) {
$dateinsertion .= " , " ;
$dateinsertion .= $datesbase [ $i ];
}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
$dateinsertion = substr ( " $dateinsertion " , 1 );
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
//mise a jour avec les nouveaux sujets dans la base
//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 );
2014-12-12 13:43:43 +01:00
$connect -> Execute ( $sql , array ( $dateinsertion , $poll_id ));
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
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 );
2014-12-12 13:43:43 +01:00
$connect -> Execute ( $sql , array ( $date_fin , $poll_id ));
2014-09-04 17:52:18 +02:00
}
//}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
//mise a jour des reponses actuelles correspondant au sujet ajouté
$sql = 'UPDATE user_studs SET reponses = ' . $connect -> Param ( 'reponses' ) . ' WHERE nom = ' . $connect -> Param ( 'nom' ) . ' AND id_users=' . $connect -> Param ( 'id_users' );
$sql = $connect -> Prepare ( $sql );
while ( $data = $user_studs -> FetchNextObject ( false )) {
$ensemblereponses = $data -> reponses ;
$newcar = '' ;
//parcours de toutes les réponses actuelles
for ( $j = 0 ; $j < $nbcolonnes ; $j ++ ) {
$car = substr ( $ensemblereponses , $j , 1 );
//si les reponses ne concerne pas la colonne ajoutée, on concatene
if ( $j == $cle ) {
$newcar .= " 0 " ;
}
$newcar .= $car ;
}
//mise a jour des reponses utilisateurs dans la base
if ( isset ( $erreur_ajout_date ) && ! $erreur_ajout_date ){
$connect -> Execute ( $sql , array ( $newcar , $data -> nom , $data -> id_users ));
}
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2014-10-21 01:31:26 +02:00
//Email sent to the admin
send_mail_admin ();
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
} else {
$erreur_ajout_date = " yes " ;
}
2011-05-15 03:56:54 +02:00
}
2014-12-12 13:43:43 +01:00
// [end] action quand on ajoute une colonne au format DATE
2011-05-15 03:56:54 +02:00
//suppression de ligne dans la base
2011-05-22 02:13:44 +02:00
for ( $i = 0 ; $i < $nblignes ; $i ++ ) {
2014-09-04 17:52:18 +02:00
if ( isset ( $_POST [ " effaceligne $i " ])) {
$compteur = 0 ;
2014-12-07 16:47:35 +01:00
$prepared = $connect -> prepare ( 'DELETE FROM user_studs WHERE nom = ? AND id_users = ?' );
2013-03-04 19:46:06 +01:00
2014-12-07 16:47:35 +01:00
foreach ( $users as $user ) {
2014-09-04 17:52:18 +02:00
if ( $compteur == $i ){
2014-12-07 16:47:35 +01:00
$prepared -> execute ( array ( $user -> nom , $user -> id_users ));
2014-09-04 17:52:18 +02:00
}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
$compteur ++ ;
}
2011-05-15 03:56:54 +02:00
}
}
2014-12-07 16:47:35 +01:00
// 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' ;
2011-05-22 02:13:44 +02:00
$sql = $connect -> Prepare ( $sql );
2014-12-12 13:43:43 +01:00
$comment_user = $connect -> Execute ( $sql , array ( $poll_id ));
2011-05-15 03:56:54 +02:00
$i = 0 ;
while ( $dcomment = $comment_user -> FetchNextObject ( false )) {
2014-09-04 17:52:18 +02:00
if ( isset ( $_POST [ 'suppressioncomment' . $i ])) {
$sql = 'DELETE FROM comments WHERE id_comment = ' . $connect -> Param ( 'id_comment' );
$sql = $connect -> Prepare ( $sql );
$connect -> Execute ( $sql , array ( $dcomment -> id_comment ));
}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
$i ++ ;
2011-05-15 03:56:54 +02:00
}
2014-12-07 16:47:35 +01:00
*/
2011-05-15 03:56:54 +02:00
//on teste pour voir si une ligne doit etre modifiée
2011-05-22 02:13:44 +02:00
$testmodifier = false ;
$testligneamodifier = false ;
for ( $i = 0 ; $i < $nblignes ; $i ++ ) {
2014-09-04 17:52:18 +02:00
if ( isset ( $_POST [ " modifierligne $i " ])) {
$ligneamodifier = $i ;
$testligneamodifier = " true " ;
}
//test pour voir si une ligne est a modifier
if ( isset ( $_POST [ " validermodifier $i " ])) {
$modifier = $i ;
$testmodifier = " true " ;
}
2011-05-15 03:56:54 +02:00
}
//si le test est valide alors on affiche des checkbox pour entrer de nouvelles valeurs
if ( $testmodifier ) {
2014-09-04 17:52:18 +02:00
$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 ;
}
}
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
$compteur = 0 ;
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
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 ( 'reponses' ) . ' 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 ));
}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
$compteur ++ ;
}
2011-05-15 03:56:54 +02:00
}
//suppression de colonnes dans la base
2011-05-22 02:13:44 +02:00
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ ) {
2014-09-04 17:52:18 +02:00
if (( isset ( $_POST [ " effacecolonne $i " ])) && $nbcolonnes > 1 ){
2014-12-12 13:43:43 +01:00
$sujets = explode ( " , " , $dsujet -> sujet );
2014-09-04 17:52:18 +02:00
//sort($toutsujet, SORT_NUMERIC);
$j = 0 ;
$nouveauxsujets = '' ;
//parcours de tous les sujets actuels
2014-12-12 13:43:43 +01:00
while ( isset ( $sujets [ $j ])) {
2014-09-04 17:52:18 +02:00
//si le sujet n'est pas celui qui a été effacé alors on concatene
if ( $i != $j ) {
$nouveauxsujets .= ',' ;
2014-12-12 13:43:43 +01:00
$nouveauxsujets .= $sujets [ $j ];
2014-09-04 17:52:18 +02:00
}
$j ++ ;
}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
//on enleve la virgule au début
$nouveauxsujets = substr ( " $nouveauxsujets " , 1 );
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
//nettoyage des reponses actuelles correspondant au sujet effacé
$compteur = 0 ;
$sql = 'UPDATE user_studs SET reponses = ' . $connect -> Param ( 'reponses' ) . ' WHERE nom = ' . $connect -> Param ( 'nom' ) . ' AND id_users = ' . $connect -> Param ( 'id_users' );
$sql = $connect -> Prepare ( $sql );
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
while ( $data = $user_studs -> FetchNextObject ( false )) {
$newcar = '' ;
$ensemblereponses = $data -> reponses ;
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
//parcours de toutes les réponses actuelles
for ( $j = 0 ; $j < $nbcolonnes ; $j ++ ) {
$car = substr ( $ensemblereponses , $j , 1 );
//si les reponses ne concerne pas la colonne effacée, on concatene
if ( $i != $j ) {
$newcar .= $car ;
}
}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
$compteur ++ ;
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
//mise a jour des reponses utilisateurs dans la base
$connect -> Execute ( $sql , array ( $newcar , $data -> nom , $data -> id_users ));
}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
//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 );
2014-12-12 13:43:43 +01:00
$connect -> Execute ( $sql , array ( $nouveauxsujets , $poll_id ));
2014-09-04 17:52:18 +02:00
}
2011-05-15 03:56:54 +02:00
}
2014-12-07 16:47:35 +01:00
// 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' );
2011-05-22 02:13:44 +02:00
$sql = $connect -> Prepare ( $sql );
2014-12-12 13:43:43 +01:00
$sondage = $connect -> Execute ( $sql , array ( $admin_poll_id ));
2011-05-22 02:13:44 +02:00
if ( $sondage !== false ) {
2014-09-04 17:52:18 +02:00
$sql = 'SELECT * FROM sujet_studs WHERE id_sondage = ' . $connect -> Param ( 'numsondage' );
$sql = $connect -> Prepare ( $sql );
2014-12-12 13:43:43 +01:00
$sujets = $connect -> Execute ( $sql , array ( $poll_id ));
2014-09-04 17:52:18 +02:00
$sql = 'SELECT * FROM user_studs WHERE id_sondage = ' . $connect -> Param ( 'numsondage' ) . ' order by id_users' ;
$sql = $connect -> Prepare ( $sql );
2014-12-12 13:43:43 +01:00
$user_studs = $connect -> Execute ( $sql , array ( $poll_id ));
2014-09-04 17:52:18 +02:00
} 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 ();
2014-12-07 16:47:35 +01:00
} */
2014-09-04 17:52:18 +02:00
// Errors
$errors = '' ;
if (( isset ( $_POST [ " boutonp " ])) && $_POST [ " nom " ] == " " ) {
$errors .= '<li>' . _ ( " Enter a name " ) . '</li>' ;
}
if ( isset ( $erreur_prenom ) && $erreur_prenom ) {
$errors .= '<li>' . _ ( " The name you've chosen already exist in this poll! " ) . '</li>' ;
}
if ( isset ( $erreur_injection ) && $erreur_injection ) {
$errors .= '<li>' . _ ( " Characters \" ' < et > are not permitted " ) . '</li>' ;
}
if ( isset ( $erreur_ajout_date ) && $erreur_ajout_date ) {
$errors .= '<li>' . _ ( " The date is not correct ! " ) . '</li>' ;
}
2014-09-29 16:33:15 +02:00
//Poll title, description and email values
2014-12-07 16:47:35 +01:00
$title = ( isset ( $_POST [ " boutonnouveautitre " ]) && ! empty ( $_POST [ 'nouveautitre' ])) ? htmlentities ( html_entity_decode ( $_POST [ 'nouveautitre' ], ENT_QUOTES , 'UTF-8' ), ENT_QUOTES , 'UTF-8' ) : stripslashes ( $poll -> title );
$description = ( isset ( $_POST [ " nouveauxcommentaires " ])) ? stripslashes ( htmlentities ( html_entity_decode ( $_POST [ 'nouveauxcommentaires' ], ENT_QUOTES , 'UTF-8' ), ENT_QUOTES , 'UTF-8' )) : stripslashes ( $poll -> comment );
$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 );
2014-09-29 16:33:15 +02:00
2014-10-21 01:31:26 +02:00
//Poll format (locked A-/D-, open A/D, editable A+/D+)
2014-12-12 13:43:43 +01:00
$poll_rules = ( isset ( $_POST [ " poll_rules " ]) && ! empty ( $_POST [ 'btn_poll_rules' ])) ? $_POST [ " poll_rules " ] : substr ( $poll -> format , 1 , 1 ); // TODO OPZ Handle comment disabling
2014-10-21 01:31:26 +02:00
$poll_rules_opt1 = '' ; $poll_rules_opt2 = '' ; $poll_rules_opt3 = '' ;
2014-12-07 16:47:35 +01:00
if ( $poll -> editable ) {
2014-10-21 01:31:26 +02:00
$poll_rules_text = '<span class="glyphicon glyphicon-edit"></span> ' . _ ( " Votes are editable " );
$poll_rules_opt3 = 'selected' ;
} elseif ( $poll_rules == '-' ) {
$poll_rules_text = '<span class="glyphicon glyphicon-lock"></span> ' . _ ( " Votes and comments are locked " );
$poll_rules_opt1 = 'selected' ;
} else {
$poll_rules_text = '<span class="glyphicon glyphicon-check"></span> ' . _ ( " Votes and comments are open " );
$poll_rules_opt2 = 'selected' ;
}
2014-09-04 17:52:18 +02:00
if ( $errors != '' ) {
Utils :: print_header ( _ ( " Error! " ));
bandeau_titre ( _ ( " Error! " ));
echo '<div class="alert alert-danger"><ul class="list-unstyled">' . $errors . '</ul></div>' . " \n " ;
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
} else {
2014-09-29 16:33:15 +02:00
Utils :: print_header ( _ ( 'Poll administration' ) . ' - ' . $title );
2014-11-06 15:20:03 +01:00
bandeau_titre ( _ ( 'Poll administration' ) . ' - ' . $title );
2014-09-04 17:52:18 +02:00
// session_unset();
2011-05-22 02:13:44 +02:00
}
2011-05-15 03:56:54 +02:00
2014-09-04 17:52:18 +02:00
echo '
2014-12-12 13:43:43 +01:00
< form name = " formulaire4 " action = " ' . Utils::getUrlSondage( $admin_poll_id , true) . ' " method = " POST " >
2014-11-06 15:20:03 +01:00
< div class = " jumbotron bg-danger " >
2014-09-04 17:52:18 +02:00
< div class = " row " >
< div class = " col-md-7 " id = " title-form " >
2014-11-06 15:20:03 +01:00
< h3 > '.$title.' < button class = " btn btn-link btn-sm btn-edit " title = " '. _('Edit the title') .' " > < span class = " glyphicon glyphicon-pencil " ></ span >< span class = " sr-only " > ' . _(' Edit ') . ' </ span ></ button ></ h3 >
2014-09-04 17:52:18 +02:00
< div class = " hidden js-title " >
< label class = " sr-only " for = " newtitle " > '. _("Title") .' </ label >
< div class = " input-group " >
< input type = " text " class = " form-control " id = " newtitle " name = " nouveautitre " size = " 40 " value = " '. $title .' " />
< span class = " input-group-btn " >
2014-10-21 01:31:26 +02:00
< button type = " submit " class = " btn btn-success " name = " boutonnouveautitre " value = " 1 " title = " '. _('Save the new title') .' " >< span class = " glyphicon glyphicon-ok " ></ span >< span class = " sr-only " > ' . _(' Save ') . ' </ span ></ button >
< button class = " btn btn-link btn-cancel " title = " '. _('Cancel the title edit') .' " >< span class = " glyphicon glyphicon-remove " ></ span >< span class = " sr-only " > ' . _(' Cancel ') . ' </ span ></ button >
2014-09-04 17:52:18 +02:00
</ span >
</ div >
</ div >
</ 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 >
2014-12-07 16:47:35 +01:00
< button onclick = " window.location.href= \ '' . Utils::get_server_name() . 'exportcsv.php?numsondage=' . $poll_id . ' \ ';return false; " class = " btn btn-default " >< span class = " glyphicon glyphicon-download-alt " ></ span > ' . _(' Export to CSV ') . ' </ button >
2014-10-21 01:31:26 +02:00
< button type = " button " class = " btn btn-danger dropdown-toggle " data - toggle = " dropdown " >
< span class = " glyphicon glyphicon-trash " ></ span > < span class = " sr-only " > ' . _("Remove") . ' </ span > < span class = " caret " ></ span >
</ button >
< ul class = " dropdown-menu " role = " menu " >
< li >< button class = " btn btn-link " type = " submit " name = " removevotes " > ' . _(' Remove all the votes ') . ' </ button ></ li >
< li >< button class = " btn btn-link " type = " submit " name = " removecomments " > ' . _(' Remove all the comments ') . ' </ button ></ li >
< li class = " divider " role = " presentation " ></ li >
< li >< button class = " btn btn-link " type = " submit " id = " suppressionsondage " name = " suppressionsondage " value = " " > '. _("Remove the poll") .' </ button ></ li >
</ ul >
2014-09-04 17:52:18 +02:00
</ div >
</ div >
</ div >
< div class = " row " >
< div class = " col-md-5 " >
< div class = " form-group " >
< div id = " author-form " >
2014-11-06 15:20:03 +01:00
< h4 class = " control-label " > '. _("Initiator of the poll") .' </ h4 >
2014-12-07 16:47:35 +01:00
< p > '.stripslashes($poll->admin_name).' </ p >
2014-09-04 17:52:18 +02:00
</ div >
< div id = " email-form " >
< p > '.$email_admin.' < button class = " btn btn-link btn-sm btn-edit " title = " '. _('Edit the email adress') .' " >< span class = " glyphicon glyphicon-pencil " ></ span >< span class = " sr-only " > ' . _(' Edit ') . ' </ span ></ button ></ p >
< div class = " hidden js-email " >
< label class = " sr-only " for = " newemail " > '. _("Email adress") .' </ label >
< div class = " input-group " >
< input type = " text " class = " form-control " id = " newemail " name = " nouvelleadresse " size = " 40 " value = " '. $email_admin .' " />
< span class = " input-group-btn " >
2014-10-22 15:42:35 +02:00
< button type = " submit " name = " boutonnouvelleadresse " value = " 1 " class = " btn btn-success " title = " '. _('Save the email address ') .' " >< span class = " glyphicon glyphicon-ok " ></ span >< span class = " sr-only " > ' . _(' Save ') . ' </ span ></ button >
< button class = " btn btn-link btn-cancel " title = " '. _('Cancel the email address edit') .' " >< span class = " glyphicon glyphicon-remove " ></ span >< span class = " sr-only " > ' . _(' Cancel ') . ' </ span ></ button >
2014-09-04 17:52:18 +02:00
</ span >
</ div >
</ div >
</ div >
</ div >
</ div >
< div class = " form-group col-md-7 " id = " description-form " >
2014-11-14 17:35:22 +01:00
< h4 class = " control-label " > '._("Description") .' </ h4 >< button class = " btn btn-link btn-sm btn-edit " title = " '. _('Edit the description') .' " >< span class = " glyphicon glyphicon-pencil " ></ span >< span class = " sr-only " > ' . _(' Edit ') . ' </ span ></ button >< br />
2014-09-04 17:52:18 +02:00
< p class = " well " > '.$description.' </ p >
< div class = " hidden js-desc text-right " >
2014-11-14 17:35:22 +01:00
< label class = " sr-only " for = " newdescription " > '._("Description") .' </ label >
2014-10-21 11:33:39 +02:00
< textarea class = " form-control " id = " newdescription " name = " nouveauxcommentaires " rows = " 2 " cols = " 40 " > '.$description.' </ textarea >
2014-09-04 17:52:18 +02:00
< button type = " submit " id = " btn-new-desc " name = " boutonnouveauxcommentaires " value = " 1 " class = " btn btn-sm btn-success " title = " '. _( " Save the description " ) .' " > '. _("Save") .' </ button >
< button class = " btn btn-default btn-sm btn-cancel " title = " '. _('Cancel the description edit') .' " > '. _(' Cancel ') .' </ button >
</ div >
</ div >
</ div >
< div class = " row " >
< div class = " form-group col-md-5 " >
2014-12-07 16:47:35 +01:00
< label for = " public-link " >< a class = " public-link " href = " ' . Utils::getUrlSondage( $poll->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( $poll->poll_id ) . ' " />
2014-09-04 17:52:18 +02:00
</ div >
< div class = " form-group col-md-5 " >
2014-12-12 13:43:43 +01:00
< 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 >
2014-12-07 16:47:35 +01:00
< input class = " form-control " id = " admin-link " type = " text " readonly = " readonly " value = " ' . Utils::getUrlSondage( $admin_poll_id , true) . ' " />
2014-09-04 17:52:18 +02:00
</ div >
< div class = " form-group col-md-2 " >
2014-11-06 15:20:03 +01:00
< h4 class = " control-label " > '. _("Expiration' s date " ) .'</h4>
2014-12-07 16:47:35 +01:00
< p > '.date("d/m/Y",strtotime($poll->end_date)).' </ p >
2014-09-04 17:52:18 +02:00
</ div >
</ div >
2014-10-21 01:31:26 +02:00
< div class = " row " >
< div class = " col-md-5 col-md-offset-7 " >
< div id = " poll-rules-form " >
< p class = " pull-right " > '.$poll_rules_text.' < button class = " btn btn-link btn-sm btn-edit " title = " '. _('Edit the poll rules') .' " >< span class = " glyphicon glyphicon-pencil " ></ span >< span class = " sr-only " > ' . _(' Edit ') . ' </ span ></ button ></ p >
< div class = " hidden js-poll-rules " >
< label class = " sr-only " for = " newrules " > '. _("Poll rules") .' </ label >
< div class = " input-group " >
< select class = " form-control " id = " newrules " name = " poll_rules " >
< option value = " - " '.$poll_rules_opt1.' > '. _("Votes and comments are locked") .' </ option >
< option value = " 0 " '.$poll_rules_opt2.' > '. _("Votes and comments are open") .' </ option >
< option value = " + " '.$poll_rules_opt3.' > '. _("Votes are editable") .' </ option >
</ select >
< span class = " input-group-btn " >
< button type = " submit " name = " btn_poll_rules " value = " 1 " class = " btn btn-success " title = " '. _('Save the new rules') .' " >< span class = " glyphicon glyphicon-ok " ></ span >< span class = " sr-only " > ' . _(' Save ') . ' </ span ></ button >
< button class = " btn btn-link btn-cancel " title = " '. _('Cancel the rules edit') .' " >< span class = " glyphicon glyphicon-remove " ></ span >< span class = " sr-only " > ' . _(' Cancel ') . ' </ span ></ button >
</ span >
</ div >
</ div >
</ div >
</ div >
</ div >
2014-09-04 17:52:18 +02:00
</ div >
</ form > ' . " \n " ; // .jumbotron
// Table headers
$thead = '<thead>' ;
2014-07-04 11:21:31 +02:00
2014-09-04 17:52:18 +02:00
// Button in the first td to avoid remove col on "Return" keypress)
$tr_add_remove_col = '<tr><td role="presentation"><button type="submit" class="invisible" name="boutonp" ></button></td>' ;
2011-05-15 03:56:54 +02:00
2014-09-04 17:52:18 +02:00
$border = array (); // bordure pour distinguer les mois
$td_headers = array (); // for a11y, headers="M1 D4 H5" on each td
$radio_title = array (); // date for
2011-05-15 03:56:54 +02:00
2014-12-12 13:43:43 +01:00
// Display dates poll
if ( $poll -> format == " D " ) {
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
$tr_months = '<tr><th role="presentation"></th>' ;
$tr_days = '<tr><th role="presentation"></th>' ;
$tr_hours = '<tr><th role="presentation"></th>' ;
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
// Headers
$colspan_month = 1 ;
$colspan_day = 1 ;
2014-12-12 13:43:43 +01:00
foreach ( $sujets as $i => $sujet ) {
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
// Current date
2014-12-12 13:43:43 +01:00
$horoCur = explode ( '@' , $sujet -> sujet ); //horoCur[0] = date, horoCur[1] = hour
if ( isset ( $sujets [ $i + 1 ])){
$next = $sujets [ $i + 1 ] -> sujet ;
$horoNext = explode ( '@' , $next );
2014-11-18 18:38:00 +01:00
}
2014-09-29 16:33:15 +02:00
$border [ $i ] = false ;
2014-12-12 13:43:43 +01:00
$radio_title [ $i ] = strftime ( $date_format [ 'txt_short' ], $horoCur [ 0 ]);
2014-09-29 16:33:15 +02:00
2014-09-04 17:52:18 +02:00
// Months
$td_headers [ $i ] = 'M' . ( $i + 1 - $colspan_month );
2013-03-04 19:46:06 +01:00
2014-12-12 13:43:43 +01:00
if ( isset ( $sujets [ $i + 1 ]) && strftime ( " %B " , $horoCur [ 0 ]) == strftime ( " %B " , $horoNext [ 0 ]) && strftime ( " %Y " , $horoCur [ 0 ]) == strftime ( " %Y " , $horoNext [ 0 ])){
2014-09-04 17:52:18 +02:00
$colspan_month ++ ;
} else {
$border [ $i ] = true ;
2014-11-15 02:21:12 +01:00
$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>' ;
2014-09-04 17:52:18 +02:00
$colspan_month = 1 ;
}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
// Days
$td_headers [ $i ] .= ' D' . ( $i + 1 - $colspan_day );
2013-03-04 19:46:06 +01:00
2014-12-12 13:43:43 +01:00
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 ])){
2014-09-04 17:52:18 +02:00
$colspan_day ++ ;
} else {
$rbd = ( $border [ $i ]) ? ' rbd' : '' ;
2014-11-15 02:21:12 +01:00
$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>' ;
2014-09-04 17:52:18 +02:00
$colspan_day = 1 ;
}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
// Hours
2014-09-29 16:33:15 +02:00
$rbd = ( $border [ $i ]) ? ' rbd' : '' ;
2014-11-15 02:21:12 +01:00
if ( $horoCur [ 1 ] !== " " ) {
$tr_hours .= '<th class="bg-info' . $rbd . '" id="H' . $i . '" title="' . $horoCur [ 1 ] . '">' . $horoCur [ 1 ] . '</th>' ;
$radio_title [ $i ] .= ' - ' . $horoCur [ 1 ];
2014-09-04 17:52:18 +02:00
$td_headers [ $i ] .= ' H' . $i ;
2014-09-29 16:33:15 +02:00
} else {
$tr_hours .= '<th class="bg-info' . $rbd . '"></th>' ;
2014-09-04 17:52:18 +02:00
}
// Remove col
2014-12-12 13:43:43 +01:00
$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>' ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
$border [ count ( $border ) - 1 ] = false ; // suppression de la bordure droite du dernier mois
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
$tr_months .= '<th></th></tr>' ;
$tr_days .= '<th></th></tr>' ;
$tr_hours .= '<th></th></tr>' ;
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
// Add col
2014-10-21 01:31:26 +02:00
$tr_add_remove_col .= '<td><button type="submit" name="ajoutsujet" class="btn btn-link btn-sm" title="' . _ ( 'Add a column' ) . '"><span class="glyphicon glyphicon-plus text-success"></span><span class="sr-only">' . _ ( " Add a column " ) . '</span></button></td></tr>' ;
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
$thead = " \n " . $tr_add_remove_col . " \n " . $tr_months . " \n " . $tr_days . " \n " . $tr_hours . " \n " ;
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
// Subjects poll
} else {
$tr_subjects = '<tr><th role="presentation"></th>' ;
2013-03-04 19:46:06 +01:00
2014-12-07 16:47:35 +01:00
foreach ( $sujets as $i => $sujet ) {
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
$td_headers [ $i ] = '' ; $radio_title [ $i ] = '' ; // init before concatenate
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
// Subjects
2014-12-07 16:47:35 +01:00
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)
2014-10-21 01:31:26 +02:00
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
2014-12-07 16:47:35 +01:00
$th_subject_text = stripslashes ( $sujet -> sujet );
2014-10-21 01:31:26 +02:00
$th_subject_html = $th_subject_text ;
}
$tr_subjects .= '<th class="bg-info" id="S' . $i . '" title="' . $th_subject_text . '">' . $th_subject_html . '</th>' ;
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
$border [ $i ] = false ;
2014-10-21 01:31:26 +02:00
$td_headers [ $i ] .= 'S' . $i ;
$radio_title [ $i ] .= $th_subject_text ;
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
// Remove col
2014-10-21 01:31:26 +02:00
$tr_add_remove_col .= '<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>' ;
2014-09-04 17:52:18 +02:00
}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
// Add col
2014-10-21 01:31:26 +02:00
$tr_add_remove_col .= '<td><button type="submit" name="ajoutsujet" class="btn btn-link btn-sm" title="' . _ ( 'Add a column' ) . '"><span class="glyphicon glyphicon-plus text-success"></span><span class="sr-only">' . _ ( " Add a column " ) . '</span></button></td></tr>' ;
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
$thead = $tr_add_remove_col . $tr_subjects . '<th></th></tr>' ;
2011-05-15 03:56:54 +02:00
}
2014-09-04 17:52:18 +02:00
// Print headers
echo '
2014-12-12 13:43:43 +01:00
< form name = " formulaire " action = " ' . Utils::getUrlSondage( $admin_poll_id , true) . ' " method = " POST " >
2014-09-04 17:52:18 +02:00
< 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 > ,
' . _(' remove a column or a line with ') . ' < span class = " glyphicon glyphicon-remove text-danger " ></ span >< span class = " sr-only " > ' . _(' Remove ') . ' </ span >
' . _(' and add a new column with '). ' < span class = " glyphicon glyphicon-plus text-success " ></ span >< span class = " sr-only " > '. _(' Add a column ') . ' </ span ></ p >
< p > ' . _(' Finally , you can change the informations of this poll like the title , the comments or your email address . ') . ' </ p >
2014-11-14 17:35:22 +01:00
< 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 >
2014-10-21 01:31:26 +02:00
</ div >
< 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 >
2014-09-04 17:52:18 +02:00
</ div >
2014-10-21 01:31:26 +02:00
2014-11-06 15:20:03 +01:00
< h3 > '._(' Votes of the poll ').' </ h3 >
2014-09-04 17:52:18 +02:00
< div id = " tableContainer " class = " tableContainer " >
< table class = " results " >
2014-10-21 01:31:26 +02:00
< caption class = " sr-only " > '._(' Votes of the poll ').$title.' </ caption >
2014-09-04 17:52:18 +02:00
< thead > '. $thead . ' </ thead >
< tbody > ' ;
// Print poll results
2011-05-22 02:13:44 +02:00
$somme [] = 0 ;
2011-05-15 03:56:54 +02:00
$compteur = 0 ;
2014-12-07 16:47:35 +01:00
foreach ( $users as $user ) {
2014-09-04 17:52:18 +02:00
2014-12-07 16:47:35 +01:00
$ensemblereponses = $user -> reponses ;
2014-09-04 17:52:18 +02:00
// Print name
echo ' < tr >
2014-12-07 16:47:35 +01:00
< th class = " bg-info " > '.stripslashes($user->nom).' </ th > ' . " \n " ;
2014-09-04 17:52:18 +02:00
// si la ligne n'est pas a changer, on affiche les données
if ( ! $testligneamodifier ) {
for ( $k = 0 ; $k < $nbcolonnes ; $k ++ ) {
$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 " ; break ;
}
2011-05-15 03:56:54 +02:00
}
2014-09-04 17:52:18 +02:00
} else { // sinon on remplace les choix de l'utilisateur par une ligne de radio pour recuperer de nouvelles valeurs
// si c'est bien la ligne a modifier on met les radios
if ( $compteur == " $ligneamodifier " ) {
for ( $j = 0 ; $j < $nbcolonnes ; $j ++ ) {
$car = substr ( $ensemblereponses , $j , 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[$j] .' " >
< ul class = " list-unstyled choice " >
< li class = " yes " >
< input type = " radio " id = " y-choice-'. $j .' " name = " choix'. $j .' " '.$car_html[1].' />
< label class = " btn btn-default btn-xs " for = " y-choice-'. $j .' " title = " ' . _('Vote " yes " for ') . $radio_title[$j] . ' " >
< span class = " glyphicon glyphicon-ok " ></ span >< span class = " sr-only " > ' . _(' Yes ') . ' </ span >
</ label >
</ li >
< li class = " ifneedbe " >
< input type = " radio " id = " i-choice-'. $j .' " name = " choix'. $j .' " '.$car_html[2].' />
< label class = " btn btn-default btn-xs " for = " i-choice-'. $j .' " title = " ' . _('Vote " ifneedbe " for ') . $radio_title[$j] . ' " >
( < span class = " glyphicon glyphicon-ok " ></ span > ) < span class = " sr-only " > ' . _(' Ifneedbe ') . ' </ span >
</ label >
</ li >
< li class = " no " >
< input type = " radio " id = " n-choice-'. $j .' " name = " choix'. $j .' " '.$car_html[0].' />
< label class = " btn btn-default btn-xs " for = " n-choice-'. $j .' " title = " ' . _('Vote " no " for ') . $radio_title[$j] . ' " >
< span class = " glyphicon glyphicon-ban-circle " ></ span >< span class = " sr-only " > ' . _(' No ') . ' </ span >
</ label >
</ li >
</ ul >
</ td > ' . " \n " ;
}
} else { //sinon on affiche les lignes normales
for ( $k = 0 ; $k < $nbcolonnes ; $k ++ ) {
$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 " ; break ;
}
}
2011-05-15 03:56:54 +02:00
}
}
2011-05-15 01:32:47 +02:00
2014-09-04 17:52:18 +02:00
//a la fin de chaque ligne se trouve les boutons modifier
if ( ! $testligneamodifier == " true " ) {
2014-10-21 01:31:26 +02:00
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 >
< button type = " submit " name = " effaceligne'. $compteur .' " title = " '. _('Remove the line:') .' '.stripslashes( $nombase ).' " class = " btn btn-link btn-sm " >
< span class = " glyphicon glyphicon-remove text-danger " ></ span >< span class = " sr-only " > ' . _(' Remove ') . ' </ span >
</ button >
</ td > ' . " \n " ;
2011-05-22 02:13:44 +02:00
}
2013-03-04 19:46:06 +01:00
2014-09-04 17:52:18 +02:00
//demande de confirmation pour modification de ligne
for ( $i = 0 ; $i < $nblignes ; $i ++ ) {
if ( isset ( $_POST [ " modifierligne $i " ])) {
if ( $compteur == $i ) {
2014-11-14 17:35:22 +01:00
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 " ;
2014-09-04 17:52:18 +02:00
}
}
2011-05-22 02:13:44 +02:00
}
2011-05-15 03:56:54 +02:00
2014-09-04 17:52:18 +02:00
$compteur ++ ;
echo '</tr>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
2014-09-04 17:52:18 +02:00
if ( ! $testligneamodifier == " true " ) {
//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 " ;
}
2011-05-15 03:56:54 +02:00
2014-09-04 17:52:18 +02:00
// 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 " ;
2011-05-15 03:56:54 +02:00
}
2014-09-04 17:52:18 +02:00
// Addition and Best choice
//affichage de la ligne contenant les sommes de chaque colonne
2014-10-21 01:31:26 +02:00
$tr_addition = '<tr id="addition"><td>' . _ ( " Addition " ) . '</td>' ;
$meilleurecolonne = max ( $somme );
2011-05-22 02:13:44 +02:00
$compteursujet = 0 ;
2014-09-29 16:33:15 +02:00
$meilleursujet = '<ul style="list-style:none">' ;
2011-05-22 02:13:44 +02:00
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ ) {
2014-10-21 01:31:26 +02:00
if ( isset ( $somme [ $i ]) && $somme [ $i ] > 0 ) {
if ( in_array ( $i , array_keys ( $somme , max ( $somme )))){
2013-03-04 19:46:06 +01:00
2014-10-21 01:31:26 +02:00
$tr_addition .= '<td><span class="glyphicon glyphicon-star text-warning"></span><span>' . $somme [ $i ] . '</span></td>' ;
2013-03-04 19:46:06 +01:00
2014-10-21 01:31:26 +02:00
$meilleursujet .= '<li><b>' . $radio_title [ $i ] . '</b></li>' ;
$compteursujet ++ ;
2014-09-04 17:52:18 +02:00
2011-05-15 03:56:54 +02:00
} else {
2014-10-21 01:31:26 +02:00
$tr_addition .= '<td>' . $somme [ $i ] . '</td>' ;
2011-05-15 03:56:54 +02:00
}
} else {
2014-10-21 01:31:26 +02:00
$tr_addition .= '<td></td>' ;
2011-05-15 03:56:54 +02:00
}
}
2014-10-21 01:31:26 +02:00
$tr_addition .= '<td></td></tr>' ;
2014-09-29 16:33:15 +02:00
$meilleursujet = str_replace ( " ° " , " ' " , $meilleursujet ) . '</ul>' ;
2014-09-04 17:52:18 +02:00
$vote_str = ( $meilleurecolonne > 1 ) ? $vote_str = _ ( 'votes' ) : _ ( 'vote' );
// Print Addition and Best choice
2014-10-21 01:31:26 +02:00
echo $tr_addition . '
2014-09-04 17:52:18 +02:00
</ tbody >
</ table >
2014-10-21 01:31:26 +02:00
</ div >
< div class = " row " > ' . " \n " ;
2014-09-04 17:52:18 +02:00
if ( $compteursujet == 1 ) {
2014-10-21 01:31:26 +02:00
echo '
2014-11-18 18:38:00 +01:00
< div class = " col-sm-12 " >< h3 > ' . _("Best choice") . ' </ h3 ></ div >
2014-10-21 01:31:26 +02:00
< 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 " ;
2014-09-04 17:52:18 +02:00
} elseif ( $compteursujet > 1 ) {
2014-10-21 01:31:26 +02:00
echo '
2014-11-18 18:38:00 +01:00
< div class = " col-sm-12 " >< h3 > ' . _("Best choices") . ' </ h3 ></ div >
2014-10-21 01:31:26 +02:00
< 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 " ;
2011-05-15 03:56:54 +02:00
}
2014-09-29 16:33:15 +02:00
echo '
</ div >
2014-11-14 17:35:22 +01:00
< hr role = " presentation " /> ' . " \n " ;
2014-12-07 16:47:35 +01:00
2014-09-04 17:52:18 +02:00
// Commments
2014-12-07 16:47:35 +01:00
$comment_user = $connect -> allComments ( $poll_id );
2011-05-15 03:56:54 +02:00
2014-12-07 16:47:35 +01:00
if ( count ( $comment_user ) != 0 ) {
2014-10-21 01:31:26 +02:00
echo '<div><h3>' . _ ( " Comments of polled people " ) . '</h3>' . " \n " ;
2014-09-04 17:52:18 +02:00
$i = 0 ;
while ( $dcomment = $comment_user -> FetchNextObject ( false )) {
echo '
< div class = " comment " >
2014-10-21 01:31:26 +02:00
< button type = " submit " name = " suppressioncomment'. $i .' " class = " btn btn-link " title = " ' . _('Remove the comment') . ' " >< span class = " glyphicon glyphicon-remove text-danger " ></ span >< span class = " sr-only " > ' . _(' Remove ') . ' </ span ></ button >
2014-09-04 17:52:18 +02:00
< b > '.stripslashes($dcomment->usercomment). ' :</ b >
< span class = " comment " > ' . stripslashes(nl2br($dcomment->comment)) . ' </ span >
</ div > ' ;
$i ++ ;
}
echo '</div>' ;
2011-05-22 02:13:44 +02:00
}
2014-09-04 17:52:18 +02:00
echo '
2014-10-21 01:31:26 +02:00
< div class = " hidden-print alert alert-info " >
2014-09-04 17:52:18 +02:00
< 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 name = " commentuser " class = " form-control " 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 >
2014-10-21 01:31:26 +02:00
< div class = " clearfix " ></ div >
2014-09-04 17:52:18 +02:00
</ div >
2014-10-21 01:31:26 +02:00
</ form > ' ;
2014-09-04 17:52:18 +02:00
bandeau_pied ();