49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* Script testant les données envoyées lors d'une demande de suppression d'un post
|
||
|
* Peut être appelé en ajax ou directement en php si JS désactivé
|
||
|
*
|
||
|
**/
|
||
|
$ajax_on=false;
|
||
|
if(!empty($_POST["ajax"]))
|
||
|
{
|
||
|
$ajax_on=true;
|
||
|
session_save_path(SESSIONS_REP);
|
||
|
ini_set("session.use_only_cookies",1);
|
||
|
session_start();
|
||
|
header('Content-Type: text/html; charset=utf-8');
|
||
|
require_once("../modele/FclFlux_post.php");
|
||
|
}
|
||
|
$msg_form=array();
|
||
|
if((empty($_POST["id_post"]))||(empty($_POST["suppr_ok"]))||(empty($_POST["hub_id"])))
|
||
|
$msg_form[]=ERREUR_IMPREVUE;
|
||
|
else
|
||
|
{
|
||
|
if($_SESSION["statut"]!="administrateur")
|
||
|
$msg_form[]=ERREUR_IMPREVUE;
|
||
|
else
|
||
|
{
|
||
|
if(empty($Bd))
|
||
|
require("../modele/connexion-bd.php");
|
||
|
$form["id_post"]=intval(trim($_POST["id_post"]));
|
||
|
$hub=new FclFlux_hub();
|
||
|
$hub->id_hub=intval(trim($_POST["hub_id"]));
|
||
|
$form["hub"]=$hub;
|
||
|
$post=new FclFlux_post($form);
|
||
|
$action=$post->supprime();
|
||
|
if(!empty($post->erreurs))
|
||
|
$msg_form=array_merge($post->erreurs,$msg_form);
|
||
|
elseif($action===false)
|
||
|
$msg_form[]=ERREUR_IMPREVUE;
|
||
|
if(empty($msg_form))
|
||
|
$msg_form[]=MSG_ADMIN_VALID;
|
||
|
$Bd=null;
|
||
|
}
|
||
|
}
|
||
|
if((!empty($msg_form))&&($ajax_on))
|
||
|
{
|
||
|
if($msg_form[0]==MSG_ADMIN_VALID)
|
||
|
echo str_replace("'","\"",get_html_alerte_msg($msg_form,"alert-success"));//pour comparaison en JS
|
||
|
else
|
||
|
echo get_html_alerte_msg($msg_form);
|
||
|
}
|