1
0

test_confirm.php 758 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. $test = Test::get($id);
  3. if(!$test) throw new Exception("Test not found.");
  4. if($test->tester_id != Core::$user->id) throw new Exception("You do not have permission to view this page.");
  5. if($test->status > Test::STATUS_ASSIGNED) throw new Exception("The test has already been accepted or declined.");
  6. switch($action) {
  7. case "accept":
  8. $test->status = Test::STATUS_CONFIRMED;
  9. $test->dts_updated = Util::getDateTime();
  10. $test->commit();
  11. Core::addAlert("success", "Test accepted successfully.");
  12. HTTP::redirect("/account/tests");
  13. break;
  14. case "decline":
  15. $test->decline();
  16. Core::addAlert("success", "Test declined successfully.");
  17. HTTP::redirect("/account/tests");
  18. break;
  19. default:
  20. throw new Exception("Invalid action.");
  21. }
  22. ?>