60 lines
1.5 KiB
PHP
60 lines
1.5 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* Script testant les données envoyées lors d'une demande de changement du hub où est diffusé 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_hub"]))||(empty($_POST["liste_hubs"])))
|
||
|
$msg_form[]=ERREUR_UTILISA_CHAMPS_ABSENTS;
|
||
|
else
|
||
|
{
|
||
|
if($_SESSION["statut"]!="administrateur")
|
||
|
$msg_form[]=ERREUR_IMPREVUE;
|
||
|
else
|
||
|
{
|
||
|
$id_post=intval($_POST["id_post_hub"]);
|
||
|
$id_hub=intval($_POST["liste_hubs"]);
|
||
|
if(empty($Bd))
|
||
|
require("../modele/connexion-bd.php");
|
||
|
$form["id_post"]=$id_post;
|
||
|
$hub=new FclFlux_hub();
|
||
|
$hub->id_hub=$id_hub;
|
||
|
$form["hub"]=$hub;
|
||
|
unset($hub);
|
||
|
$post=new FclFlux_post($form);
|
||
|
if(!empty($post->erreurs))
|
||
|
$msg_form=array_merge($post->erreurs,$msg_form);
|
||
|
if(empty($msg_form))
|
||
|
{
|
||
|
$action=$post->change_hub();
|
||
|
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)&&(!empty($post->id_post)))
|
||
|
echo $post->id_post;//tout s'est bien passé, je recharge le post en ajax
|
||
|
else
|
||
|
{
|
||
|
foreach($msg_form as $message)
|
||
|
echo "<h4>$message</h4>";
|
||
|
}
|
||
|
}
|