<?php

include './core/bootstrap.php';
//connect to database
include 'dbconnect.php';
//check that user has a valid cookie, redirect if no valid cookie
include 'php_common/cookiecheck.php';
$workoutId = $_GET['wid'];
$workoutLoggingService = new WorkoutLoggingService();
$workoutInfo = $workoutLoggingService->getWorkoutInfo($workoutId);
$workoutUserId = $workoutInfo["userid"];
// Check that user of the workout_id_prev matches that of the cookie userid
if ($userid != $workoutUserId) {
    header('HTTP/1.1 500 Internal Server Error');
} else {
    $workoutLoggingService->deleteWorkout($workoutId);
    //update records table
    include 'update-records-absolute.php';
}
Example #2
0
$workout_id_prev = $_GET['wid'];
$showChangesSaved = 0;
//check if edits have been submitted
if (isset($_POST['workoutsubmit'])) {
    // save workout as a new workout (even though it was edited)
    $workoutResult = $workoutLoggingService->saveWorkout($_POST, $userid);
    // delete the previous workout
    $workoutLoggingService->deleteWorkout($workout_id_prev);
    // reset previous workout id
    $workout_id_prev = $workoutResult["workoutID"];
    //display a message that changes have been saved.
    $showChangesSaved = 1;
    //update records table
    include 'update-records-absolute.php';
}
$workoutInfo = $workoutLoggingService->getWorkoutInfo($workout_id_prev);
$userid_wid = $workoutInfo["userid"];
// Check that user of the workout_id_prev matches that of the cookie userid
if ($userid != $userid_wid) {
    header('Location: past-workouts.php');
}
// Extract user preferences
$userprefs = $userService->getUserPrefs($userid);
$show_boulder = $userprefs['show_boulder'];
$show_TR = $userprefs['show_TR'];
$show_Lead = $userprefs['show_Lead'];
$show_project = $userprefs['show_project'];
$show_redpoint = $userprefs['show_redpoint'];
$show_flash = $userprefs['show_flash'];
$show_onsight = $userprefs['show_onsight'];
$minB = $userprefs['minV'];