start(); /// TODO try to remove them if possible include_once (GLPI_ROOT . "/inc/db.function.php"); // Standard includes include_once (GLPI_ROOT . "/inc/config.php"); //disbled errors =>pour le variable res (Ajax) ini_set('display_errors', 0); Session::checkLoginUser(); global $DB; // print("
".print_r($_POST,true).""); //print("
".print_r($_FILES,true).""); if(isset($_POST)){ switch ($_POST['function']) { case "publication": if( $_POST["action"] == 'add'){ addPublication($_POST , $_FILES); Html::redirect($CFG_GLPI["root_doc"]."/front/publications.php"); }else if($_POST["action"] == 'update'){ updatePublication($_POST , $_FILES); Html::redirect($CFG_GLPI["root_doc"]."/front/publications.php"); }else if($_POST["action"] == 'delete'){ deletePublication($_POST); } break; case "jaime": if( $_POST["value"] != 'deleted'){ $isJaime = isJaime($_POST["id_publication"] , $_SESSION["glpiID"]); if($isJaime == false){ $stmt = $DB->prepare("INSERT INTO publication_reactions( id_publication , id_user , type , reaction) VALUES ( ? , ? , 'jaime' , ? )"); $stmt->bind_param("iis",$_POST["id_publication"], $_SESSION["glpiID"] , $_POST["value"]); $stmt->execute(); }else{ $stmt = $DB->prepare("UPDATE publication_reactions SET reaction = ? where id_publication = ? and id_user = ? and type ='jaime' "); $stmt->bind_param("sii", $_POST["value"] , $_POST["id_publication"] , $_SESSION["glpiID"]); $stmt->execute(); } }else if( $_POST["value"] == 'deleted'){ //$DB->query("DELETE FROM publication_reactions WHERE id_publication='".(int)$_POST["id_publication"]."' and id_user = '".$_SESSION["glpiID"]."' and type = 'jaime' "); } break; case "commentaire": if( $_POST["action"] == 'add'){ addCommentaire($_POST); }elseif( $_POST["action"] == 'update'){ //updateCommentaire($_POST); }elseif( $_POST["action"] == 'delete'){ //deleteCommentaire($_POST); } break; } }