Beispiel #1
0
         if (empty($requestObject->trailTerrain) === true) {
             $requestObject->trailTerrain = null;
         }
         if (empty($requestObject->trailUse) === true) {
             $requestObject->trailUse = null;
         }
         if (empty($requestObject->trailUuid) === true) {
             $requestObject->trailUuid = null;
         }
         if ($method === "PUT") {
             verifyXsrf();
             $trail = Trail::getTrailById($pdo, $id);
             if ($trail === null) {
                 throw new RuntimeException("trail does not exist", 404);
             }
             $trail = new Trail($id, $requestObject->userId, $trail->getBrowser(), $trail->getCreateDate(), $trail->getIpAddress(), $requestObject->submitTrailId, $requestObject->trailAmenities, $requestObject->trailCondition, $requestObject->trailDescription, $requestObject->trailDifficulty, $requestObject->trailDistance, $requestObject->trailName, $requestObject->trailSubmissionType, $requestObject->trailTerrain, $requestObject->trailTraffic, $requestObject->trailUse, $requestObject->trailUuid);
             $trail->update($pdo);
             $reply->message = "trail updated okay";
         }
         if ($method === "POST") {
             verifyXsrf();
             //preform the actual post/do i need to treat foreign keys in any special manner
             $trail = new Trail(null, $requestObject->userId, $_SERVER["HTTP_USER_AGENT"], new DateTime(), $_SERVER["REMOTE_ADDR"], $requestObject->submitTrailId, $requestObject->trailAmenities, $requestObject->trailCondition, $requestObject->trailDescription, $requestObject->trailDifficulty, $requestObject->trailDistance, $requestObject->trailName, $requestObject->trailSubmissionType, $requestObject->trailTerrain, $requestObject->trailTraffic, $requestObject->trailUse, $requestObject->trailUuid);
             $trail->insert($pdo);
             $reply->message = "trail submitted okay";
         }
     }
 } else {
     // if not an active user and attempting a method other than get, throw an exception
     if (empty($method) === false && $method !== "GET") {
         throw new RuntimeException("only active users are allowed to modify entries", 401);