Merge branch 'RyDroid/framadate-adminstuds.php'
This commit is contained in:
commit
f0872df179
316
adminstuds.php
316
adminstuds.php
@ -29,13 +29,48 @@ if (file_exists('bandeaux_local.php')) {
|
|||||||
include_once('bandeaux.php');
|
include_once('bandeaux.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getChoicesFromPOST($nbColumns)
|
||||||
|
{
|
||||||
|
$choices = array();
|
||||||
|
for ($i=0; $i < $nbColumns; ++$i) {
|
||||||
|
// radio checked 1 = Yes, 2 = Ifneedbe, 0 = No
|
||||||
|
if (isset($_POST['choix'. $i])) {
|
||||||
|
$choices[] = $_POST['choix'. $i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $choices;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNewChoiceFromChoices($choices)
|
||||||
|
{
|
||||||
|
if(!is_array($choice)) {
|
||||||
|
throw new Exception('$choices must be a an array');
|
||||||
|
}
|
||||||
|
|
||||||
|
$newChoice = '';
|
||||||
|
foreach ($choices as $choice) {
|
||||||
|
// radio checked 1 = Yes, 2 = Ifneedbe, 0 = No
|
||||||
|
switch ($choice) {
|
||||||
|
case 1: $newChoice .= '1'; break;
|
||||||
|
case 2: $newChoice .= '2'; break;
|
||||||
|
default: $newChoice .= '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $newChoice;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNewChoiceFromPOST($nbColumns)
|
||||||
|
{
|
||||||
|
return getNewChoiceFromChoices(getChoicesFromPOST($nbColumns));
|
||||||
|
}
|
||||||
|
|
||||||
// Initialisation des variables
|
// Initialisation des variables
|
||||||
$numsondageadmin = false;
|
$numsondageadmin = false;
|
||||||
$sondage = false;
|
$sondage = false;
|
||||||
|
|
||||||
// recuperation du numero de sondage admin (24 car.) dans l'URL
|
// recuperation du numero de sondage admin (24 car.) dans l'URL
|
||||||
if (Utils::issetAndNoEmpty('sondage', $_GET) && is_string($_GET['sondage']) && strlen($_GET['sondage']) === 24) {
|
if (Utils::issetAndNoEmpty('sondage', $_GET) && is_string($_GET['sondage']) && strlen($_GET['sondage']) === 24) {
|
||||||
$numsondageadmin=$_GET["sondage"];
|
$numsondageadmin = $_GET['sondage'];
|
||||||
//on découpe le résultat pour avoir le numéro de sondage (16 car.)
|
//on découpe le résultat pour avoir le numéro de sondage (16 car.)
|
||||||
$numsondage = substr($numsondageadmin, 0, 16);
|
$numsondage = substr($numsondageadmin, 0, 16);
|
||||||
}
|
}
|
||||||
@ -50,7 +85,7 @@ if (preg_match(";[\w\d]{24};i", $numsondageadmin)) {
|
|||||||
$sql = $connect->Prepare($sql);
|
$sql = $connect->Prepare($sql);
|
||||||
$sujets = $connect->Execute($sql, array($numsondage));
|
$sujets = $connect->Execute($sql, array($numsondage));
|
||||||
|
|
||||||
$sql = 'SELECT * FROM user_studs WHERE id_sondage = '.$connect->Param('numsondage').' order by id_users';
|
$sql = 'SELECT * FROM user_studs WHERE id_sondage = '.$connect->Param('numsondage').' ORDER BY id_users';
|
||||||
$sql = $connect->Prepare($sql);
|
$sql = $connect->Prepare($sql);
|
||||||
$user_studs = $connect->Execute($sql, array($numsondage));
|
$user_studs = $connect->Execute($sql, array($numsondage));
|
||||||
}
|
}
|
||||||
@ -86,21 +121,21 @@ function send_mail_admin() {
|
|||||||
global $numsondageadmin;
|
global $numsondageadmin;
|
||||||
global $smtp_allowed;
|
global $smtp_allowed;
|
||||||
if($smtp_allowed == true) {
|
if($smtp_allowed == true) {
|
||||||
if(!isset($_SESSION["mail_admin_sent"])) {
|
if(!isset($_SESSION['mail_admin_sent'])) {
|
||||||
Utils::sendEmail( $email_admin,
|
Utils::sendEmail( $email_admin,
|
||||||
_("[ADMINISTRATOR] New settings for your poll") . ' ' . stripslashes( $poll_title ),
|
_("[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") .
|
_('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($numsondageadmin, true) . "\n\n" .
|
||||||
_("Thanks for your confidence.") . "\n" . NOMAPPLICATION
|
_('Thanks for your confidence.') . "\n" . NOMAPPLICATION
|
||||||
);
|
);
|
||||||
$_SESSION["mail_admin_sent"]=true;
|
$_SESSION['mail_admin_sent']=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//si la valeur du nouveau titre est valide et que le bouton est activé
|
//si la valeur du nouveau titre est valide et que le bouton est activé
|
||||||
if (isset($_POST["boutonnouveautitre"])) {
|
if (isset($_POST['boutonnouveautitre'])) {
|
||||||
if (Utils::issetAndNoEmpty('nouveautitre') === false) {
|
if (Utils::issetAndNoEmpty('nouveautitre') === false) {
|
||||||
$err |= TITLE_EMPTY;
|
$err |= TITLE_EMPTY;
|
||||||
} else {
|
} else {
|
||||||
@ -155,12 +190,9 @@ if (isset($_POST["boutonnouvelleadresse"])) {
|
|||||||
//New poll rules
|
//New poll rules
|
||||||
if (isset($_POST["btn_poll_rules"])) {
|
if (isset($_POST["btn_poll_rules"])) {
|
||||||
echo '<!-- '; print_r($_POST); echo ' -->';
|
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);
|
$new_poll_rules = substr($dsondage->format, 0, 1);
|
||||||
|
if($_POST['poll_rules'] == '+' || $_POST['poll_rules'] == '-') {
|
||||||
|
$new_poll_rules .= $_POST['poll_rules'];
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update SQL database with new rules
|
//Update SQL database with new rules
|
||||||
@ -177,10 +209,10 @@ if (isset($_POST["btn_poll_rules"])) {
|
|||||||
$dsujet=$sujets->FetchObject(false);
|
$dsujet=$sujets->FetchObject(false);
|
||||||
$dsondage=$sondage->FetchObject(false);
|
$dsondage=$sondage->FetchObject(false);
|
||||||
|
|
||||||
if (isset($_POST["ajoutsujet"])) {
|
if (isset($_POST['ajoutsujet'])) {
|
||||||
Utils::print_header( _("Add a column") .' - ' . stripslashes( $dsondage->titre ));
|
Utils::print_header( _('Add a column') .' - ' . stripslashes( $dsondage->titre ));
|
||||||
|
|
||||||
bandeau_titre(_("Make your polls"));
|
bandeau_titre(_('Make your polls'));
|
||||||
|
|
||||||
//on recupere les données et les sujets du sondage
|
//on recupere les données et les sujets du sondage
|
||||||
|
|
||||||
@ -201,14 +233,14 @@ if (isset($_POST["ajoutsujet"])) {
|
|||||||
} else {
|
} else {
|
||||||
//ajout d'une date avec creneau horaire
|
//ajout d'une date avec creneau horaire
|
||||||
echo '
|
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>
|
<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">
|
<div class="form-group">
|
||||||
<label for="newdate" class="col-md-4">'. _("Day") .'</label>
|
<label for="newdate" class="col-md-4">'. _("Day") .'</label>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<div class="input-group date">
|
<div class="input-group date">
|
||||||
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
|
<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") .'" />
|
<input type="text" id="newdate" data-date-format="'. _('dd/mm/yyyy') .'" aria-describedby="dateformat" name="newdate" class="form-control" placeholder="'. _("dd/mm/yyyy") .'" />
|
||||||
</div>
|
</div>
|
||||||
<span id="dateformat" class="sr-only">'. _("(dd/mm/yyyy)") .'</span>
|
<span id="dateformat" class="sr-only">'. _("(dd/mm/yyyy)") .'</span>
|
||||||
</div>
|
</div>
|
||||||
@ -243,8 +275,8 @@ if (isset($_POST["suppressionsondage"])) {
|
|||||||
<form name="formulaire" action="' . Utils::getUrlSondage($numsondageadmin, true) . '" method="POST">
|
<form name="formulaire" action="' . Utils::getUrlSondage($numsondageadmin, true) . '" method="POST">
|
||||||
<div class="alert alert-warning text-center">
|
<div class="alert alert-warning text-center">
|
||||||
<h2>' . _("Confirm removal of your poll") . '</h2>
|
<h2>' . _("Confirm removal of your poll") . '</h2>
|
||||||
<p><button class="btn btn-default" type="submit" value="" name="annullesuppression">'._("Keep this poll!").'</button>
|
<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>
|
<button type="submit" name="confirmesuppression" value="" class="btn btn-danger">'._('Remove this poll!').'</button></p>
|
||||||
</div>
|
</div>
|
||||||
</form>';
|
</form>';
|
||||||
|
|
||||||
@ -281,11 +313,11 @@ if (isset($_POST["confirmesuppression"])) {
|
|||||||
//affichage de l'ecran de confirmation de suppression de sondage
|
//affichage de l'ecran de confirmation de suppression de sondage
|
||||||
Utils::print_header(_("Your poll has been removed!"));
|
Utils::print_header(_("Your poll has been removed!"));
|
||||||
|
|
||||||
bandeau_titre(_("Make your polls"));
|
bandeau_titre(_('Make your polls'));
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<div class="alert alert-success text-center">
|
<div class="alert alert-success text-center">
|
||||||
<h2>' . _("Your poll has been removed!") . '</h2>
|
<h2>' . _('Your poll has been removed!') . '</h2>
|
||||||
<p>' . _('Back to the homepage of ') . ' <a href="' . Utils::get_server_name() . '"> ' . NOMAPPLICATION . '</a></p>
|
<p>' . _('Back to the homepage of ') . ' <a href="' . Utils::get_server_name() . '"> ' . NOMAPPLICATION . '</a></p>
|
||||||
</div>
|
</div>
|
||||||
</form>'."\n";
|
</form>'."\n";
|
||||||
@ -320,7 +352,7 @@ if (isset($_POST['ajoutcomment'])) {
|
|||||||
while ( $dcomment_user_doublon=$comment_user_doublon->FetchNextObject(false)) {
|
while ( $dcomment_user_doublon=$comment_user_doublon->FetchNextObject(false)) {
|
||||||
if($dcomment_user_doublon->comment == $comment && $dcomment_user_doublon->usercomment == $comment_user) {
|
if($dcomment_user_doublon->comment == $comment && $dcomment_user_doublon->usercomment == $comment_user) {
|
||||||
$comment_doublon = true;
|
$comment_doublon = true;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,31 +374,20 @@ if (isset($_POST['ajoutcomment'])) {
|
|||||||
$nbcolonnes = substr_count($dsujet->sujet, ',') + 1;
|
$nbcolonnes = substr_count($dsujet->sujet, ',') + 1;
|
||||||
$nblignes = $user_studs->RecordCount();
|
$nblignes = $user_studs->RecordCount();
|
||||||
|
|
||||||
//si il n'y a pas suppression alors on peut afficher normalement le tableau
|
//s'il n'y a pas suppression alors on peut afficher normalement le tableau
|
||||||
|
|
||||||
//action si le bouton participer est cliqué
|
//action si le bouton participer est cliqué
|
||||||
if (isset($_POST["boutonp"])) {
|
if (isset($_POST["boutonp"])) {
|
||||||
//si on a un nom dans la case texte
|
//si on a un nom dans la case texte
|
||||||
if (Utils::issetAndNoEmpty('nom')){
|
if (Utils::issetAndNoEmpty('nom')){
|
||||||
$nouveauchoix = '';
|
$nouveauchoix = getNewChoiceFromPOST($nbcolonnes);
|
||||||
$erreur_prenom = false;
|
$erreur_prenom = false;
|
||||||
|
|
||||||
for ($i=0;$i<$nbcolonnes;$i++){
|
$nom = htmlentities(html_entity_decode($_POST['nom'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8');
|
||||||
// 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 = htmlentities(html_entity_decode($_POST["nom"], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8');
|
|
||||||
|
|
||||||
while($user = $user_studs->FetchNextObject(false)) {
|
while($user = $user_studs->FetchNextObject(false)) {
|
||||||
if ($nom == $user->nom) {
|
if ($nom == $user->nom) {
|
||||||
$erreur_prenom="yes";
|
$erreur_prenom = 'yes';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,12 +406,12 @@ if (isset($_POST["boutonp"])) {
|
|||||||
|
|
||||||
|
|
||||||
//action quand on ajoute une colonne au format AUTRE
|
//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']) && Utils::issetAndNoEmpty('nouvellecolonne') && (substr($dsondage->format, 0, 1) == 'A' )) {
|
||||||
$nouveauxsujets=$dsujet->sujet;
|
$nouveauxsujets=$dsujet->sujet;
|
||||||
|
|
||||||
//on rajoute la valeur a la fin de tous les sujets deja entrés
|
//on rajoute la valeur a la fin de tous les sujets deja entrés
|
||||||
$nouveauxsujets.=",";
|
$nouveauxsujets .= ',';
|
||||||
$nouveauxsujets.=str_replace(","," ",$_POST["nouvellecolonne"]);
|
$nouveauxsujets .= str_replace(',', ' ', $_POST['nouvellecolonne']);
|
||||||
$nouveauxsujets = htmlentities(html_entity_decode($nouveauxsujets, ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8');
|
$nouveauxsujets = htmlentities(html_entity_decode($nouveauxsujets, ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8');
|
||||||
|
|
||||||
//mise a jour avec les nouveaux sujets dans la base
|
//mise a jour avec les nouveaux sujets dans la base
|
||||||
@ -403,19 +424,18 @@ if (isset($_POST["ajoutercolonne"]) && Utils::issetAndNoEmpty('nouvellecolonne')
|
|||||||
|
|
||||||
|
|
||||||
//action quand on ajoute une colonne au format DATE
|
//action quand on ajoute une colonne au format DATE
|
||||||
if (isset($_POST["ajoutercolonne"]) && (substr($dsondage->format, 0, 1) == "D")) {
|
if (isset($_POST['ajoutercolonne']) && (substr($dsondage->format, 0, 1) == 'D')) {
|
||||||
$nouveauxsujets=$dsujet->sujet;
|
$nouveauxsujets=$dsujet->sujet;
|
||||||
|
|
||||||
if (isset($_POST["newdate"]) && $_POST["newdate"] != "vide") {
|
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));
|
$nouvelledate = 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"){
|
if (isset($_POST['newhour']) && $_POST['newhour'] != 'vide') {
|
||||||
$nouvelledate.="@";
|
$nouvelledate .= '@' . $_POST['newhour'];
|
||||||
$nouvelledate.=$_POST["newhour"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//on rajoute la valeur dans les valeurs
|
//on rajoute la valeur dans les valeurs
|
||||||
$datesbase = explode(",",$dsujet->sujet);
|
$datesbase = explode(',', $dsujet->sujet);
|
||||||
$taillebase = sizeof($datesbase);
|
$taillebase = sizeof($datesbase);
|
||||||
|
|
||||||
//recherche de l'endroit de l'insertion de la nouvelle date dans les dates deja entrées dans le tableau
|
//recherche de l'endroit de l'insertion de la nouvelle date dans les dates deja entrées dans le tableau
|
||||||
@ -424,7 +444,7 @@ if (isset($_POST["ajoutercolonne"]) && (substr($dsondage->format, 0, 1) == "D"))
|
|||||||
} elseif ($nouvelledate > $datesbase[$taillebase-1]) {
|
} elseif ($nouvelledate > $datesbase[$taillebase-1]) {
|
||||||
$cleinsertion = count($datesbase);
|
$cleinsertion = count($datesbase);
|
||||||
} else {
|
} else {
|
||||||
for ($i = 0; $i < count($datesbase); $i++) {
|
for ($i = 0; $i < count($datesbase); ++$i) {
|
||||||
$j = $i + 1;
|
$j = $i + 1;
|
||||||
if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) {
|
if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) {
|
||||||
$cleinsertion = $j;
|
$cleinsertion = $j;
|
||||||
@ -435,12 +455,11 @@ if (isset($_POST["ajoutercolonne"]) && (substr($dsondage->format, 0, 1) == "D"))
|
|||||||
array_splice($datesbase, $cleinsertion, 0, $nouvelledate);
|
array_splice($datesbase, $cleinsertion, 0, $nouvelledate);
|
||||||
$cle = array_search($nouvelledate, $datesbase);
|
$cle = array_search($nouvelledate, $datesbase);
|
||||||
$dateinsertion = '';
|
$dateinsertion = '';
|
||||||
for ($i = 0; $i < count($datesbase); $i++) {
|
for ($i = 0; $i < count($datesbase); ++$i) {
|
||||||
$dateinsertion.=",";
|
$dateinsertion .= ',' . $datesbase[$i];
|
||||||
$dateinsertion.=$datesbase[$i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$dateinsertion = substr("$dateinsertion", 1);
|
$dateinsertion = substr($dateinsertion, 1);
|
||||||
|
|
||||||
//mise a jour avec les nouveaux sujets dans la base
|
//mise a jour avec les nouveaux sujets dans la base
|
||||||
//if (isset($erreur_ajout_date) && !$erreur_ajout_date){
|
//if (isset($erreur_ajout_date) && !$erreur_ajout_date){
|
||||||
@ -464,12 +483,12 @@ if (isset($_POST["ajoutercolonne"]) && (substr($dsondage->format, 0, 1) == "D"))
|
|||||||
$newcar = '';
|
$newcar = '';
|
||||||
|
|
||||||
//parcours de toutes les réponses actuelles
|
//parcours de toutes les réponses actuelles
|
||||||
for ($j = 0; $j < $nbcolonnes; $j++) {
|
for ($j = 0; $j < $nbcolonnes; ++$j) {
|
||||||
$car = substr($ensemblereponses,$j,1);
|
$car = substr($ensemblereponses,$j,1);
|
||||||
|
|
||||||
//si les reponses ne concerne pas la colonne ajoutée, on concatene
|
//si les reponses ne concerne pas la colonne ajoutée, on concatene
|
||||||
if ($j == $cle) {
|
if ($j == $cle) {
|
||||||
$newcar.="0";
|
$newcar.='0';
|
||||||
}
|
}
|
||||||
|
|
||||||
$newcar .= $car;
|
$newcar .= $car;
|
||||||
@ -485,14 +504,14 @@ if (isset($_POST["ajoutercolonne"]) && (substr($dsondage->format, 0, 1) == "D"))
|
|||||||
send_mail_admin();
|
send_mail_admin();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$erreur_ajout_date="yes";
|
$erreur_ajout_date = 'yes';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//suppression de ligne dans la base
|
//suppression de ligne dans la base
|
||||||
for ($i = 0; $i < $nblignes; $i++) {
|
for ($i = 0; $i < $nblignes; ++$i) {
|
||||||
if (isset($_POST["effaceligne$i"])) {
|
if (isset($_POST['effaceligne'. $i])) {
|
||||||
$compteur = 0;
|
$compteur = 0;
|
||||||
$sql = 'DELETE FROM user_studs WHERE nom = '.$connect->Param('nom').' AND id_users = '.$connect->Param('id_users');
|
$sql = 'DELETE FROM user_studs WHERE nom = '.$connect->Param('nom').' AND id_users = '.$connect->Param('id_users');
|
||||||
$sql = $connect->Prepare($sql);
|
$sql = $connect->Prepare($sql);
|
||||||
@ -502,7 +521,7 @@ for ($i = 0; $i < $nblignes; $i++) {
|
|||||||
$connect->Execute($sql, array($data->nom, $data->id_users));
|
$connect->Execute($sql, array($data->nom, $data->id_users));
|
||||||
}
|
}
|
||||||
|
|
||||||
$compteur++;
|
++$compteur;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -520,7 +539,7 @@ while ($dcomment = $comment_user->FetchNextObject(false)) {
|
|||||||
$connect->Execute($sql, array($dcomment->id_comment));
|
$connect->Execute($sql, array($dcomment->id_comment));
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
++$i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -528,53 +547,43 @@ while ($dcomment = $comment_user->FetchNextObject(false)) {
|
|||||||
$testmodifier = false;
|
$testmodifier = false;
|
||||||
$testligneamodifier = false;
|
$testligneamodifier = false;
|
||||||
|
|
||||||
for ($i = 0; $i < $nblignes; $i++) {
|
for ($i = 0; $i < $nblignes; ++$i) {
|
||||||
if (isset($_POST["modifierligne$i"])) {
|
if (isset($_POST['modifierligne'. $i])) {
|
||||||
$ligneamodifier = $i;
|
$ligneamodifier = $i;
|
||||||
$testligneamodifier="true";
|
$testligneamodifier = 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
//test pour voir si une ligne est a modifier
|
//test pour voir si une ligne est à modifier
|
||||||
if (isset($_POST["validermodifier$i"])) {
|
if (isset($_POST['validermodifier'. $i])) {
|
||||||
$modifier = $i;
|
$modifier = $i;
|
||||||
$testmodifier="true";
|
$testmodifier = 'true';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//si le test est valide alors on affiche des checkbox pour entrer de nouvelles valeurs
|
//si le test est valide alors on affiche des checkbox pour entrer de nouvelles valeurs
|
||||||
if ($testmodifier) {
|
if ($testmodifier) {
|
||||||
$nouveauchoix = '';
|
$nouveauchoix = getNewChoiceFromPOST($nbcolonnes);
|
||||||
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;
|
$compteur = 0;
|
||||||
|
|
||||||
while ($data = $user_studs->FetchNextObject(false)) {
|
while ($data = $user_studs->FetchNextObject(false)) {
|
||||||
//mise a jour des données de l'utilisateur dans la base SQL
|
//mise à jour des données de l'utilisateur dans la base SQL
|
||||||
if ($compteur==$modifier) {
|
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 = 'UPDATE user_studs SET reponses = '.$connect->Param('reponses').' WHERE nom = '.$connect->Param('nom').' AND id_users = '.$connect->Param('id_users');
|
||||||
$sql = $connect->Prepare($sql);
|
$sql = $connect->Prepare($sql);
|
||||||
$connect->Execute($sql, array($nouveauchoix, $data->nom, $data->id_users));
|
$connect->Execute($sql, array($nouveauchoix, $data->nom, $data->id_users));
|
||||||
}
|
}
|
||||||
|
|
||||||
$compteur++;
|
++$compteur;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//suppression de colonnes dans la base
|
//suppression de colonnes dans la base
|
||||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
for ($i = 0; $i < $nbcolonnes; ++$i) {
|
||||||
if ((isset($_POST["effacecolonne$i"])) && $nbcolonnes > 1){
|
if ((isset($_POST['effacecolonne' .$i])) && $nbcolonnes > 1) {
|
||||||
$toutsujet = explode(",",$dsujet->sujet);
|
$toutsujet = explode(',', $dsujet->sujet);
|
||||||
//sort($toutsujet, SORT_NUMERIC);
|
//sort($toutsujet, SORT_NUMERIC);
|
||||||
$j = 0;
|
$j = 0;
|
||||||
$nouveauxsujets = '';
|
$nouveauxsujets = '';
|
||||||
@ -583,17 +592,16 @@ for ($i = 0; $i < $nbcolonnes; $i++) {
|
|||||||
while (isset($toutsujet[$j])) {
|
while (isset($toutsujet[$j])) {
|
||||||
//si le sujet n'est pas celui qui a été effacé alors on concatene
|
//si le sujet n'est pas celui qui a été effacé alors on concatene
|
||||||
if ($i != $j) {
|
if ($i != $j) {
|
||||||
$nouveauxsujets .= ',';
|
$nouveauxsujets .= ',' . $toutsujet[$j];
|
||||||
$nouveauxsujets .= $toutsujet[$j];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$j++;
|
++$j;
|
||||||
}
|
}
|
||||||
|
|
||||||
//on enleve la virgule au début
|
//on enlève la virgule au début
|
||||||
$nouveauxsujets = substr("$nouveauxsujets", 1);
|
$nouveauxsujets = substr($nouveauxsujets, 1);
|
||||||
|
|
||||||
//nettoyage des reponses actuelles correspondant au sujet effacé
|
//nettoyage des réponses actuelles correspondant au sujet effacé
|
||||||
$compteur = 0;
|
$compteur = 0;
|
||||||
$sql = 'UPDATE user_studs SET reponses = '.$connect->Param('reponses').' WHERE nom = '.$connect->Param('nom').' AND id_users = '.$connect->Param('id_users');
|
$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);
|
$sql = $connect->Prepare($sql);
|
||||||
@ -603,7 +611,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) {
|
|||||||
$ensemblereponses = $data->reponses;
|
$ensemblereponses = $data->reponses;
|
||||||
|
|
||||||
//parcours de toutes les réponses actuelles
|
//parcours de toutes les réponses actuelles
|
||||||
for ($j = 0; $j < $nbcolonnes; $j++) {
|
for ($j = 0; $j < $nbcolonnes; ++$j) {
|
||||||
$car=substr($ensemblereponses, $j, 1);
|
$car=substr($ensemblereponses, $j, 1);
|
||||||
//si les reponses ne concerne pas la colonne effacée, on concatene
|
//si les reponses ne concerne pas la colonne effacée, on concatene
|
||||||
if ($i != $j) {
|
if ($i != $j) {
|
||||||
@ -611,13 +619,13 @@ for ($i = 0; $i < $nbcolonnes; $i++) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$compteur++;
|
++$compteur;
|
||||||
|
|
||||||
//mise a jour des reponses utilisateurs dans la base
|
//mise à jour des reponses utilisateurs dans la base
|
||||||
$connect->Execute($sql, array($newcar, $data->nom, $data->id_users));
|
$connect->Execute($sql, array($newcar, $data->nom, $data->id_users));
|
||||||
}
|
}
|
||||||
|
|
||||||
//mise a jour des sujets dans la base
|
//mise à jour des sujets dans la base
|
||||||
$sql = 'UPDATE sujet_studs SET sujet = '.$connect->Param('nouveauxsujets').' WHERE id_sondage = '.$connect->Param('numsondage');
|
$sql = 'UPDATE sujet_studs SET sujet = '.$connect->Param('nouveauxsujets').' WHERE id_sondage = '.$connect->Param('numsondage');
|
||||||
$sql = $connect->Prepare($sql);
|
$sql = $connect->Prepare($sql);
|
||||||
$connect->Execute($sql, array($nouveauxsujets, $numsondage));
|
$connect->Execute($sql, array($nouveauxsujets, $numsondage));
|
||||||
@ -639,13 +647,12 @@ if ($sondage !== false) {
|
|||||||
$sql = $connect->Prepare($sql);
|
$sql = $connect->Prepare($sql);
|
||||||
$user_studs = $connect->Execute($sql, array($numsondage));
|
$user_studs = $connect->Execute($sql, array($numsondage));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Utils::print_header(_("Error!"));
|
Utils::print_header(_("Error!"));
|
||||||
bandeau_titre(_("Error!"));
|
bandeau_titre(_("Error!"));
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning">
|
||||||
<h2>' . _("This poll doesn't exist !") . '</h2>
|
<h2>' . _('This poll doesn\'t exist !') . '</h2>
|
||||||
<p>' . _('Back to the homepage of ') . ' <a href="' . Utils::get_server_name() . '"> ' . NOMAPPLICATION . '</a></p>
|
<p>' . _('Back to the homepage of ') . ' <a href="' . Utils::get_server_name() . '"> ' . NOMAPPLICATION . '</a></p>
|
||||||
</div>'."\n";
|
</div>'."\n";
|
||||||
|
|
||||||
@ -656,35 +663,44 @@ if ($sondage !== false) {
|
|||||||
|
|
||||||
// Errors
|
// Errors
|
||||||
$errors = '';
|
$errors = '';
|
||||||
if ((isset($_POST["boutonp"])) && $_POST["nom"] == "") {
|
if ((isset($_POST['boutonp'])) && $_POST['nom'] == '') {
|
||||||
$errors .= '<li>' . _("Enter a name") . '</li>';
|
$errors .= '<li>' . _('Enter a name') . '</li>';
|
||||||
}
|
}
|
||||||
if (isset($erreur_prenom) && $erreur_prenom) {
|
if (isset($erreur_prenom) && $erreur_prenom) {
|
||||||
$errors .= '<li>' . _("The name you've chosen already exist in this poll!") . '</li>';
|
$errors .= '<li>' . _('The name you\'ve chosen already exist in this poll!') . '</li>';
|
||||||
}
|
}
|
||||||
if (isset($erreur_injection) && $erreur_injection) {
|
if (isset($erreur_injection) && $erreur_injection) {
|
||||||
$errors .= '<li>' . _("Characters \" ' < et > are not permitted") . '</li>';
|
$errors .= '<li>' . _("Characters \" ' < et > are not permitted") . '</li>';
|
||||||
}
|
}
|
||||||
if (isset($erreur_ajout_date) && $erreur_ajout_date) {
|
if (isset($erreur_ajout_date) && $erreur_ajout_date) {
|
||||||
$errors .= '<li>' . _("The date is not correct !") . '</li>';
|
$errors .= '<li>' . _('The date is not correct!') . '</li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
//Poll title, description and email values
|
//Poll title, description and email values
|
||||||
$title = (isset($_POST["boutonnouveautitre"]) && Utils::issetAndNoEmpty('nouveautitre')) ? htmlentities(html_entity_decode($_POST['nouveautitre'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8') : stripslashes( $dsondage->titre );
|
$title = (isset($_POST['boutonnouveautitre']) && Utils::issetAndNoEmpty('nouveautitre'))
|
||||||
$description = (isset($_POST["nouveauxcommentaires"])) ? stripslashes(htmlentities(html_entity_decode($_POST['nouveauxcommentaires'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8')) : stripslashes( $dsondage->commentaires );
|
? htmlentities(html_entity_decode($_POST['nouveautitre'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8')
|
||||||
$email_admin = (isset($_POST["boutonnouvelleadresse"]) && Utils::issetAndNoEmpty('nouvelleadresse')) ? htmlentities(html_entity_decode($_POST['nouvelleadresse'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8') : stripslashes( $dsondage->mail_admin );
|
: stripslashes( $dsondage->titre );
|
||||||
|
$description = (isset($_POST['nouveauxcommentaires']))
|
||||||
|
? stripslashes(htmlentities(html_entity_decode($_POST['nouveauxcommentaires'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8'))
|
||||||
|
: stripslashes( $dsondage->commentaires );
|
||||||
|
$email_admin = (isset($_POST['boutonnouvelleadresse']) && Utils::issetAndNoEmpty('nouvelleadresse'))
|
||||||
|
? htmlentities(html_entity_decode($_POST['nouvelleadresse'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8')
|
||||||
|
: stripslashes( $dsondage->mail_admin );
|
||||||
|
|
||||||
//Poll format (locked A-/D-, open A/D, editable A+/D+)
|
//Poll format (locked A-/D-, open A/D, editable A+/D+)
|
||||||
$poll_rules = (isset($_POST["poll_rules"]) && Utils::issetAndNoEmpty('btn_poll_rules')) ? $_POST["poll_rules"] : substr($dsondage->format, 1, 1);
|
$poll_rules = (isset($_POST['poll_rules']) && Utils::issetAndNoEmpty('btn_poll_rules'))
|
||||||
$poll_rules_opt1 = '';$poll_rules_opt2 = '';$poll_rules_opt3 = '';
|
? $_POST['poll_rules'] : substr($dsondage->format, 1, 1);
|
||||||
|
$poll_rules_opt1 = '';
|
||||||
|
$poll_rules_opt2 = '';
|
||||||
|
$poll_rules_opt3 = '';
|
||||||
if($poll_rules == '+') {
|
if($poll_rules == '+') {
|
||||||
$poll_rules_text = '<span class="glyphicon glyphicon-edit"></span> '. _("Votes are editable");
|
$poll_rules_text = '<span class="glyphicon glyphicon-edit"></span> '. _('Votes are editable');
|
||||||
$poll_rules_opt3 = 'selected';
|
$poll_rules_opt3 = 'selected';
|
||||||
} elseif($poll_rules == '-') {
|
} elseif($poll_rules == '-') {
|
||||||
$poll_rules_text = '<span class="glyphicon glyphicon-lock"></span> '. _("Votes and comments are locked");
|
$poll_rules_text = '<span class="glyphicon glyphicon-lock"></span> '. _('Votes and comments are locked');
|
||||||
$poll_rules_opt1 = 'selected';
|
$poll_rules_opt1 = 'selected';
|
||||||
} else {
|
} else {
|
||||||
$poll_rules_text = '<span class="glyphicon glyphicon-check"></span> '. _("Votes and comments are open");
|
$poll_rules_text = '<span class="glyphicon glyphicon-check"></span> '. _('Votes and comments are open');
|
||||||
$poll_rules_opt2 = 'selected';
|
$poll_rules_opt2 = 'selected';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -693,7 +709,6 @@ if ($errors!='') {
|
|||||||
bandeau_titre(_("Error!"));
|
bandeau_titre(_("Error!"));
|
||||||
|
|
||||||
echo '<div class="alert alert-danger"><ul class="list-unstyled">'.$errors.'</ul></div>'."\n";
|
echo '<div class="alert alert-danger"><ul class="list-unstyled">'.$errors.'</ul></div>'."\n";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Utils::print_header(_('Poll administration').' - '.$title);
|
Utils::print_header(_('Poll administration').' - '.$title);
|
||||||
bandeau_titre(_('Poll administration').' - '.$title);
|
bandeau_titre(_('Poll administration').' - '.$title);
|
||||||
@ -723,13 +738,13 @@ echo '
|
|||||||
<button onclick="javascript:print(); return false;" class="btn btn-default"><span class="glyphicon glyphicon-print"></span> ' . _('Print') . '</button>
|
<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>
|
<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>
|
||||||
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown">
|
<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>
|
<span class="glyphicon glyphicon-trash"></span> <span class="sr-only">' . _('Remove') . '</span> <span class="caret"></span>
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu" role="menu">
|
<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="removevotes">' . _('Remove all the votes') . '</button></li>
|
||||||
<li><button class="btn btn-link" type="submit" name="removecomments">' . _('Remove all the comments') . '</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 class="divider" role="presentation"></li>
|
||||||
<li><button class="btn btn-link" type="submit" id="suppressionsondage" name="suppressionsondage" value="" >'. _("Remove the poll") .'</button></li>
|
<li><button class="btn btn-link" type="submit" id="suppressionsondage" name="suppressionsondage" value="" >'. _('Remove the poll') .'</button></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -810,8 +825,8 @@ $dsujet=$sujets->FetchObject(false);
|
|||||||
$dsondage=$sondage->FetchObject(false);
|
$dsondage=$sondage->FetchObject(false);
|
||||||
|
|
||||||
//reformatage des données des sujets du sondage
|
//reformatage des données des sujets du sondage
|
||||||
$toutsujet=explode(",",$dsujet->sujet);
|
$toutsujet = explode(',', $dsujet->sujet);
|
||||||
$toutsujet=str_replace("°","'",$toutsujet);
|
$toutsujet = str_replace('°', '\'',$toutsujet);
|
||||||
$nbcolonnes = substr_count($dsujet->sujet,',') +1;
|
$nbcolonnes = substr_count($dsujet->sujet,',') +1;
|
||||||
|
|
||||||
// Table headers
|
// Table headers
|
||||||
@ -825,7 +840,7 @@ $td_headers = array(); // for a11y, headers="M1 D4 H5" on each td
|
|||||||
$radio_title = array(); // date for
|
$radio_title = array(); // date for
|
||||||
|
|
||||||
// Dates poll
|
// Dates poll
|
||||||
if (substr($dsondage->format, 0, 1)=="D") {
|
if (substr($dsondage->format, 0, 1) == 'D') {
|
||||||
|
|
||||||
$tr_months = '<tr><th role="presentation"></th>';
|
$tr_months = '<tr><th role="presentation"></th>';
|
||||||
$tr_days = '<tr><th role="presentation"></th>';
|
$tr_days = '<tr><th role="presentation"></th>';
|
||||||
@ -835,14 +850,14 @@ if (substr($dsondage->format, 0, 1)=="D") {
|
|||||||
$colspan_month = 1;
|
$colspan_month = 1;
|
||||||
$colspan_day = 1;
|
$colspan_day = 1;
|
||||||
|
|
||||||
for ($i = 0; $i < count($toutsujet); $i++) {
|
for ($i = 0; $i < count($toutsujet); ++$i) {
|
||||||
|
|
||||||
// Current date
|
// Current date
|
||||||
$current = $toutsujet[$i];//format date@hour. ex : 2020292820@10:00
|
$current = $toutsujet[$i];//format date@hour. ex : 2020292820@10:00
|
||||||
$horoCur = explode("@",$current); //horoCur[0] = date, horoCur[1] = hour
|
$horoCur = explode("@",$current); //horoCur[0] = date, horoCur[1] = hour
|
||||||
if (isset($toutsujet[$i+1])){
|
if (isset($toutsujet[$i+1])){
|
||||||
$next = $toutsujet[$i+1];
|
$next = $toutsujet[$i+1];
|
||||||
$horoNext = explode("@",$next);
|
$horoNext = explode('@', $next);
|
||||||
}
|
}
|
||||||
$border[$i] = false;
|
$border[$i] = false;
|
||||||
$radio_title[$i] = strftime($date_format['txt_short'],$horoCur[0]);
|
$radio_title[$i] = strftime($date_format['txt_short'],$horoCur[0]);
|
||||||
@ -862,7 +877,7 @@ if (substr($dsondage->format, 0, 1)=="D") {
|
|||||||
$td_headers[$i] .= ' D'.($i+1-$colspan_day);
|
$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($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++;
|
++$colspan_day;
|
||||||
} else {
|
} else {
|
||||||
$rbd = ($border[$i]) ? ' rbd' : '';
|
$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>';
|
$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>';
|
||||||
@ -880,7 +895,9 @@ if (substr($dsondage->format, 0, 1)=="D") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove col
|
// 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($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>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -891,19 +908,20 @@ if (substr($dsondage->format, 0, 1)=="D") {
|
|||||||
$tr_hours .= '<th></th></tr>';
|
$tr_hours .= '<th></th></tr>';
|
||||||
|
|
||||||
// Add col
|
// Add col
|
||||||
$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>';
|
$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>';
|
||||||
|
|
||||||
$thead = "\n".$tr_add_remove_col."\n".$tr_months."\n".$tr_days."\n".$tr_hours."\n";
|
$thead = "\n".$tr_add_remove_col."\n".$tr_months."\n".$tr_days."\n".$tr_hours."\n";
|
||||||
|
|
||||||
// Subjects poll
|
// Subjects poll
|
||||||
} else {
|
} else {
|
||||||
$toutsujet=str_replace("@","<br />",$toutsujet);
|
$toutsujet=str_replace('@', '<br />', $toutsujet);
|
||||||
|
|
||||||
$tr_subjects = '<tr><th role="presentation"></th>';
|
$tr_subjects = '<tr><th role="presentation"></th>';
|
||||||
|
|
||||||
for ($i = 0; isset($toutsujet[$i]); $i++) {
|
for ($i = 0; isset($toutsujet[$i]); ++$i) {
|
||||||
|
|
||||||
$td_headers[$i]='';$radio_title[$i]=''; // init before concatenate
|
$td_headers[$i]='';
|
||||||
|
$radio_title[$i]=''; // init before concatenate
|
||||||
|
|
||||||
// Subjects
|
// Subjects
|
||||||
preg_match_all('/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/',$toutsujet[$i],$md_a_img); // Markdown [![alt](src)](href)
|
preg_match_all('/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/',$toutsujet[$i],$md_a_img); // Markdown [![alt](src)](href)
|
||||||
@ -985,7 +1003,7 @@ while ($data = $user_studs->FetchNextObject(false)) {
|
|||||||
$ensemblereponses = $data->reponses;
|
$ensemblereponses = $data->reponses;
|
||||||
|
|
||||||
// Print name
|
// Print name
|
||||||
$nombase=str_replace("°","'",$data->nom);
|
$nombase=str_replace('°', '\'',$data->nom);
|
||||||
echo '<tr>
|
echo '<tr>
|
||||||
<th class="bg-info">'.stripslashes($nombase).'</th>'."\n";
|
<th class="bg-info">'.stripslashes($nombase).'</th>'."\n";
|
||||||
|
|
||||||
@ -995,28 +1013,30 @@ while ($data = $user_studs->FetchNextObject(false)) {
|
|||||||
$rbd = ($border[$k]) ? ' rbd' : '';
|
$rbd = ($border[$k]) ? ' rbd' : '';
|
||||||
$car = substr($ensemblereponses, $k, 1);
|
$car = substr($ensemblereponses, $k, 1);
|
||||||
switch ($car) {
|
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";
|
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) {
|
if (isset($somme[$k]) === false) {
|
||||||
$somme[$k] = 0;
|
$somme[$k] = 0;
|
||||||
}
|
}
|
||||||
$somme[$k]++; break;
|
++$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;
|
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;
|
default: echo '<td class="bg-danger'.$rbd.'" headers="'.$td_headers[$k].'"><span class="sr-only">' . _('No') . '</span></td>'."\n";break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // sinon on remplace les choix de l'utilisateur par une ligne de radio pour recuperer de nouvelles valeurs
|
} 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
|
// si c'est bien la ligne a modifier on met les radios
|
||||||
if ($compteur == "$ligneamodifier") {
|
if ($compteur == $ligneamodifier) {
|
||||||
for ($j = 0; $j < $nbcolonnes; $j++) {
|
for ($j = 0; $j < $nbcolonnes; ++$j) {
|
||||||
|
|
||||||
$car = substr($ensemblereponses, $j, 1);
|
$car = substr($ensemblereponses, $j, 1);
|
||||||
|
|
||||||
// variable pour afficher la valeur cochée
|
// variable pour afficher la valeur cochée
|
||||||
$car_html[0]='value="0"';$car_html[1]='value="1"';$car_html[2]='value="2"';
|
$car_html[0] = 'value="0"';
|
||||||
|
$car_html[1] = 'value="1"';
|
||||||
|
$car_html[2] = 'value="2"';
|
||||||
switch ($car) {
|
switch ($car) {
|
||||||
case "1": $car_html[1]='value="1" checked';break;
|
case '1': $car_html[1]='value="1" checked'; break;
|
||||||
case "2": $car_html[2]='value="2" checked';break;
|
case '2': $car_html[2]='value="2" checked'; break;
|
||||||
default: $car_html[0]='value="0" checked';break;
|
default: $car_html[0]='value="0" checked';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
@ -1045,24 +1065,24 @@ while ($data = $user_studs->FetchNextObject(false)) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
} else { //sinon on affiche les lignes normales
|
} else { //sinon on affiche les lignes normales
|
||||||
for ($k = 0; $k < $nbcolonnes; $k++) {
|
for ($k = 0; $k < $nbcolonnes; ++$k) {
|
||||||
$rbd = ($border[$k]) ? ' rbd' : '';
|
$rbd = ($border[$k]) ? ' rbd' : '';
|
||||||
$car = substr($ensemblereponses, $k, 1);
|
$car = substr($ensemblereponses, $k, 1);
|
||||||
switch ($car) {
|
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";
|
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) {
|
if (isset($somme[$k]) === false) {
|
||||||
$somme[$k] = 0;
|
$somme[$k] = 0;
|
||||||
}
|
}
|
||||||
$somme[$k]++; break;
|
++$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;
|
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;
|
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
|
//a la fin de chaque ligne se trouve les boutons modifier
|
||||||
if (!$testligneamodifier=="true") {
|
if (!$testligneamodifier == 'true') {
|
||||||
echo '
|
echo '
|
||||||
<td>
|
<td>
|
||||||
<button type="submit" class="btn btn-link btn-sm" name="modifierligne'.$compteur.'" title="'. _('Edit the line:') .' '.stripslashes($nombase).'">
|
<button type="submit" class="btn btn-link btn-sm" name="modifierligne'.$compteur.'" title="'. _('Edit the line:') .' '.stripslashes($nombase).'">
|
||||||
@ -1075,19 +1095,19 @@ while ($data = $user_studs->FetchNextObject(false)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//demande de confirmation pour modification de ligne
|
//demande de confirmation pour modification de ligne
|
||||||
for ($i = 0; $i < $nblignes; $i++) {
|
for ($i = 0; $i < $nblignes; ++$i) {
|
||||||
if (isset($_POST["modifierligne$i"])) {
|
if (isset($_POST['modifierligne'. $i])) {
|
||||||
if ($compteur == $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";
|
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++;
|
++$compteur;
|
||||||
echo '</tr>'."\n";
|
echo '</tr>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$testligneamodifier=="true") {
|
if (!$testligneamodifier == 'true') {
|
||||||
//affichage de la case vide de texte pour un nouvel utilisateur
|
//affichage de la case vide de texte pour un nouvel utilisateur
|
||||||
echo '<tr id="vote-form">
|
echo '<tr id="vote-form">
|
||||||
<td class="bg-info" style="padding:5px">
|
<td class="bg-info" style="padding:5px">
|
||||||
@ -1098,7 +1118,7 @@ if (!$testligneamodifier=="true") {
|
|||||||
</td>'."\n";
|
</td>'."\n";
|
||||||
|
|
||||||
//une ligne de checkbox pour le choix du nouvel utilisateur
|
//une ligne de checkbox pour le choix du nouvel utilisateur
|
||||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
for ($i = 0; $i < $nbcolonnes; ++$i) {
|
||||||
echo '
|
echo '
|
||||||
<td class="bg-info" headers="'.$td_headers[$i].'">
|
<td class="bg-info" headers="'.$td_headers[$i].'">
|
||||||
<ul class="list-unstyled choice">
|
<ul class="list-unstyled choice">
|
||||||
@ -1143,7 +1163,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) {
|
|||||||
$tr_addition .= '<td><span class="glyphicon glyphicon-star text-warning"></span><span>'.$somme[$i].'</span></td>';
|
$tr_addition .= '<td><span class="glyphicon glyphicon-star text-warning"></span><span>'.$somme[$i].'</span></td>';
|
||||||
|
|
||||||
$meilleursujet.= '<li><b>'.$radio_title[$i].'</b></li>';
|
$meilleursujet.= '<li><b>'.$radio_title[$i].'</b></li>';
|
||||||
$compteursujet++;
|
++$compteursujet;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$tr_addition .= '<td>'.$somme[$i].'</td>';
|
$tr_addition .= '<td>'.$somme[$i].'</td>';
|
||||||
@ -1155,9 +1175,9 @@ for ($i = 0; $i < $nbcolonnes; $i++) {
|
|||||||
$tr_addition .= '<td></td></tr>';
|
$tr_addition .= '<td></td></tr>';
|
||||||
|
|
||||||
//recuperation des valeurs des sujets et adaptation pour affichage
|
//recuperation des valeurs des sujets et adaptation pour affichage
|
||||||
$toutsujet = explode(",", $dsujet->sujet);
|
$toutsujet = explode(',', $dsujet->sujet);
|
||||||
|
|
||||||
$meilleursujet = str_replace("°", "'", $meilleursujet).'</ul>';
|
$meilleursujet = str_replace('°', '\'', $meilleursujet).'</ul>';
|
||||||
$vote_str = ($meilleurecolonne > 1) ? $vote_str = _('votes') : _('vote');
|
$vote_str = ($meilleurecolonne > 1) ? $vote_str = _('votes') : _('vote');
|
||||||
|
|
||||||
// Print Addition and Best choice
|
// Print Addition and Best choice
|
||||||
@ -1194,7 +1214,7 @@ $sql = $connect->Prepare($sql);
|
|||||||
$comment_user = $connect->Execute($sql, array($numsondage));
|
$comment_user = $connect->Execute($sql, array($numsondage));
|
||||||
|
|
||||||
if ($comment_user->RecordCount() != 0) {
|
if ($comment_user->RecordCount() != 0) {
|
||||||
echo '<div><h3>' . _("Comments of polled people") . '</h3>'."\n";
|
echo '<div><h3>' . _('Comments of polled people') . '</h3>'."\n";
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ( $dcomment=$comment_user->FetchNextObject(false)) {
|
while ( $dcomment=$comment_user->FetchNextObject(false)) {
|
||||||
@ -1211,15 +1231,15 @@ if ($comment_user->RecordCount() != 0) {
|
|||||||
echo '
|
echo '
|
||||||
<div class="hidden-print alert alert-info">
|
<div class="hidden-print alert alert-info">
|
||||||
<div class="col-md-6 col-md-offset-3">
|
<div class="col-md-6 col-md-offset-3">
|
||||||
<fieldset id="add-comment"><legend>' . _("Add a comment in the poll") . '</legend>
|
<fieldset id="add-comment"><legend>' . _('Add a comment in the poll') . '</legend>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<p><label for="commentuser">'. _("Your name") .'</label><input type=text name="commentuser" class="form-control" id="commentuser" /></p>
|
<p><label for="commentuser">'. _('Your name') .'</label><input type=text name="commentuser" class="form-control" id="commentuser" /></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<p><label for="comment">'. _("Your comment") .'</label><br />
|
<p><label for="comment">'. _('Your comment') .'</label><br />
|
||||||
<textarea name="comment" id="comment" class="form-control" rows="2" cols="40"></textarea></p>
|
<textarea name="comment" id="comment" class="form-control" rows="2" cols="40"></textarea></p>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-center"><input type="submit" name="ajoutcomment" value="'. _("Send the comment") .'" class="btn btn-success"></p>
|
<p class="text-center"><input type="submit" name="ajoutcomment" value="'. _('Send the comment') .'" class="btn btn-success"></p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user