id_hub=$page[2]; $hub_infos=$hub->get_infos_cache(false); if(empty($hub_infos)) { header("location:".PAGE_404); exit(); } //utilisateur connecté ? $user=new FclFlux_utilisateur(); if(!$user->test_session(false)) { unset($user); $redirige=PAGE_ABO_CREA_HUB.intval($page[2]); FclFlux_utilisateur::crea_cookie_redirection($redirige,2); $_SESSION["hub_abo"]=$hub_infos["nom"]; if(!empty($_POST["email_abo"])) { $_SESSION["email_abo"]=trim(strip_tags($_POST["email_abo"])); //je cherche si un abonné existe déjà pour cette adresse if(empty($Bd)) require("../modele/connexion-bd.php"); $cherche_email=FclFlux_utilisateur::recherche($_POST["email_abo"],"email","id_utilisateur"); if(!empty($cherche_email)) { unset($Bd); header("Location:".PAGE_CONNEXION); exit(); } unset($Bd); } header("Location:".PAGE_INSCRIPTION); exit(); } //les rubriques "mères" pour le fil d'ariane $meres=$hub->get_liste_rubriques_cache(CREA_CACHE); // liste des abonnements existants à proposer $liste_abo=""; $abos=FclFlux_abonnement::get_liste_abo_cache($user,CREA_CACHE); if(!empty($abos)) { foreach ($abos as $abo_info) $liste_abo.=" ".affiche_utf8(htmlentities($abo_info["designation"],ENT_QUOTES),UTF8_OK)." "; } //l'utilisateur à valider le formulaire if(isset($_POST["nouvel_abo"]))//pour ne pas confondre avec l'arrivée du site tiers { if(empty($Bd)) require("../modele/connexion-bd.php"); if(!empty($_POST["abo"])) { //ajout d'un hub à un abonnement existant $abo=new FclFlux_abonnement(); $abo->id_abonnement=intval($_POST["abo"]); $action=$abo->ajout_hubs(array($hub)); $Bd=null; } else { //je vais créé un nouvel abonnement et lui associer ce hub if(!empty($_POST["nouvel_abo"])) $infos["designation"]=$_POST["nouvel_abo"]; else $infos["designation"]="Nouvel abonnement."; $infos["proprietaire"]=$user; $abo=new FclFlux_abonnement($infos); $action=$abo->ajout(); if($action!==false) $action=$abo->ajout_hubs(array($hub)); } $Bd=null; if((!$action)||(!empty($abo->erreurs))) { $_SESSION["message"]=ERREUR_IMPREVUE; header("location:".PAGE_ACCUEIL); exit(); } else { $_SESSION["message"]="Votre nouvel abonnement a bien été créé !"; header("location:".PAGE_ABO_AFFICHE.$abo->id_abonnement); exit(); } } include("../vues/compte_crea_abo_hub.php");