示例#1
0
 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()) {
         $newMajorCode = trim($_POST['major_code']);
         $newMajorName = trim($_POST['major_name']);
         Major::create($newMajorCode, $newMajorName);
         header('Location: ' . BASE_URL . 'academia/majors/success');