| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- $test = Test::get($id);
- if(!$test) throw new Exception("Test not found.");
- if($test->tester_id != Core::$user->id) throw new Exception("You do not have permission to view this page.");
- if($test->status > Test::STATUS_ASSIGNED) throw new Exception("The test has already been accepted or declined.");
- switch($action) {
- case "accept":
- $test->status = Test::STATUS_CONFIRMED;
- $test->dts_updated = Util::getDateTime();
- $test->commit();
- // TODO: Email/notification?
- Core::addAlert("success", "Test accepted successfully.");
- HTTP::redirect("/account/tests");
- break;
- case "decline":
- $test->status = Test::STATUS_UNASSIGNED;
- $test->tester_id = null;
- $test->dts_due = null;
- $test->dts_assigned = null;
- $test->dts_updated = Util::getDateTime();
- $test->commit();
- // TODO: Email/notification?
- Core::addAlert("success", "Test declined successfully.");
- HTTP::redirect("/account/tests");
- break;
- default:
- throw new Exception("Invalid action.");
- }
- ?>
|