public static function process() { $user = unserialize($_SESSION['user']); if (isset($_GET['edit'])) { $id = $_GET['workout']; if (empty($id)) { die("empty id"); } self::$workout = new Workout($user, $id); self::$workout->read(); self::$exercise_forms = self::$workout->exercises; } else { if (isset($_GET['create'])) { self::$workout = new Workout($user); self::$exercise_forms = array(0 => array()); } else { if (isset($_GET['save'])) { $id = $_GET['workout']; self::$workout = new Workout($user, $id); self::$exercise_forms = $_POST['exercises']; self::$workout->name = $_POST['workout_name']; if (empty(self::$exercise_forms)) { die("no exercises submitted"); } $invalid_forms = array(); foreach (self::$exercise_forms as $id => $exercise_form) { if (!Validate::exercise_form($execise_form)) { $invalid_forms[] = $exercise_form; } } if (count($invalid_forms) > 0) { //print errors } else { self::$workout->exercises = self::$exercise_forms; if (self::$workout->is_new()) { self::$workout->create(); } else { self::$workout->update(); } //header("Location: ?do=list"); } } } } }
$content .= Login::renderContent(); $styles[] = Login::getStyles(); $scripts[] = Login::getScripts(); break; case 'logout': session_destroy(); break; case 'design': WorkoutDesign::process(); $content .= WorkoutDesign::renderContent(); $styles[] = WorkoutDesign::getStyles(); $scripts[] = WorkoutDesign::getScripts(); break; case 'register': Register::process(); $styles[] = WorkoutDesign::getStyles(); $content .= Register::renderContent(); break; case 'assign': WorkoutAssign::process(); $content .= WorkoutAssign::renderContent(); break; case 'list': WorkoutListing::process(); $content .= WorkoutListing::renderContent(); break; case 'workout': Workingout::process(); $content .= Workingout::renderContent(); break; default: