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

	#########################################################################################
	# Modifier un élève de Pnyx																#
	# Auteur : V. Blais																		#
	# Création : 2006-05-02																	#
	# 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												#
	#########################################################################################

	include_once("fckeditor/fckeditor.php");
	
	require "entete_php.php";
	
	/*session_name("cliquez");
	session_start();
	bd_connexion();*/
	
		# ou verifier si la session est valide 
		# puis verifier si l'usager dispose des autorisations requises
		# pour la saisie
		verifier_session();
		acces_eleveC("mod_prop.php");
		
		/*$idp = $HTTP_SESSION_VARS[SESSION][projet];
		$ide = $HTTP_SESSION_VARS[SESSION][usager_id]; */
if(isset($HTTP_POST_VARS['type_action'])){
	if ($HTTP_POST_VARS['type_action'] == "modifier"){
		
	
			$titre = addslashes($HTTP_POST_VARS['titre']);
			$texte = addslashes($HTTP_POST_VARS['texte']);
			if($HTTP_POST_VARS['choixSource'] == "oui"){
				$source = addslashes($HTTP_POST_VARS['source']);
			}
			else{
				$source = "Aucune";
			}
					
			$requete_sql = "UPDATE fiche
							SET slogan = \"$titre\",
								niveau = \"$HTTP_POST_VARS[niveau]\",
								proposition = \"$texte\",
								categorie = \"$HTTP_POST_VARS[cat]\",
								source = \"$source\"
							WHERE fiche_id = \"$HTTP_GET_VARS[id_prop]\"
							";
			$reponse_mod_nouv = bd_executer_sql($requete_sql);
			
			$HTTP_SESSION_VARS['SESSION']['message'] = "Ta proposition est modifiée.";
	}
}
	
	$requete_sql = "SELECT *
					FROM fiche
					WHERE fiche_id = \"$HTTP_GET_VARS[id_prop]\"
					";
	$reponse_prop = bd_executer_sql($requete_sql);
	$ligne = mysql_fetch_array($reponse_prop);
	
	$requete_sql = "SELECT *
                    FROM projet
                    WHERE statut = \"actif\"
                        ";
    $reponse_actif = bd_executer_sql($requete_sql);
    $projet = mysql_fetch_array($reponse_actif);
	
	$requete_sql = "SELECT *
                    FROM categorie_prop
					WHERE actif = 1
                    ";
    $reponse_cat = bd_executer_sql($requete_sql);
	
	$requete_sql = "SELECT titre
                    FROM site_parametres
                    ";
    $reponse_titre = bd_executer_sql($requete_sql);
    $ligne_titre = mysql_fetch_array($reponse_titre);
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title><?= $ligne_titre['titre'] ?></title>

<script type="text/javascript" src="lib/fonctions.js"></script>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-1684383-1";
urchinTracker();
</script>
</head>

<body bgcolor="#FFFFFF">
<?
if(isset($HTTP_POST_VARS['type_action'])){	
	if ($HTTP_POST_VARS['type_action'] == "modifier"){
?>
		<script language="JavaScript">
			refresh_parent();
		</script>
<?
	}
}
?>	
<form name="form_mod_prop" method="post" action="mod_prop.php?id_prop=<?=$HTTP_GET_VARS['id_prop']?>">

<table width="664" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td colspan="2"><h2>Modification d'une proposition</h2></td>
</tr>
<tr>
			<td><p><strong>Slogan:</strong></p></td>
			<td><input type="text" size="50" maxlength="255" name="titre" value="<?= $ligne['slogan']?>"/></td>
</tr>
<tr>
			<td ><p><strong>Niveau </strong></p></td>
			<td><select name="niveau" size="1">
<?
				if($projet['international'] == 1){
					if ($ligne['niveau'] == "international"){
						echo "<option value=\"international\" selected=\"selected\">International</option>";
					} else {
						echo "<option value=\"international\">International</option>";
					}
				}
				
				if($projet['national'] == 1){
					if ($ligne['niveau'] == "national"){
						echo "<option value=\"national\" selected=\"selected\">National</option>";
					} else {
						echo "<option value=\"national\">National</option>";
					}
				}
				
				if($projet['local'] == 1){
					if ($ligne['niveau'] == "local"){
						echo "<option value=\"local\" selected=\"selected\">Local</option>";
					} else {
						echo "<option value=\"local\">Local</option>";
					}
				}
?>
			</select>
			</td>
</tr>
<tr>
<td valign="top"><p><strong>Catégorie :</strong></p></td>
<td><select name="cat" size="1">
<?
		while($ligne_cat = mysql_fetch_array($reponse_cat)){
			if ($ligne['categorie'] == $ligne_cat['cat_id']){
				echo "<option value='" . $ligne_cat['cat_id'] . "' selected=\"selected\">" . $ligne_cat['nom'] . "</option>";
			} else {
				echo "<option value='" . $ligne_cat['cat_id'] . "'>" . $ligne_cat['nom'] . "</option>";
			}
		}
			
?>
				</select>
			</td></tr>
<tr>
			<td valign="top"><p><strong> Explication :</strong></p></td>
		<td>
<?
	if(file_exists('fckeditor/')){
		$oFCKeditor = new FCKeditor('texte') ;
		$oFCKeditor->BasePath = 'fckeditor/' ;
		$oFCKeditor->Value = $ligne['proposition'];
		$oFCKeditor->Create() ;
	}
	else{
?>
<textarea name="texte" cols="50" rows="10"><?= $ligne['proposition'] ?></textarea>
<?
	}
?>
<br />
</td>
</tr>
<tr>
			<td valign="top"><p><strong> Source :</strong></p></td>
		<td>
<?
			$sourceOUI = "";
			$sourceNON = "";
			if($ligne['source'] == "Aucune"){
				$sourceNON = " checked='checked'";
			}
			else{
				$sourceOUI = " checked='checked'";
			}
?>
            Oui <input type="radio" name="choixSource" value="oui" onclick="enableSource('oui')"<?= $sourceOUI ?> /> / Non <input type="radio" name="choixSource" value="non" onclick="enableSource('non')"<?= $sourceNON ?> />
            <br />
<?
			$disabledS = "";
			if($ligne['source'] == "Aucune"){
				$disabledS = "disabled='disabled'";
			}
?>			           
            <textarea <?= $disabledS ?> cols="60" rows="5" name="source" id="source" onkeyup="verificationSource()"><?= $ligne['source'] ?></textarea>
   		</td>
</tr>
<tr>
			<td colspan="2">&nbsp;</td>
</tr>
<tr>
			<td colspan="2" align="center">
<?
			$disabledMod = "";
			if($ligne['source'] != "Aucune"){
				$disabledMod = " disabled='disabled'";
			}
?>			
            <input type="submit" name="mod" id="mod" value="Modifier"<?= $disabledMod ?> />
			<input type="hidden" name="type_action" value="modifier"/>
			<input type="hidden" name="id_prop" value="<?= $ligne['prop_id']?>"/>
		  </td>
</tr>
<tr>
<td colspan="2"><p>&nbsp;</p></td>
</tr>
</table>
</form>
<script type="text/javascript" language="javascript">
	function enableSource(quel){
		if(quel == "oui"){
			document.getElementById('source').disabled = false;
			document.getElementById('source').value = "";
			document.getElementById('mod').disabled = true;
		}
		else{
			document.getElementById('source').disabled = true;
			document.getElementById('source').value = "Aucune";
			document.getElementById('mod').disabled = false;
		}
	}
					
	function verificationSource(){
    	if(document.getElementById('source').value != ""){
        	document.getElementById('mod').disabled = false;
        }
        else{
        	document.getElementById('mod').disabled = true;
        }
	}
	verificationSource();
</script>
<?
	mysql_close();
?>
</body>
</html>
Return current item: Pnyx : des lections virtuelles!