75 lines
1.9 KiB
PHP
75 lines
1.9 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* Script testant les données envoyées lors des demandes d'ajout/suppression d'un flux à importer dans un hub.
|
||
|
* Peut être appelé en ajax ou directement en php si JS désactivé
|
||
|
*
|
||
|
**/
|
||
|
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_hub.php");
|
||
|
}
|
||
|
if(!empty($_POST["id_hub"]))
|
||
|
$id_hub=intval(trim($_POST["id_hub"]));
|
||
|
if(!empty($_POST["liste_flux"]))
|
||
|
$nouveau_flux=intval(trim($_POST["liste_flux"]));
|
||
|
$suppr_rubriques=array();
|
||
|
if(!empty($_POST["suppr_flux"]))
|
||
|
{
|
||
|
foreach($_POST['suppr_flux'] as $id)
|
||
|
$suppr_flux[]=intval($id);
|
||
|
}
|
||
|
$msg_form_classement=array();
|
||
|
if(((empty($nouveau_flux))&&(empty($suppr_flux)))||(empty($id_hub)))
|
||
|
$msg_form_classement[]=ERREUR_UTILISA_CHAMPS_ABSENTS;
|
||
|
else
|
||
|
{
|
||
|
if($_SESSION["statut"]!="administrateur")
|
||
|
$msg_form_classement[]=ERREUR_IMPREVUE;
|
||
|
else
|
||
|
{
|
||
|
require_once("../modele/connexion-bd.php");
|
||
|
$hub=new FclFlux_hub();
|
||
|
$hub->id_hub=$id_hub;
|
||
|
if(!empty($nouveau_flux))
|
||
|
{
|
||
|
$flux=new FclFlux_flux();
|
||
|
$flux->id_flux=$nouveau_flux;
|
||
|
$action=$flux->ajout_hub($hub);
|
||
|
if(!empty($flux->erreurs))
|
||
|
$msg_form=$flux->erreurs;
|
||
|
elseif($action===false)
|
||
|
$msg_form[]=ERREUR_IMPREVUE;
|
||
|
}
|
||
|
if(!empty($suppr_flux))
|
||
|
{
|
||
|
foreach($suppr_flux as $flux_id)
|
||
|
{
|
||
|
$flux=new FclFlux_flux();
|
||
|
$flux->id_flux=$flux_id;
|
||
|
$action=$flux->suppr_hub($hub);
|
||
|
if(!empty($flux->erreurs))
|
||
|
$msg_form=$flux->erreurs;
|
||
|
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)&&(!empty($hub->id_hub)))
|
||
|
echo $hub->id_hub;//tout s'est bien passé, j'actualise l'affichage
|
||
|
else
|
||
|
{
|
||
|
foreach($msg_form as $message)
|
||
|
echo "<h4>$message</h4>";
|
||
|
}
|
||
|
}
|