prof_conflict($cta[1], $_POST['cprof'], $_SESSION['year'], $_SESSION['season'], $_SESSION['dept']); } } if (isset($_POST['remove'])) { $l = explode("|", $_POST['taprof']); //remove this record from the db. drop_conflict($l[0], $l[1], $_SESSION['dept'], $_SESSION['year'], $_SESSION['season']); } if (isset($_POST['match'])) { //make sure every field is set. $mta = explode('=', $_POST['mta']); $c = explode('=', $_POST['course']); $s = explode('=', $_POST['section']); if (!(count($mta) == 1 || count($c) == 3 || count($s) == 1)) { //make a record of this matching. $error = force_match($_SESSION['dept'], $_SESSION['year'], $_SESSION['season'], $mta[1], $c[0], $s[3]); $status = array(); if (isset($error)) { $status = array("error-message", $error); } } unset($_SESSION['course']); unset($_SESSION['section']); } if (isset($_POST['mremove'])) { $l = explode("|", $_POST['tamatch']); //remove this record from the db. drop_match($l[0], $l[1], $l[2], $_SESSION['dept'], $_SESSION['year'], $_SESSION['season']); } if (isset($_GET['course'])) { $_SESSION['course'] = $_GET['course'];
function force_checks($dept, $year, $season) { //something important just happened, and we want to make the constraints are still valid. //the plan: take all force matches, drop them, and re-add them. $db = new PDO(DB_PATH, DB_LOGIN, DB_PW); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //first see if TA is in the database under your department $sql = "SELECT * FROM force_match WHERE department = '{$dept}' AND quarter_year = {$year}\n AND quarter_season = {$season};"; $matches = array(); try { $result = $db->query($sql); foreach ($result as $r) { array_push($matches, $r); } } catch (PDOException $e) { echo $e->getMessage(); } foreach ($matches as $r) { //drop and add. drop_match($r['sid'], $r[course], $r[section], $r[department], $r[quarter_year], $r[quarter_season]); force_match($r[department], $r[quarter_year], $r[quarter_season], $r['sid'], $r[course], $r[section]); } }