<?php
#########################################################################################
# Recherche dans les propositions de Pnyx - scripts bdd #
# Auteur : V. Blais #
# Création : 2006-04-05 #
# Modification : 2008-09-03 #
# #
# Pnyx - une application Web (PHP/MySQL) d'élections virtuelles conçue pour des élèves #
# du primaire et du secondaire, dans lequel ils sont amenés à faire des propositions #
# en ligne et voter pour leur favorite, sous la supervision d'un enseignant. #
# #
# Copyright (C) <2008 - 2009> #
# <Service national du RÉCIT de l'univers social de la Commission scolaire de la #
# Pointe-de-l'Île> #
# #
# This program is free software; you can redistribute it and/or modify it under the #
# terms of the GNU General Public License as published by the Free Software Foundation. #
# This program is distributed in the hope that it will be useful, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A #
# PARTICULAR PURPOSE. See the GNU General Public License for more details. #
# You should have received a copy of the GNU General Public License along with this #
# program as the file LICENSE.txt; if not, please see #
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. #
# #
# Service national du RÉCIT de l'univers social #
# http://www.recitus.qc.ca #
# Contact e-mail : steve-hide@address.com #
#########################################################################################
require "entete_php.php";
if (! session_is_registered("RECH")) {
session_register("RECH");
$HTTP_SESSION_VARS['RECH']["cat"] = "";
$HTTP_SESSION_VARS['RECH']["tous"] = "";
$HTTP_SESSION_VARS['RECH']["niveau"] = "";
$HTTP_SESSION_VARS['RECH']["niveau_scol"] = "";
$HTTP_SESSION_VARS['RECH']["typegrp"] = "";
$HTTP_SESSION_VARS['RECH']["ecole"] = "";
$HTTP_SESSION_VARS['RECH']["groupe"] = "";
$HTTP_SESSION_VARS['RECH']["region"] = "";
$HTTP_SESSION_VARS['RECH']["circons"] = "";
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.date_valide DESC";
}
if(isset($HTTP_GET_VARS['type_action'])){
if ($HTTP_GET_VARS['type_action'] == "tous"){
$HTTP_SESSION_VARS['RECH']["cat"] = "";
$HTTP_SESSION_VARS['RECH']["tous"] = "y";
$HTTP_SESSION_VARS['RECH']["niveau"] = "";
$HTTP_SESSION_VARS['RECH']["niveau_scol"] = "";
$HTTP_SESSION_VARS['RECH']["typegrp"] = "";
$HTTP_SESSION_VARS['RECH']["ecole"] = "";
$HTTP_SESSION_VARS['RECH']["groupe"] = "";
$HTTP_SESSION_VARS['RECH']["region"] = "";
$HTTP_SESSION_VARS['RECH']["circons"] = "";
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.date_valide DESC";
if($periode == "vote" || $periode == "fin_vote"){
$HTTP_SESSION_VARS['SESSION']['onglet'] = 2;
}
else{
$HTTP_SESSION_VARS['SESSION']['onglet'] = 1;
}
header("Location: gen_rech_prog.php");
}
if ($HTTP_GET_VARS['type_action'] == "rechA1"){
$HTTP_SESSION_VARS['RECH']["cat"] = "";
$HTTP_SESSION_VARS['RECH']["tous"] = "";
$HTTP_SESSION_VARS['RECH']["niveau"] = "";
$HTTP_SESSION_VARS['RECH']["niveau_scol"] = "1er cycle secondaire";
$HTTP_SESSION_VARS['RECH']["typegrp"] = "";
$HTTP_SESSION_VARS['RECH']["ecole"] = "";
$HTTP_SESSION_VARS['RECH']["groupe"] = "";
$HTTP_SESSION_VARS['RECH']["region"] = "";
$HTTP_SESSION_VARS['RECH']["circons"] = "";
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.date_valide DESC";
if($periode == "vote" || $periode == "fin_vote"){
$HTTP_SESSION_VARS['SESSION']['onglet'] = 2;
}
else{
$HTTP_SESSION_VARS['SESSION']['onglet'] = 1;
}
header("Location: gen_rech_prog.php");
}
if ($HTTP_GET_VARS['type_action'] == "rechA2"){
$HTTP_SESSION_VARS['RECH']["cat"] = "";
$HTTP_SESSION_VARS['RECH']["tous"] = "";
$HTTP_SESSION_VARS['RECH']["niveau"] = "";
$HTTP_SESSION_VARS['RECH']["niveau_scol"] = "2e cycle secondaire";
$HTTP_SESSION_VARS['RECH']["typegrp"] = "";
$HTTP_SESSION_VARS['RECH']["ecole"] = "";
$HTTP_SESSION_VARS['RECH']["groupe"] = "";
$HTTP_SESSION_VARS['RECH']["region"] = "";
$HTTP_SESSION_VARS['RECH']["circons"] = "";
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.date_valide DESC";
if($periode == "vote" || $periode == "fin_vote"){
$HTTP_SESSION_VARS['SESSION']['onglet'] = 2;
}
else{
$HTTP_SESSION_VARS['SESSION']['onglet'] = 1;
}
header("Location: gen_rech_prog.php");
}
if ($HTTP_GET_VARS['type_action'] == "rechA3"){
$HTTP_SESSION_VARS['RECH']["cat"] = "";
$HTTP_SESSION_VARS['RECH']["tous"] = "";
$HTTP_SESSION_VARS['RECH']["niveau"] = "";
$HTTP_SESSION_VARS['RECH']["niveau_scol"] = "3e cycle primaire";
$HTTP_SESSION_VARS['RECH']["typegrp"] = "";
$HTTP_SESSION_VARS['RECH']["ecole"] = "";
$HTTP_SESSION_VARS['RECH']["groupe"] = "";
$HTTP_SESSION_VARS['RECH']["region"] = "";
$HTTP_SESSION_VARS['RECH']["circons"] = "";
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.date_valide DESC";
if($periode == "vote" || $periode == "fin_vote"){
$HTTP_SESSION_VARS['SESSION']['onglet'] = 2;
}
else{
$HTTP_SESSION_VARS['SESSION']['onglet'] = 1;
}
header("Location: gen_rech_prog.php");
}
if ($HTTP_GET_VARS['type_action'] == "rechA4"){
$HTTP_SESSION_VARS['RECH']["cat"] = "";
$HTTP_SESSION_VARS['RECH']["tous"] = "";
$HTTP_SESSION_VARS['RECH']["niveau"] = "";
$HTTP_SESSION_VARS['RECH']["niveau_scol"] = "2e cycle primaire";
$HTTP_SESSION_VARS['RECH']["typegrp"] = "";
$HTTP_SESSION_VARS['RECH']["ecole"] = "";
$HTTP_SESSION_VARS['RECH']["groupe"] = "";
$HTTP_SESSION_VARS['RECH']["region"] = "";
$HTTP_SESSION_VARS['RECH']["circons"] = "";
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.date_valide DESC";
if($periode == "vote" || $periode == "fin_vote"){
$HTTP_SESSION_VARS['SESSION']['onglet'] = 2;
}
else{
$HTTP_SESSION_VARS['SESSION']['onglet'] = 1;
}
header("Location: gen_rech_prog.php");
}
if ($HTTP_GET_VARS['type_action'] == "rechA5"){
$HTTP_SESSION_VARS['RECH']["cat"] = "";
$HTTP_SESSION_VARS['RECH']["tous"] = "";
$HTTP_SESSION_VARS['RECH']["niveau"] = "";
$HTTP_SESSION_VARS['RECH']["niveau_scol"] = "1er cycle primaire";
$HTTP_SESSION_VARS['RECH']["typegrp"] = "";
$HTTP_SESSION_VARS['RECH']["ecole"] = "";
$HTTP_SESSION_VARS['RECH']["groupe"] = "";
$HTTP_SESSION_VARS['RECH']["region"] = "";
$HTTP_SESSION_VARS['RECH']["circons"] = "";
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.date_valide DESC";
if($periode == "vote" || $periode == "fin_vote"){
$HTTP_SESSION_VARS['SESSION']['onglet'] = 2;
}
else{
$HTTP_SESSION_VARS['SESSION']['onglet'] = 1;
}
header("Location: gen_rech_prog.php");
}
if ($HTTP_GET_VARS['type_action'] == "nouv_region"){
$HTTP_SESSION_VARS['RECH']["cat"] = "";
$HTTP_SESSION_VARS['RECH']["tous"] = "";
$HTTP_SESSION_VARS['RECH']["niveau"] = "";
$HTTP_SESSION_VARS['RECH']["niveau_scol"] = "";
$HTTP_SESSION_VARS['RECH']["typegrp"] = "";
$HTTP_SESSION_VARS['RECH']["ecole"] = "";
$HTTP_SESSION_VARS['RECH']["groupe"] = "";
$HTTP_SESSION_VARS['RECH']["region"] = "";
$HTTP_SESSION_VARS['RECH']["circons"] = "";
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.date_valide DESC";
header("Location: gen_rech_region.php");
}
if ($HTTP_GET_VARS['type_action'] == "nouv_ecole"){
$HTTP_SESSION_VARS['RECH']["cat"] = "";
$HTTP_SESSION_VARS['RECH']["tous"] = "";
$HTTP_SESSION_VARS['RECH']["niveau"] = "";
$HTTP_SESSION_VARS['RECH']["niveau_scol"] = "";
$HTTP_SESSION_VARS['RECH']["typegrp"] = "";
$HTTP_SESSION_VARS['RECH']["ecole"] = "";
$HTTP_SESSION_VARS['RECH']["groupe"] = "";
$HTTP_SESSION_VARS['RECH']["region"] = "";
$HTTP_SESSION_VARS['RECH']["circons"] = "";
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.date_valide DESC";
header("Location: gen_rech_ecole.php");
}
}
if(isset($HTTP_POST_VARS['type_action'])){
if ($HTTP_POST_VARS['type_action'] == "rech_crit"){
$HTTP_SESSION_VARS['RECH']["niveau"] = $HTTP_POST_VARS['niveau'];
$HTTP_SESSION_VARS['RECH']["cat"] = $HTTP_POST_VARS['cat'];
$HTTP_SESSION_VARS['RECH']["niveau_scol"] = $HTTP_POST_VARS['niveau_scol'];
$HTTP_SESSION_VARS['RECH']["typegrp"] = $HTTP_POST_VARS['typegrp'];
$HTTP_SESSION_VARS['RECH']["tous"] = "";
if($periode == "vote" || $periode == "fin_vote"){
$HTTP_SESSION_VARS['SESSION']['onglet'] = 2;
}
else{
$HTTP_SESSION_VARS['SESSION']['onglet'] = 1;
}
header("Location: gen_rech_prog.php");
}
}
if (isset($HTTP_GET_VARS['id_ecole'])){
$HTTP_SESSION_VARS['RECH']["ecole"] = $HTTP_GET_VARS['id_ecole'];
if($periode == "vote" || $periode == "fin_vote"){
$HTTP_SESSION_VARS['SESSION']['onglet'] = 2;
}
else{
$HTTP_SESSION_VARS['SESSION']['onglet'] = 1;
}
header("Location: gen_rech_prog.php");
}
if(isset($HTTP_POST_VARS['type_action'])){
if ($HTTP_POST_VARS['type_action'] == "rech_ecole"){
$HTTP_SESSION_VARS['RECH']["ecole"] = $HTTP_POST_VARS['ecole'];
$HTTP_SESSION_VARS['RECH']["groupe"] = $HTTP_POST_VARS['groupe'];
$HTTP_SESSION_VARS['RECH']["region"] = $HTTP_POST_VARS['region'];
$HTTP_SESSION_VARS['RECH']["circons"] = $HTTP_POST_VARS['circons'];
if($periode == "vote" || $periode == "fin_vote"){
$HTTP_SESSION_VARS['SESSION']['onglet'] = 2;
}
else{
$HTTP_SESSION_VARS['SESSION']['onglet'] = 1;
}
header("Location: gen_rech_prog.php");
}
if ($HTTP_POST_VARS['type_action'] == "ordre"){
if ($HTTP_POST_VARS['ordre'] == "prop_asc"){
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.slogan ASC";
}
if ($HTTP_POST_VARS['ordre'] == "prop_desc"){
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.slogan DESC";
}
if ($HTTP_POST_VARS['ordre'] == "date_asc"){
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.date_valide ASC";
}
if ($HTTP_POST_VARS['ordre'] == "date_desc"){
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.date_valide DESC";
}
if ($HTTP_POST_VARS['ordre'] == "auteur_asc"){
$HTTP_SESSION_VARS['RECH']["ordre"] = "U.login ASC";
}
if ($HTTP_POST_VARS['ordre'] == "auteur_desc"){
$HTTP_SESSION_VARS['RECH']["ordre"] = "U.login DESC";
}
if ($HTTP_POST_VARS['ordre'] == "cat_asc"){
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.categorie ASC";
}
if ($HTTP_POST_VARS['ordre'] == "cat_desc"){
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.categorie DESC";
}
if ($HTTP_POST_VARS['ordre'] == "ecole_asc"){
$HTTP_SESSION_VARS['RECH']["ordre"] = "EC.nom ASC";
}
if ($HTTP_POST_VARS['ordre'] == "ecole_desc"){
$HTTP_SESSION_VARS['RECH']["ordre"] = "EC.nom DESC";
}
if ($HTTP_POST_VARS['ordre'] == "groupe_asc"){
$HTTP_SESSION_VARS['RECH']["ordre"] = "G.nom ASC";
}
if ($HTTP_POST_VARS['ordre'] == "groupe_desc"){
$HTTP_SESSION_VARS['RECH']["ordre"] = "G.nom DESC";
}
if ($HTTP_POST_VARS['ordre'] == "app_desc"){
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.app_moyenne DESC";
}
if ($HTTP_POST_VARS['ordre'] == "app_asc"){
$HTTP_SESSION_VARS['RECH']["ordre"] = "F.app_moyenne ASC";
}
header("Location: gen_rech_prog.php");
}
}
if(isset($HTTP_GET_VARS['type_action'])){
if ($HTTP_GET_VARS['type_action'] == "retour"){
# echo "GET:";
# gen_variables_get();
if(isset($_GET['onglet'])){
$HTTP_SESSION_VARS['SESSION']['onglet'] = $_GET['onglet'];
}
if ($HTTP_GET_VARS["tous"] == "y"){
$HTTP_SESSION_VARS['RECH']['tous'] = "y";
} else {
if (isset($HTTP_GET_VARS["cat"])){
$HTTP_SESSION_VARS['RECH']["cat"] = $HTTP_GET_VARS["cat"];
}
if (isset($HTTP_GET_VARS["niveau"] )){
$HTTP_SESSION_VARS['RECH']["niveau"] = $HTTP_GET_VARS["niveau"];
}
if (isset($HTTP_GET_VARS["niveau_scol"])){
$HTTP_SESSION_VARS['RECH']["niveau_scol"] = $HTTP_GET_VARS["niveau_scol"];
}
if (isset($HTTP_GET_VARS["typegrp"])){
$HTTP_SESSION_VARS['RECH']["typegrp"] = $HTTP_GET_VARS["typegrp"];
}
if (isset($HTTP_GET_VARS["ecole"])){
$HTTP_SESSION_VARS['RECH']["ecole"] = $HTTP_GET_VARS["ecole"];
}
if (isset($HTTP_GET_VARS["groupe"])){
$HTTP_SESSION_VARS['RECH']["groupe"] = $HTTP_GET_VARS["groupe"];
}
if (isset($HTTP_GET_VARS["region"])){
$HTTP_SESSION_VARS['RECH']["region"] = $HTTP_GET_VARS["region"];
}
if (isset($HTTP_GET_VARS["circons"])){
$HTTP_SESSION_VARS['RECH']["circons"] = $HTTP_GET_VARS["circons"];
}
if (isset($HTTP_GET_VARS["ordre"] )){
$HTTP_SESSION_VARS['RECH']["ordre"] = $HTTP_GET_VARS["ordre"];
}
}
if (isset($HTTP_GET_VARS["tout"])){
session_register("TOUT");
$HTTP_SESSION_VARS["TOUT"] = "y";
}
# echo "SESSION:";
# gen_variables_session();
session_unregister("RETOUR");
header("Location: gen_rech_prog.php");
}
if ($HTTP_GET_VARS['type_action'] == "aff_prop"){
#LIEN DE RETOUR À PAGE RECHERCHE
if (session_is_registered("RECH")) {
$retour = "gen_rech_prog2.php?type_action=retour";
if ($HTTP_SESSION_VARS['RECH']["tous"] == "y"){
$retour = $retour."&tous=y";
if(isset($HTTP_SESSION_VARS["TOUT"])){
if ($HTTP_SESSION_VARS["TOUT"] == "y"){
$retour = $retour."&tout=y";
}
}
} else {
if ($HTTP_SESSION_VARS['RECH']["cat"] != ""){
$retour = $retour."&cat=".$HTTP_SESSION_VARS['RECH']["cat"];
}
if ($HTTP_SESSION_VARS['RECH']["niveau"] != ""){
$retour = $retour."&niveau=".$HTTP_SESSION_VARS['RECH']["niveau"];
}
if ($HTTP_SESSION_VARS['RECH']["niveau_scol"] != ""){
$retour = $retour."&niveau_scol=".$HTTP_SESSION_VARS['RECH']["niveau_scol"];
}
if ($HTTP_SESSION_VARS['RECH']["typegrp"] != ""){
$retour = $retour."&typegrp=".$HTTP_SESSION_VARS['RECH']["typegrp"];
}
if ($HTTP_SESSION_VARS['RECH']["ecole"] != ""){
$retour = $retour."&ecole=".$HTTP_SESSION_VARS['RECH']["ecole"];
}
if ($HTTP_SESSION_VARS['RECH']["groupe"] != ""){
$retour = $retour."&groupe=".$HTTP_SESSION_VARS['RECH']["groupe"];
}
if ($HTTP_SESSION_VARS['RECH']["region"] != ""){
$retour = $retour."®ion=".$HTTP_SESSION_VARS['RECH']["region"];
}
if ($HTTP_SESSION_VARS['RECH']["circons"] != ""){
$retour = $retour."&circons=".$HTTP_SESSION_VARS['RECH']["circons"];
}
if ($HTTP_SESSION_VARS['RECH']["ordre"] != ""){
$retour = $retour."&ordre=".$HTTP_SESSION_VARS['RECH']["ordre"];
}
if ($HTTP_SESSION_VARS["TOUT"] == "y"){
$retour = $retour."&tout=y";
}
session_unregister("RECH");
}
} else {
$retour = "gen_rech_prog.php";
if ($HTTP_SESSION_VARS["TOUT"] == "y"){
$retour = $retour."?tout=y";
}
}
# echo $retour;
if (!session_is_registered("RETOUR")){
session_register("RETOUR");
}
if ($periode == "vote" && $HTTP_SESSION_VARS["TOUT"] != "y"){
$HTTP_SESSION_VARS["RETOUR"] = "<a href='".$retour."'>Retour à la liste des finalistes</a>";
} else if ($periode == "fin_vote" && $HTTP_SESSION_VARS["TOUT"] != "y"){
$HTTP_SESSION_VARS["RETOUR"] = "<a href='".$retour."'>Retour à la liste des résultats</a>";
} else {
if($periode == "vote"){
if(isset($_GET['type'])){
if($_GET['type'] == "final"){
$HTTP_SESSION_VARS["RETOUR"] = "<a href='".$retour."&onglet=1'>Retour à la liste des finalistes</a>";
}
}
else{
$HTTP_SESSION_VARS["RETOUR"] = "<a href='".$retour."&onglet=2'>Retour à la page de recherche</a>";
}
}
else{
$HTTP_SESSION_VARS["RETOUR"] = "<a href='".$retour."&onglet=1'>Retour à la page de recherche</a>";
}
}
session_unregister("TOUT");
if(isset($_GET['type'])){
if($_GET['type'] == "final"){
$page = "gen_fiche.php?id_prop=".$HTTP_GET_VARS['id_prop']."&pos=".$HTTP_GET_VARS['pos']."&type=final";
}
}
else{
$page = "gen_fiche.php?id_prop=".$HTTP_GET_VARS['id_prop']."&pos=".$HTTP_GET_VARS['pos']."";
}
header("Location: $page");
if ($HTTP_GET_VARS['type_action'] == "voir_tout"){
if (!session_is_registered("TOUT")){
session_register("TOUT");
}
$HTTP_SESSION_VARS["TOUT"] = "y";
$HTTP_SESSION_VARS['RECH']["tous"] = "y";
# echo $HTTP_SESSION_VARS["TOUT"];
header("Location: gen_rech_prog.php");
}
if ($HTTP_GET_VARS['type_action'] == "voir_fin"){
session_unregister("TOUT");
# echo $HTTP_SESSION_VARS["TOUT"];
header("Location: gen_rech_prog.php");
}
}
}
?>