Ejemplo n.º 1
0
    return $app['twig']->render('login.html.twig');
});
$app->get("/logged_on", function () use($app) {
    $user_name = $_GET['username'];
    $user = User::findByUserName($user_name);
    $user_logged = $user->logIn($user_name, $_GET['password']);
    if ($user_logged == "Wrong Password") {
        return $app['twig']->render('login.html.twig');
    } else {
        return $app['twig']->render('users.html.twig', array('user' => $user_logged, 'avialable_users' => $user->findUsersNear(), 'requests' => $user->findMeetupRequests()));
    }
});
$app->post("/request_meetup", function () use($app) {
    $user1 = User::find($_POST['user1_id']);
    $user2 = User::find($_POST['user2_id']);
    $location = Place::setMeetupLocation($user1, $user2);
    $user1->addMeetUpRequest($user2->getId(), $location->getId());
    return $app['twig']->render('waiting_to_confirm.html.twig', array('user1_id' => $user1->getId(), 'user2_id' => $user2->getId()));
});
//waiting for request respond page
$app->get("/wait_for_confirmation", function () use($app) {
    $user1 = User::find($_GET['user1_id']);
    $user2 = User::find($_GET['user2_id']);
    if ($user1->hasUserTwoConfirmed($user2->getId()) == NULL) {
        return $app['twig']->render('waiting_to_confirm.html.twig', array('user1_id' => $user1->getId(), 'user2_id' => $user2->getId()));
    } else {
        if ($user1->hasUserTwoConfirmed($user2->getId())) {
            $location = Place::getMeetUpLocation($user1->getId(), $user2->getId());
            return $app['twig']->render('confirmed_user1.html.twig', array('user_to_meet' => $user2, 'user' => $user1, 'location' => $location));
        } else {
            return $app['twig']->render('rejected.html.twig', array('user' => $user1, 'user_to_meet' => $user2));
Ejemplo n.º 2
0
 static function setMeetupLocation($user1, $user2)
 {
     $temp_location = Place::generateLocation();
     if ($temp_location->verifyLocation($user1, $user2)) {
         return $temp_location;
     } else {
         Place::setMeetupLocation($user1, $user2);
     }
 }