Example #1
0
}
try {
    $instructors = InstructorFetcher::retrieveAll();
    if (isBtnUpdatePrsd()) {
        $updateDone = 0;
        $instructorId = trim($_POST['updateInstructorIdModal']);
        $newInstructorFname = trim($_POST['instructorFnameUpdate']);
        $newInstructorLname = trim($_POST['instructorLnameUpdate']);
        $updateDone = false;
        if (($instructor = getInstructor($instructorId, $instructors)) !== false) {
            $oldInstructorFname = $instructor[InstructorFetcher::DB_COLUMN_FIRST_NAME];
            $oldInstructorLname = $instructor[InstructorFetcher::DB_COLUMN_LAST_NAME];
            $updateDone = $updateDone || Instructor::updateLname($instructorId, $newInstructorLname, $oldInstructorLname);
            if (strcmp($newInstructorFname, $oldInstructorFname) !== 0) {
                $updateDone = true;
                Instructor::updateFname($instructorId, $newInstructorFname);
            }
            if (strcmp($newInstructorLname, $oldInstructorLname) !== 0) {
                $updateDone = true;
                Instructor::updateLname($instructorId, $newInstructorLname);
            }
            if (!$updateDone) {
                throw new Exception("No new data inputted. Process aborted.");
            }
            //
            header('Location: ' . BASE_URL . 'academia/instructors/success');
        } else {
            throw new Exception("Either you're trying to hack this app or something wrong went. In either case the\n            developers were just notified about this.");
        }
    } else {
        if (isBtnSavePrsd()) {