<?php
#########################################################################################
# Gestion des groupes de Pnyx - scripts bdd #
# Auteur : V. Blais #
# Création : 2006-04-05 #
# Modification : 2008-07-01 #
# #
# 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";
# verifier si la session est valide
# puis verifier si l'usager dispose des autorisations requises
# pour la saisie
verifier_session();
acces_admin("adm_groupe.php");
$projet = $HTTP_SESSION_VARS['SESSION']['projet'];
#CHANGER DE GROUPE AFFICHÉ
if ($HTTP_POST_VARS['type_action'] == "chg_grp"){
$page = "adm_groupe.php?id_groupe=".$HTTP_POST_VARS['groupe'];
header("Location: $page");
}
#SUPPRIMER UN GROUPE
if ($HTTP_POST_VARS['type_action'] == "eff_groupe"){
$requete_sql = "SELECT eleve_id FROM eleve
WHERE groupe_id = \"$HTTP_POST_VARS[id_groupe]\"
";
$reponse_eleve = bd_executer_sql($requete_sql);
while ($ligne_eleve = mysql_fetch_array($reponse_eleve)){
$requete_sql = "SELECT * FROM fiche
WHERE eleve_id = \"$ligne_eleve[eleve_id]\"
";
$reponse_fiche = bd_executer_sql($requete_sql);
while ($ligne_fiche = mysql_fetch_array($reponse_fiche)){
/*$requete_sql = "DELETE FROM fiche
WHERE fiche_id = \"$ligne_fiche[fiche_id]\"
";
$reponse_sup_app = bd_executer_sql($requete_sql);*/
$requete_sql = "DELETE FROM election
WHERE fiche_id = \"$ligne_fiche[fiche_id]\"
AND projet_id = $projet
";
$reponse_sup_fiche = bd_executer_sql($requete_sql);
}
/*$requete_sql = "DELETE FROM fiche
WHERE eleve_id = \"$ligne_eleve[eleve_id]\"
";
$reponse_sup_fiche = bd_executer_sql($requete_sql);*/
$requete_sql = "SELECT * FROM eleve
WHERE eleve_id = \"$ligne_eleve[eleve_id]\"
AND projet_id = $projet
";
$reponse_vote = bd_executer_sql($requete_sql);
$ligne_vote = mysql_fetch_array($reponse_vote);
$requete_sql = "UPDATE election
SET nb_votes = nb_votes - 1
WHERE fiche_id = \"$ligne_vote[fiche_id]\"
AND projet_id = $projet
";
$reponse_elect = bd_executer_sql($requete_sql);
$requete_sql = "DELETE FROM eleve
WHERE eleve_id = \"$ligne_eleve[eleve_id]\"
";
$reponse_sup_prop = bd_executer_sql($requete_sql);
$requete_sql = "DELETE FROM bloc_msg
WHERE eleve_bloc = \"$ligne_eleve[eleve_id]\"
";
$reponse_sup_prop = bd_executer_sql($requete_sql);
$requete_sql = "DELETE FROM usager
WHERE usager_id = \"$ligne_eleve[usager_id]\"
";
$reponse_sup_log = bd_executer_sql($requete_sql);
}
$requete_sql = "DELETE FROM groupe
WHERE groupe_id = \"$HTTP_POST_VARS[id_groupe]\"
";
$reponse_sup_groupe = bd_executer_sql($requete_sql);
$requete_sql = "SELECT * FROM groupe
WHERE resp_id = \"$HTTP_POST_VARS[id_resp]\"
AND projet_id = $projet
";
$reponse_grp = bd_executer_sql($requete_sql);
$nb_grp = mysql_num_rows($reponse_grp);
$requete_sql = "UPDATE lien_resp_projet
SET nb_groupe = \"$nb_grp\"
WHERE resp_id = \"$HTTP_POST_VARS[id_resp]\"
AND projet_id = $projet
";
$reponse_mod_lien = bd_executer_sql($requete_sql);
$HTTP_SESSION_VARS['SESSION']['message'] = "Le groupe a été supprimé.";
$page = "adm_groupe.php";
header("Location: $page");
}
?>