id_utilisateur=$_SESSION["id_utilisateur"]; $form["proprietaire"]=$user; $abo_suppr=new FclFlux_abonnement($form); if(empty($abo_suppr->erreurs)) { $suppr=$abo_suppr->supprime(); if(!empty($abo_suppr->erreurs)) $msg_form=array_merge($abo_suppr->erreurs,$msg_form); elseif($suppr===false) $msg_form[]=ERREUR_IMPREVUE; else { $_SESSION["message"]=MSG_UTILISA_MAJ_SUPPR_VALID; if($ajax_on) $msg_form[]=MSG_UTILISA_MAJ_SUPPR_VALID; else { header("location:".PAGE_ABO_LISTE); exit(); } } } } elseif((empty($_POST["designation"]))||(empty($form["max_liens"]))) $msg_form[]=ERREUR_UTILISA_CHAMPS_ABSENTS; else { if(empty($Bd)) require("../modele/connexion-bd.php"); $user=new FclFlux_utilisateur(); $user->id_utilisateur=$_SESSION["id_utilisateur"]; $form["proprietaire"]=$user; $abo_maj=new FclFlux_abonnement($form); if(!empty($abo_maj->erreurs)) $msg_form=array_merge($abo_maj->erreurs,$msg_form); //suppression des hubs / abonnement if((empty($msg_form))&&(!empty($_POST["hubs_suppr"]))) { $liste_hubs=array();$i=0; foreach($_POST["hubs_suppr"] as $hub_id) { $hub_suppr=new FclFlux_hub(); $hub_suppr->id_hub=$hub_id; $liste_hubs[$i]=$hub_suppr; unset($hub_suppr); $i++; } if($i>0) { $action=$abo_maj->supprime_hubs($liste_hubs); if(!empty($abo_maj->erreurs)) $msg_form=array_merge($abo_maj->erreurs,$msg_form); elseif($action===false) $msg_form[]=ERREUR_IMPREVUE; } } //ajout hub / abonnement if((empty($msg_form))&&(empty($abo_maj->erreurs))&&(!empty($_POST["hubs_ajout"]))) { $liste_hubs=array();$i=0; foreach($_POST["hubs_ajout"] as $hub_id) { $hub_ajout=new FclFlux_hub(); $hub_ajout->id_hub=$hub_id; $liste_hubs[$i]=$hub_ajout; unset($hub_ajout); $i++; } if($i>0) { $action=$abo_maj->ajout_hubs($liste_hubs); if(!empty($abo_maj->erreurs)) $msg_form=array_merge($abo_maj->erreurs,$msg_form); elseif($action===false) $msg_form[]=ERREUR_IMPREVUE; } } //changement de ville ? if((empty($msg_form))&&(empty($abo_maj->erreurs))&&(!empty($_POST["insee"]))&&($_POST["a_insee"]!=$_POST["insee"])) { $abo_maj->set_ville_insee($_POST["insee"]); $chgt_ville=$abo_maj->abo_rapide_nouvelle_ville($_POST["insee"],$user); if(!empty($abo_maj->erreurs)) $msg_form=array_merge($abo_maj->erreurs,$msg_form); elseif($chgt_ville===false) $msg_form[]=ERREUR_IMPREVUE; } // les autres infos. if((empty($msg_form))&&(empty($abo_maj->erreurs))) { $maj=$abo_maj->actualise(); if(!empty($abo_maj->erreurs)) $msg_form=array_merge($abo_maj->erreurs,$msg_form); elseif($maj===false) $msg_form[]=ERREUR_IMPREVUE; } if(empty($msg_form)) $msg_form[]=MSG_UTILISA_MAJ_INFOS_VALID; $Bd=null; } if((!empty($msg_form))&&($ajax_on)) { if(($msg_form[0]==MSG_UTILISA_MAJ_INFOS_VALID)&&(!empty($abo_maj->id_abonnement))) echo $abo_maj->id_abonnement;//tout s'est bien passé, je recharge l'abonnement en ajax elseif($msg_form[0]==MSG_UTILISA_MAJ_SUPPR_VALID) echo str_replace("\"","'",MSG_UTILISA_MAJ_SUPPR_VALID);//pour comparaison en JS else echo get_html_alerte_msg($msg_form); }