50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* Script testant les données envoyées lors d'une demande de suppression d'une source de flux
|
||
|
* 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_source.php");
|
||
|
}
|
||
|
$msg_form=array();
|
||
|
if((empty($_POST["id_source"]))||(((empty($_POST["suppr_ok"])))&&((empty($_POST["suppr_ok_tot"])))))
|
||
|
$msg_form[]=ERREUR_IMPREVUE;
|
||
|
else
|
||
|
{
|
||
|
if($_SESSION["statut"]!="administrateur")
|
||
|
$msg_form[]=ERREUR_IMPREVUE;
|
||
|
else
|
||
|
{
|
||
|
if(empty($Bd))
|
||
|
require("../modele/connexion-bd.php");
|
||
|
$source=new FclFlux_source();
|
||
|
$form["id_source"]=$_POST["id_source"];//utile pour réaffichage si pas en ajax
|
||
|
$source->id_source=intval(trim($_POST["id_source"]));
|
||
|
if(empty($_POST["suppr_ok_tot"]))
|
||
|
$action=$source->supprime();
|
||
|
else
|
||
|
$action=$source->supprime(false);
|
||
|
if(!empty($source->erreurs))
|
||
|
$msg_form=array_merge($source->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);
|
||
|
}
|