Esempio n. 1
0
<?php

include_once dirname(__FILE__) . "/../common/common.php";
include_once dirname(__FILE__) . '/../business/AuthB.php';
include_once dirname(__FILE__) . '/../database/Trip.php';
$auth = new AuthB();
if (!$auth->canSynchTrip()) {
    $response = errorResponse(RESPONSE_UNAUTHORIZED);
} else {
    if (isGetMethod()) {
        if (isset($_GET['hash'])) {
            $hash = $_GET['hash'];
            if ($hash === '') {
                $response = errorResponse(RESPONSE_BAD_REQUEST, 'Empty hash');
            } else {
                $trip = Trip::findByHash($hash);
                if ($trip === null) {
                    $response = errorResponse(RESPONSE_NOT_FOUND);
                } else {
                    $response = successResponse();
                    $response['tripId'] = $trip->getTripId();
                    $response['created'] = $trip->getCreated();
                    $response['updated'] = $trip->getUpdated();
                    $response['name'] = $trip->getName();
                    $response['description'] = $trip->getDescription();
                    $response['bannerImg'] = $trip->getBannerImg();
                    $response['startDate'] = $trip->getStartDate();
                    $response['endDate'] = $trip->getEndDate();
                    $response['active'] = $trip->getActive();
                    $response['deleted'] = $trip->getDeleted();
                    $response['hash'] = $trip->getHash();