/** * Récupère tous les tweets des utilisateurs qu'il suit * @return $alltweets array */ public function getAllTweets() { /* On récupère les ID que notre user follow */ $user = InfoUser::getInstance($this->db, $this->userid); $allid = $user->getUserIdFollow(); /* On ajoute notre ID à la liste */ $allid[] = $this->userid; /* On selectionne tous les tweets appartement à la liste des ID */ $getTweets = $this->db->prepare("SELECT t.*, u.id as user_id, u.pseudo, u.nom, u.prenom FROM tweets as t LEFT JOIN users as u ON t.auteur_id = u.id WHERE auteur_id REGEXP(:ids) ORDER BY date DESC"); $getTweets->execute(array('ids' => implode('|', $allid))); $getTweets->setFetchMode(PDO::FETCH_OBJ); $alltweets = $getTweets->fetchAll(); /* On retourne les tweets */ return $alltweets; }
use App\Vendor\User; use App\Vendor\Follow; require 'core/init.php'; if (!connect()) { User::redirect('/home.php'); } //On défini le titre App::setTitle('Profil'); $id_page = "profil"; /* Si le profil selectionné n'est pas le notre */ if (isset($_GET['user']) && $_GET['user'] != $_SESSION['username']) { $profil_userid = $_GET['user']; $profil_user = InfoUser::getInstance($DB_con, $profil_userid); } else { /* Sinon si c'est le notre */ $profil_user = InfoUser::getInstance($DB_con, $_SESSION['username']); } /* On récupère ensuite les infos */ $info_profil = $profil_user->getInfo(); $follow = Follow::getInstance($DB_con, $info_profil->id); if (isset($_POST['SubmitFollow'])) { $UserToFollow = htmlspecialchars(trim($_POST['ProfilUserid'])); if (!empty($UserToFollow)) { $follow->Follow(); } } if (isset($_POST['SubmitUnFollow'])) { $UserToFollow = htmlspecialchars(trim($_POST['ProfilUserid'])); if (!empty($UserToFollow)) { $follow->UnFollow(); }
$imgtwitter = null; } else { $text = ""; $href = ""; $textBtn = ""; $imgtwitter = ""; } $template_no_connect = "<p class=\"navbar-text navbar-right\">{$text} <a type=\"button\" href=\"{$href}\" class=\"btn btn-primary-outline btn-smlarge navbar-btn\" id=\"navbar-btn-noconnect\">{$textBtn}</a></p>"; $onglets = $template_no_connect; } else { if (!isset($_SESSION['imgprofil'])) { $user = User::getInstance($DB_con); $_SESSION['imgprofil'] = $user->getUserImg($_SESSION['userid']); } /* On récupère les infos propre à notre utilisateur */ $user = InfoUser::getInstance($DB_con, $_SESSION['username'], true); $info_user = $user->getInfo(); $activehome = $id_page == "index" ? 'class="active"' : ""; $activenotif = $id_page == "notification" ? 'class="active"' : ""; $activemsg = $id_page == "message" ? 'class="active"' : ""; $onglets = ' <ul class="nav navbar-nav navbar-left"> <li ' . $activehome . '><a href="/" title="Accueil"><i class="fa fa-home"></i> Accueil</a></li> <li ' . $activenotif . '><a href="/notifications.php" title="Mes notifications"><i class="fa fa-bell"></i> Notifications</a></li> <li ' . $activemsg . '><a href="/messages.php" title="Mes messages" id="liamis"><i class="fa fa-envelope"></i> Messages</a></li> </ul> <a type="button" class="btn btn-primary-outline navbar-btn navbar-right" data-toggle="modal" data-target="#newTweet"><i class="fa fa-paper-plane"></i> Tweeter</a> <ul class="nav navbar-nav navbar-right" style="margin-right: 10px;"> <li class="dropdown"> <a href="javascript:void(0)" data-target="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> <img class="img-circle navbar-img-profil" src="' . $_SESSION["imgprofil"] . '"></i>
<?php use App\App; use Core\Config; use App\Vendor\InfoUser; use App\Vendor\User; require 'core/init.php'; if (!connect()) { User::redirect('/home.php'); } //On défini le titre App::setTitle('Accueil'); $id_page = "index"; /* On récupère les infos de l'utilisateur */ $user = InfoUser::getInstance($DB_con, $_SESSION['userid']); $info_profil = $user->getInfo(); $nbrTweets = $user->getNbrTweets(); $nbrFollowers = $user->getNbrFollowers(); $nbrFollow = $user->getNbrFollow(); $nbrMedia = $user->getNbrMedia(); if (!isset($_SESSION['imgprofil'])) { $user = User::getInstance($DB_con); $_SESSION['imgprofil'] = $user->getUserImg($_SESSION['userid']); } //On importe la vue require Config::get('view.paths') . 'index.view.php';