Exemple #1
0
});
$app->post('/reportSpotIssue', function () use($app) {
    verifyRequiredParams(array('userId', 'spotId', 'airdata', 'seadata', 'cam'));
    $response = array();
    // reading post params
    //$email = $app->request()->post('email');
    //$user_id = $app->request()->post('userId');
    $spotId = $app->request()->post('spotId');
    $airdata = $app->request()->post('airdata');
    $seadata = $app->request()->post('seadata');
    $cam = $app->request()->post('cam');
    //global $user_id;
    $db = new DbHandler();
    //$res = $db->toggleFavourite($email, $spotId);
    $res = $db->reportIssue($user_id, $spotId, $airdata, $seadata, $cam);
    $spot = $db->getSpot($spotId);
    $user = $db->getUserById($user_id);
    $response = array();
    $response["airdata"] = $airdata;
    $response["seadata"] = $seadata;
    $response["cam"] = $cam;
    if ($res == ISSUE_LOGGED_SUCCESSFULLY) {
        //try send email here
        sendErrorReport($user, $spot, $airdata, $seadata, $cam);
        $response["error"] = false;
        $response["message"] = "Thanks for letting us know there's a problem.<br>We'll contact you should we require more details.";
    } else {
        if ($res == ISSUE_LOG_FAILED) {
            $response["error"] = true;
            $response["message"] = 'Oops! We are unable to log an issue for this spot.';
        } else {