//echo "erreur file type"; } if (isset($_POST['id_groupe']) && isset($_POST['users_concernes']) && isset($_POST['potin'])) { $groupe = $_POST['id_groupe']; $concernes = json_decode($_POST['users_concernes']); $potin = $_POST['potin']; $potin = make_clickable($potin); // On écrit le potin dans la table "potins" $req = $bdd->prepare('INSERT INTO potins(potin, id_auteur, id_groupe, date_potin, image) VALUES(?, ?, ?, NOW(), ?)'); $req->execute(array($potin, $id_user, $groupe, $LienImageNews)); $id_nouveau_potin = $bdd->lastInsertId(); // On récupère l'id du potin inséré // On associe le potin à chaque user concerne foreach ($concernes as $key => $concerne_courant) { $req = $bdd->prepare('INSERT INTO cor_potin_users(id_concerne, id_potin, decouvert) VALUES(?, ?, 0)'); $req->execute(array($concerne_courant, $id_nouveau_potin)); // Notifications include_once 'modele/notifications.php'; nouvelle_notif($concerne_courant, 'nouv_potin', $id_nouveau_potin, $groupe, $bdd); } // Renvoi de l'affichage du nouveau potin include_once 'modele/rechercher_potins.php'; $potin_courant = infos_potin($id_nouveau_potin, $bdd); //include_once('vue/potin/affichage_potin.php'); include_once 'vue/potin/potin_v4.php'; //$retour['potin'] = vue_affichage_potin($potin_courant, $id_user, $bdd); $retour['potin'] = vue_potin_v4($potin_courant, $id_user, $bdd); $retour['id_potin'] = $id_nouveau_potin; echo $retour['potin']; //echo json_encode($retour); }
<?php include 'vue/rediger_potin/nouveau_potin.php'; ?> <div id="emplacement-nouveau-potin"></div> <?php include_once 'modele/rechercher_potins.php'; //include_once('vue/potin/affichage_potin.php'); include_once 'vue/potin/potin_v4.php'; $potins_cherches = rechercher_potins_d_un_groupe_de_user($id_user, $groupe['id_groupe'], $bdd); // Les 10 premiers potins $potins_cherches = array_slice($potins_cherches, 0, 10); if ($potins_cherches != 'plus_de_potins' && $potins_cherches != 'pas_de_potins' && $potins_cherches != 'erreur') { foreach ($potins_cherches as $i => $potin_courant) { $potin_courant = infos_potin($potin_courant, $bdd); //echo vue_affichage_potin($potin_courant, $id_user, $bdd); echo vue_potin_v4($potin_courant, $id_user, $bdd); } } else { echo 'Il n\'y a pas de potins à afficher'; } ?> </div> </div> <div id="suite-scrolling"></div> <button class="btn btn-default btn-block" id="bouton-accueil-scrolling">La suite !</button>
$offset = $limit * $num_page; include_once 'modele/rechercher_potins.php'; include_once 'vue/potin/affichage_potin.php'; include_once 'vue/potin/potin_v4.php'; include_once 'vue/potin/potin_v4_brouille.php'; include_once 'modele/infos_potin.php'; $reponse = NULL; $j = 0; $potins_cherches = rechercher_potins_sur_user($id_user, $bdd); if ($potins_cherches != 0) { $potins_cherches = array_slice($potins_cherches, $offset, $limit); foreach ($potins_cherches as $i => $potin_courant) { $potin_courant = infos_potin($potin_courant, $bdd); //$reponse['potin'.$j] = vue_potin_v4($potin_courant, $id_user, $bdd); $reqa = $bdd->prepare('SELECT decouvert FROM cor_potin_users WHERE id_concerne = ? AND id_potin = ?'); $reqa->execute(array($id_user, $potin_courant['id_Potin'])); $donneesa = $reqa->fetch(); $reqa->closeCursor(); if ($donneesa['decouvert'] == 1 || auteur_du_potin($potin_courant['id_Potin'], $bdd) == $id_user) { // Si on l'a écouvert ou qu'on en est l'auteur $reponse['potin' . $j] = vue_potin_v4($potin_courant, $id_user, $bdd); } else { $reponse['potin' . $j] = vue_potin_v4_brouille($potin_courant, $id_user, $bdd); } $j++; } $reponse['nb_potins'] = $j; } else { $reponse['nb_potins'] = 0; } echo json_encode($reponse);