示例#1
0
    return isset($_POST['hidden_submit_pressed']) && empty($_POST['hidden_submit_pressed']);
}
try {
    $majors = MajorFetcher::retrieveMajorsToEdit();
    if (isBtnUpdatePrsd()) {
        $updateDone = false;
        $majorId = trim($_POST['updateMajorIdModal']);
        $newMajorCode = trim($_POST['majorCodeUpdate']);
        $newMajorName = trim($_POST['majorNameUpdate']);
        $updateDone = false;
        if (($major = getMajor($majorId, $majors)) !== false) {
            $oldMajorCodeName = $major[MajorFetcher::DB_COLUMN_CODE];
            $oldMajorName = $major[MajorFetcher::DB_COLUMN_NAME];
            if (strcmp($newMajorName, $oldMajorName) !== 0) {
                $updateDone = true;
                Major::updateName($majorId, $newMajorName);
            }
            if (strcmp($newMajorCode, $oldMajorCodeName) !== 0) {
                $updateDone = true;
                Major::updateCode($majorId, $newMajorCode);
            }
            if (!$updateDone) {
                throw new Exception("No new data inputted. Process aborted.");
            }
            //
            header('Location: ' . BASE_URL . 'academia/majors/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()) {