%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/alliance/domains/congress-intercultural.eu/public_html/
Upload File :
Create Path :
Current File : /home/alliance/domains/congress-intercultural.eu/public_html/a-modifier_actu.php

<?php
include_once("inc/config.php");
include_once("inc/functions.php");
include_once("inc/init.php");
include_once("inc/session.php");

$db = new BaseOps;
verif_get($_GET['id']);

$query = "SELECT * FROM `actu` WHERE id = ".$_GET['id'];
if(!$db->isres($query))
{
	include('a-404.php');
	exit(0);
}

$actu_sec = $section->actu_sec($_GET['id']);
verif_co_sec($actu_sec);


$actu = new Actu();

if(isset($_POST['post']) && $_POST['post'] == 1)
{
	verif_co_sec($_POST['section']);
	$erreur = $db->verif($_POST['titre_fr'], "Le titre français");
	if($erreur == "ok") $erreur = $db->verif($_POST['titre_en'], "Le titre anglais");
	if($_POST['type'] == 1 || $_POST['type'] == 2)
	{
		if($erreur == "ok") $erreur = $db->verif($_POST['texte_fr'], "Le texte français");
		if($erreur == "ok") $erreur = $db->verif($_POST['texte_en'], "Le texte anglais");
	}
	if($_POST['type'] == 1 || $_POST['type'] == 3)
	{
		if($erreur == "ok") $erreur = $db->verif($_POST['date_debut'], "La date de l'événement");
	}
	if($erreur == "ok")
	{
	
		$actua = $db->select_array($query);
		//Photos
		
		if($_POST['photo1'] != null) { if($_POST['photo1'] != $actua['photo1']) {
				$actu->suppr_photo($actua['id'], 1);
				$_POST['photo1'] = photo_move($_POST['photo1']); } }
		if($_POST['photo2'] != null) { if($_POST['photo2'] != $actua['photo2']) {
				$actu->suppr_photo($actua['id'], 2);
				$_POST['photo2'] = photo_move($_POST['photo2']); } }
		if($_POST['photo3'] != null) { if($_POST['photo3'] != $actua['photo3']) {
				$actu->suppr_photo($actua['id'], 3);
				$_POST['photo3'] = photo_move($_POST['photo3']); } }
		if($_POST['photo4'] != null) { if($_POST['photo4'] != $actua['photo4']) {
				$actu->suppr_photo($actua['id'], 4);
				$_POST['photo4'] = photo_move($_POST['photo4']); } }
		if($_POST['docactu'] != null) { if($_POST['docactu'] != $actua['docactu']) {
				$actu->suppr_photo($actua['id'], 5);
				$_POST['docactu'] = photo_move($_POST['docactu']); } }
		
		// if($_POST['photo1'] != $actua['photo1']) $_POST['photo1'] = photo_move($_POST['photo1']);
		// if($_POST['photo2'] != $actua['photo2']) $_POST['photo2'] = photo_move($_POST['photo2']);
		// if($_POST['photo3'] != $actua['photo3']) $_POST['photo3'] = photo_move($_POST['photo3']);
		// if($_POST['photo4'] != $actua['photo4']) $_POST['photo4'] = photo_move($_POST['photo4']);
		
		if($_POST['photo1'] == null) { $_POST['photo1'] = $actua['photo1']; }
		if($_POST['photo2'] == null) { $_POST['photo2'] = $actua['photo2']; }
		if($_POST['photo3'] == null) { $_POST['photo3'] = $actua['photo3']; }
		if($_POST['photo4'] == null) { $_POST['photo4'] = $actua['photo4']; }
		if($_POST['docactu'] == null) { $_POST['docactu'] = $actua['docactu']; }
		
		if($_POST['supp1']) {
			photo_supp($actua['photo1']);
			$_POST['photo1'] = null; }
		if($_POST['supp2']) {
			photo_supp($actua['photo2']);
			$_POST['photo2'] = null; }
		if($_POST['supp3']) {
			photo_supp($actua['photo3']);
			$_POST['photo3'] = null; }
		if($_POST['supp4']) {
			photo_supp($actua['photo4']);
			$_POST['photo4'] = null; }
		if($_POST['supp5']) {
			photo_supp($actua['docactu']);
			$_POST['docactu'] = null; }
	
		$where = "id = ".$_GET['id'];
		$where2 = "actu = ".$_GET['id'];
		// actu
		$next_id = $db->next_id("actu");
		$values = array(
			"section" => $_POST['section'],
			"type" => $_POST['type'],
			"date_debut" => dateUs($_POST['date_debut']),
			"date_fin" => dateUs($_POST['date_fin']),
			"photo1" => $_POST['photo1'],
			"photo2" => $_POST['photo2'],
			"photo3" => $_POST['photo3'],
			"photo4" => $_POST['photo4'],
			"docactu" => $_POST['docactu'],
			"hotpage" => $_POST['hotpage'] );
		$db->update("actu", $values, $where);
		
		//actu_fr
		$values = array (
			"titre" => $_POST['titre_fr'],
			"texte" => $_POST['texte_fr'],
			"permalien" => cleanUrl($_POST['titre_fr']) );
		$db->update("actu_lang", $values, $where2." AND lang = 1");
			
		//actu_en
		$values = array (
			"titre" => $_POST['titre_en'],
			"texte" => $_POST['texte_en'],
			"permalien" => cleanUrl($_POST['titre_en']) );
		$db->update("actu_lang", $values, $where2." AND lang = 2");
		
		$yes = true;
	}
	else {
		$err = true;
	}
}


$data = $db->select_array($query);
$query = "SELECT * FROM `actu_lang` WHERE lang = 1 AND actu = ".$data['id'];
$data_fr = $db->select_array($query);
$query = "SELECT * FROM `actu_lang` WHERE lang = 2 AND actu = ".$data['id'];
$data_en = $db->select_array($query);

if(!isset($_POST['titre_fr'])) $_POST['titre_fr'] = $data_fr['titre'];
if(!isset($_POST['titre_en'])) $_POST['titre_en'] = $data_en['titre'];
if(!isset($_POST['texte_fr'])) $_POST['texte_fr'] = $data_fr['texte'];
if(!isset($_POST['texte_en'])) $_POST['texte_en'] = $data_en['texte'];
if(!isset($_POST['section'])) $_POST['section'] = $data['section'];
if(!isset($_POST['type'])) $_POST['type'] = $data['type'];
if(!isset($_POST['date_debut'])) $_POST['date_debut'] = $data['date_debut'];
if($_POST['date_debut'] == "0000-00-00") $_POST['date_debut'] = null;
if(!isset($_POST['date_fin'])) $_POST['date_fin'] = $data['date_fin'];
if($_POST['date_fin'] == "0000-00-00") $_POST['date_fin'] = null;
if(!isset($_POST['hotpage'])) $_POST['hotpage'] = $data['hotpage'];
if(!isset($_POST['photo1'])) $_POST['photo1'] = $data['photo1'];
if(!isset($_POST['photo2'])) $_POST['photo2'] = $data['photo2'];
if(!isset($_POST['photo3'])) $_POST['photo3'] = $data['photo3'];
if(!isset($_POST['photo4'])) $_POST['photo4'] = $data['photo4'];
if(!isset($_POST['docactu'])) $_POST['docactu'] = $data['docactu'];

//affichage du html
include("theme/html.php");
//affichage des metas
include("theme/meta.php");
echo "\n<title>Modifier une actualité - ".$info_titresite."</title>\n";
//affichage du header
if(estadmin()) include("theme/header_admin.php");
else include("theme/header_redacteur.php");
?>

<div class="text_admin">
<h2>Modifier une actualité</h2>
<p>Pour mettre l'actualité comme événement dans le calendrier, regardez-bien le type de l'actualité</p>

<ul class="sousmenuadmin">
	<li><a href="admin/liste_actus.php?sec=<?php echo $_POST['section']; ?>">Retour à la liste des actualités</a></li>
	<li><a href="fr/news/<?php echo $data['id']; ?>-<?php echo $data_fr['permalien']; ?>.html">Voir l'actualité sur le site</a></li>
</ul>

<?php
if($err) {
	echo "<p class=\"erreurbloc\">".$erreur."</p>";
}
if($yes) {
	echo "<p class=\"infobloc\">Opération effectuée</p>";
}
?>
<form action="admin/modifier_actu.php?id=<?php echo $_GET['id']; ?>" enctype="multipart/form-data" method="post" class="form">
	<table>
		<tr>
			<td class="label"></td>
			<td class="field head">Français</td>
			<td class="field head">Anglais</td>
		</tr>
<?php
if (!estadmin()) {
?>
	<input type="hidden" name="section" value="<?php echo $_POST['section']; ?>" />
<?php
} else {
?>
		<tr>
			<td class="label">Section <span class="etoile">*</span></td>
			<td class="field">
				<select name="section">
<?php

$result = $section->liste_sections_all();
if($result != null)
{
	foreach($result as $sec)
	{
		if($sec['id'] == $_POST['section'])
			echo "<option value=\"".$sec['id']."\" selected=\"selected\">".$sec['titre']."</option>\n";
		else if($sec['id'] == $_POST['section'])
			echo "<option value=\"".$sec['id']."\" selected=\"selected\">".$sec['titre']."</option>\n";
		else
			echo "<option value=\"".$sec['id']."\">".$sec['titre']."</option>\n";
	}
}

?>
				</select>
			</td>
			<td class="field"></td>
		</tr>
<?php } ?>
		<tr>
			<td class="label top">Type <span class="etoile">*</span></td>
			<td class="field evenement">
				<p><input type="radio" class="radio" id="type1" <?php if($_POST['type'] == 1 || !isset($_POST['type'])) echo 'checked="checked"'; ?> name="type" value="1"> <label for="type1">actualité + ajout au calendrier</label></p>
				<p><input type="radio" class="radio" id="type2" <?php if($_POST['type'] == 2) echo 'checked="checked"'; ?> name="type" value="2"> <label for="type2">actualité sans ajout au calendrier</label></p>
				<p><input type="radio" class="radio" id="type3" <?php if($_POST['type'] == 3) echo 'checked="checked"'; ?> name="type" value="3"> <label for="type3">uniquement ajout au calendrier</label></p>
				</td>
			<td class="field"></td>
		</tr>
		<tr class="even">
			<td class="label">Date de l'événement <span class="etoile">*</span></td>
			<td class="field"><input type="text" class="datepick" name="date_debut" value="<?php echo dateFr($_POST['date_debut']); ?>" /></td>
			<td class="field"></td>
		</tr>
		<tr class="even">
			<td class="label">Date de fin</td>
			<td class="field"><input type="text" class="datepick" name="date_fin" value="<?php echo dateFr($_POST['date_fin']); ?>" /></td>
			<td class="field"></td>
		</tr>
		<tr>
			<td class="label">Titre de l'actualité <span class="etoile">*</span></td>
			<td class="field"><input type="text" name="titre_fr" value="<?php echo $_POST['titre_fr']; ?>" /></td>
			<td class="field"><input type="text" name="titre_en" value="<?php echo $_POST['titre_en']; ?>" /></td>
		</tr>
		<tr class="news">
			<td class="label"></td>
			<td class="field" colspan="2">
				<div id="toolbar"></div>
			</td>
		</tr>
		<tr class="news">
			<td class="label top">Texte de l'actualité <span class="etoile">*</span></td>
			<td class="field top"><textarea name="texte_fr"><?php echo $_POST['texte_fr']; ?></textarea></td>
			<td class="field top"><textarea name="texte_en"><?php echo $_POST['texte_en']; ?></textarea></td>
		</tr>
		<tr class="news">
			<td class="label top">Photo principale</td>
			<td class="field"><input type="file" name="file_1" id="file_1" /><?php if($_POST['photo1']) echo '<div class="uploadifyQueueItem completed"><div class="cancel"><input type="checkbox" class="radio supphoto" name="supp1" id="supp1"> <label for="supp1">Supprimer</label></div><a href="uploads/'.$_POST['photo1'].'" class="zoom">'.$_POST['photo1'].'</a></div> '; ?></td>
			<td class="field"><input type="hidden" name="photo1" id="photo1" value="<?php echo $_POST['photo1']; ?>" /></td>
		</tr>
		<tr class="news">
			<td class="label top">Photo n°2</td>
			<td class="field"><input type="file" name="file_2" id="file_2" /><?php if($_POST['photo2']) echo '<div class="uploadifyQueueItem completed"><div class="cancel"><input type="checkbox" class="radio supphoto" name="supp2" id="supp2"> <label for="supp2">Supprimer</label></div><a href="uploads/'.$_POST['photo2'].'" class="zoom">'.$_POST['photo2'].'</a></div> '; ?></td>
			<td class="field"><input type="hidden" name="photo2" id="photo2" value="<?php echo $_POST['photo2']; ?>" /></td>
		</tr>
		<tr class="news">
			<td class="label top">Photo n°3</td>
			<td class="field"><input type="file" name="file_3" id="file_3" /><?php if($_POST['photo3']) echo '<div class="uploadifyQueueItem completed"><div class="cancel"><input type="checkbox" class="radio supphoto" name="supp3" id="supp3"> <label for="supp3">Supprimer</label></div><a href="uploads/'.$_POST['photo3'].'" class="zoom">'.$_POST['photo3'].'</a></div> '; ?></td>
			<td class="field"><input type="hidden" name="photo3" id="photo3" value="<?php echo $_POST['photo3']; ?>" /></td>
		</tr>
		<tr class="news">
			<td class="label top">Photo n°4</td>
			<td class="field"><input type="file" name="file_4" id="file_4" /><?php if($_POST['photo4']) echo '<div class="uploadifyQueueItem completed"><div class="cancel"><input type="checkbox" class="radio supphoto" name="supp4" id="supp4"> <label for="supp4">Supprimer</label></div><a href="uploads/'.$_POST['photo4'].'" class="zoom">'.$_POST['photo4'].'</a></div> '; ?></td>
			<td class="field"><input type="hidden" name="photo4" id="photo4" value="<?php echo $_POST['photo4']; ?>" /></td>
		</tr>
		<tr class="news">
			<td class="label top">Document</td>
			<td class="field"><input type="file" name="file_docactu" id="file_docactu" /><?php if($_POST['docactu']) echo '<div class="uploadifyQueueItem completed"><div class="cancel"><input type="checkbox" class="radio supphoto" name="supp5" id="supp5"> <label for="supp5">Supprimer</label></div><a href="uploads/'.$_POST['docactu'].'">'.$_POST['docactu'].'</a></div> '; ?></td>
			<td class="field"><input type="hidden" name="docactu" id="docactu" value="<?php echo $_POST['docactu']; ?>" /></td>
		</tr>
		<tr class="news">
			<td class="label">Page d'accueil <span class="etoile">*</span></td>
			<td class="field">
				<p><input type="radio" class="radio" id="hotpage1" <?php if($_POST['hotpage'] == 1 || $_POST['hotpage'] == 2 || !isset($_POST['hotpage'])) echo 'checked="checked"'; ?> name="hotpage" value="1"> <label for="hotpage1">Je souhaite que cette information soit publiée, si possible, à la UNE du portail Amicale</label></p>
				<p><input type="radio" class="radio" id="hotpage0" <?php if($_POST['hotpage'] == 0) echo 'checked="checked"'; ?> name="hotpage" value="0"> <label for="hotpage0">Cette information n'a pas besoin d'être publiée à la UNE du portail Amicale</label></p>
<?php
if($_POST['hotpage'] == 2) {
	echo "<p class=\"infobloc\"><strong>Attention</strong>, cette offre est sur la page d'accueil, si vous la modifiez, elle devra être re-validée par un administrateur.</p>";
}
?>
			</td>
			<td class="field"></td>
		</tr>
	</table>
	<div class="form_bouton">
		<input type="hidden" name="post" value="1" />
		<input type="submit" class="bouton" id="maj_bouton" value="Mofifier une actualité" />
		<a href="admin/suppr_actu.php?id=<?php echo $_GET['id']; ?>" class="bouton confirm" />Supprimer l'actualité</a>
	</div>
</form>
</div>

<?

//affichage du footer
include("theme/footer.php");

?>

Zerion Mini Shell 1.0