/** * Fonciton affichant la liste de tous mes amis, fournissant un bouton permettant de les supprimer. */ function listeAmi() { $userId = $_SESSION['User']->getId(); $am = new AmisManager(connexionDb()); $tab1 = $am->getAmisByIdUser1($userId); $tab2 = $am->getAmisByIdUser2($userId); $tabRecap[0] = $tab1; $tabRecap[1] = $tab2; $um = new UserManager(connexionDb()); $actm = new ActivityManager(connexionDb()); $uam = new User_ActivityManager(connexionDb()); $existe = false; ?> <div class="Membres"> <div class="table-responsive"> <table class="table table-striped"> <caption> <h2> Membres </h2></caption> <tr> <th> Nom d'utilisateur</th> <th> Adresse Mail </th> <th> Téléphone </th> <th> Dernière connexion </th> <th> Activité du jour </th> <th> Action </th> </tr> <?php foreach ($tabRecap as $elem) { foreach ($elem as $amis) { if ($amis->getAccepte() == 1) { if ($elem == $tab1) { $user = $um->getUserById($amis->getIdUser2()); } else { if ($elem == $tab2) { $user = $um->getUserById($amis->getIdUser1()); } } $tabAct = $uam->getActIdByUserId($user); if ($tabAct) { $actId = $tabAct[0]['id_activity']; $activity = $actm->getActivityById($actId); $activity->setLibelle("<a href='amis.page.php?to=modifAct&id={$actId}'>" . $activity->getLibelle() . "</a>"); } else { $activity = new Activity(array("Libelle" => "N/A")); } if ($user->getTel() == NULL) { $tel = "N/A"; } else { $tel = $user->getTel(); } $id = $user->getId(); echo "<tr><td>" . $user->getUserName() . " </td><td>" . $user->getEmail() . " </td><td> " . $tel . "</td><td> " . $user->getDateLastConnect() . "</td><td> " . $activity->getLibelle() . "</td>"; echo "<td><form class='form-horizontal col-sm-12' name='suppression{$id}' action='amis.page.php' method='post'>"; echo "<input type='hidden' name='idAmi{$id}' value='" . $id . "''>"; echo "<button class='btn btn-danger col-sm-9' type='submit' id='formulaire' name='supprimerAmi{$id}'>Supprimer cet ami</button>"; echo "</form>"; echo "</td></tr>"; $existe = true; } } } if (!$existe) { echo "<tr> <td> Vous n'avez pas d'ami pour le moment !</td></tr>"; } ?> </table> </div> </div> <?php }