Location: PHPKode > projects > Pnyx : des lections virtuelles! > pnyx1.0.1/adm_resp2.php
<?php

	#########################################################################################
	# Gestion des responsables 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";

	if ($HTTP_POST_VARS['type_action'] == "eff_resp"){

		$requete_sql = "SELECT * FROM groupe
						WHERE resp_id = \"$HTTP_POST_VARS[id_resp]\"
  						";
		$reponse_grp = bd_executer_sql($requete_sql);
		
		while ($ligne_groupe = mysql_fetch_array($reponse_grp)){
		
			$requete_sql = "SELECT * FROM eleve
						WHERE groupe_id = \"$ligne_groupe[groupe_id]\"
  						";
			$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 = "DELETE FROM fiche
								WHERE eleve_id = \"$ligne_eleve[eleve_id]\"
  								";
				$reponse_sup_prop = 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_vote[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 eleve
							WHERE eleve_id = \"$ligne_eleve[eleve_id]\"
  							";
				$reponse_sup_eleve = bd_executer_sql($requete_sql);*/
			
			}
			$requete_sql = "DELETE FROM groupe
							WHERE groupe_id = \"$ligne_groupe[groupe_id]\"
  							";
			$reponse_sup_groupe = bd_executer_sql($requete_sql);
			
		}
		
		$requete_sql = "DELETE FROM lien_resp_projet
						WHERE resp_id = \"$HTTP_POST_VARS[id_resp]\"
  						";
		$reponse_sup_resp = bd_executer_sql($requete_sql);
		
		$requete_sql = "DELETE FROM msg_resp
						WHERE auteur =  \"$HTTP_POST_VARS[id_resp]\"
  						";
		$reponse_sup_log = bd_executer_sql($requete_sql);
		
		$requete_sql = "DELETE FROM msg_fil
						WHERE auteur =  \"$HTTP_POST_VARS[id_resp]\"
						AND type_auteur = \"resp\"
  						";
		$reponse_sup_log = bd_executer_sql($requete_sql);
		
		$requete_sql = "DELETE FROM fil_discussion
						WHERE last_auteur =  \"$HTTP_POST_VARS[id_resp]\"
						AND type_auteur = \"resp\"
  						";
		$reponse_sup_log = bd_executer_sql($requete_sql);
			
		$requete_sql = "DELETE FROM bloc_msg
						WHERE bloc_par = \"$HTTP_POST_VARS[id_resp]\"
						AND bloc_type = \"resp\"
  						";
		$reponse_sup_prop = bd_executer_sql($requete_sql);
		
		
		$requete_sql = "SELECT usager_id FROM responsable
						WHERE resp_id = \"$HTTP_POST_VARS[id_resp]\"
  						";
		$reponse_log = bd_executer_sql($requete_sql);
		$ligne_log = mysql_fetch_array($reponse_log);
		
		$requete_sql = "DELETE FROM usager
						WHERE usager_id = \"$ligne_log[usager_id]\"
  								";
		$reponse_sup_log = bd_executer_sql($requete_sql);
		
		
		$requete_sql = "DELETE FROM responsable
						WHERE resp_id = \"$HTTP_POST_VARS[id_resp]\"
  						";
		$reponse_sup_resp = bd_executer_sql($requete_sql);
		
		$HTTP_SESSION_VARS['SESSION']['message'] = "L'inscription du responsable a été supprimée.";
		
		header("Location: adm_enregistrement.php?id_projet=$projet");
	
	}
	
	if ($HTTP_POST_VARS['type_action'] == "valider"){
	
		$requete_sql = "SELECT groupe_id 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 valide = \"1\", 
						date_valide = \"$date\",
						nb_groupe = \"$nb_grp\"
    					WHERE resp_id = \"$HTTP_POST_VARS[id_resp]\"
						AND projet_id = $projet
  						";
		$reponse_val = bd_executer_sql($requete_sql);
		
		$requete_sql = "UPDATE responsable
						SET nouveau = \"0\"
    					WHERE resp_id = \"$HTTP_POST_VARS[id_resp]\"
  						";
		$reponse_val = bd_executer_sql($requete_sql);
		
		$requete_sql = "SELECT prenom, nom
						FROM responsable
						WHERE resp_id = \"$HTTP_POST_VARS[id_resp]\"
  						";
		$reponse_nom = bd_executer_sql($requete_sql);
		$ligne_nom = mysql_fetch_array($reponse_nom);
		
		$HTTP_SESSION_VARS['SESSION']['message'] = "L'inscription du responsable ". $ligne_nom['prenom'] . " " . $ligne_nom['nom'] . " est validée. Il peut maintenant publier les fiches de candidature de ses élèves en ligne.";
		
		$page = "adm_resp.php?id_resp=".$HTTP_POST_VARS['id_resp']."";
		header("Location: $page");
	}
	
	if ($HTTP_POST_VARS['type_action'] == "invalider"){
	
		$requete_sql = "SELECT groupe_id 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 valide = \"0\", 
						date_valide = \"0000-00-00\",
						nb_groupe = \"$nb_grp\"
    					WHERE resp_id = \"$HTTP_POST_VARS[id_resp]\"
						AND projet_id = $projet
  						";
		$reponse_val = bd_executer_sql($requete_sql);
		
		$requete_sql = "SELECT prenom, nom
						FROM responsable
						WHERE resp_id = \"$HTTP_POST_VARS[id_resp]\"
  						";
		$reponse_nom = bd_executer_sql($requete_sql);
		$ligne_nom = mysql_fetch_array($reponse_nom);
		
		$HTTP_SESSION_VARS['SESSION']['message'] = "L'inscription du responsable ". $ligne_nom['prenom'] . " " . $ligne_nom['nom'] . " est invalidée. Il ne peut plus publier en ligne les fiches de candidature de ses élèves.";
		
		$page = "adm_resp.php?id_resp=".$HTTP_POST_VARS['id_resp']."";
		header("Location: $page");
	}
	
	
	

?>
Return current item: Pnyx : des lections virtuelles!