<?php require_once 'inc/bootstrap.inc.php'; require_once 'inc/guard.inc.php'; // Friends model require_once dirname(__FILE__) . '/core/Friends.class.php'; $friendsModel = new Friends(); // Get friends $friends = $friendsModel->getAllFriends($_SESSION['auth']['user_id'], 6); shuffle($friends['friends']); // Get friend requests $friendRequests = $friendsModel->getFriendRequests($_SESSION['auth']['user_id']); $notifications = $friendsModel->getNotifications(); require_once 'templates/notifications.tpl.php';
$data = json_decode($app->request->getBody()); echo json_encode($friend->addFriend($_SESSION['auth']['user_id'], $data->friend_id)); }); $app->delete('/friend', function () use($friend, $app) { $data = json_decode($app->request->getBody()); echo json_encode($friend->deleteFriend($_SESSION['auth']['user_id'], $data->friend_id)); }); $app->delete('/friends', function () use($friend, $app) { $data = json_decode($app->request->getBody()); echo json_encode($friend->deleteFriends($_SESSION['auth']['user_id'], $data->friends_to_remove)); }); /** * Notifications */ $app->get('/notifications/:type/:offset/:limit', function ($type, $offset, $limit) use($friend) { echo json_encode($friend->getNotifications($type, $offset, $limit)); }); /** * Login */ $app->post('/login', function () use($app, $login, $user) { $body = json_decode($app->request->getBody()); $email = $body[0]->value; $password = $body[1]->value; $status = $login->login($email, $password, $user); echo json_encode($status); }); $app->post('/logout', function () use($login) { $login->logout(); echo json_encode(''); });