Beispiel #1
0
 public function delete($con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(ThesisAdvisorPeer::DATABASE_NAME);
     }
     try {
         $con->begin();
         ThesisAdvisorPeer::doDelete($this, $con);
         $this->setDeleted(true);
         $con->commit();
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
 }
Beispiel #2
0
 public function executeUpdate()
 {
     $i18n = new sfI18N();
     $i18n->initialize($this->getContext());
     $i18n->setCulture($this->getUser()->getCulture());
     $action_i18n = $i18n->globalMessageFormat->format('save as new');
     $action_type = $this->getRequestParameter('action_type');
     if ($action_type == $action_i18n || !$this->getRequestParameter('id')) {
         $student_thesis = new StudentThesis();
     } else {
         $student_thesis = StudentThesisPeer::retrieveByPk($this->getRequestParameter('id'));
         $this->forward404Unless($student_thesis);
     }
     $student_thesis->setId($this->getRequestParameter('id'));
     $student_thesis->setThesisTitle($this->getRequestParameter('thesis_title'));
     $student_thesis->setStudentId($this->getRequestParameter('student_id'));
     $student_thesis->setStatus($this->getRequestParameter('status'));
     $student_thesis->save();
     $c = new Criteria();
     $c->add(ThesisAdvisorPeer::STUDENT_THESIS_ID, $student_thesis->getId());
     ThesisAdvisorPeer::doDelete($c);
     $advisors = $this->getRequestParameter('isSelected');
     if ($advisors) {
         foreach ($advisors as $id) {
             $ta = new ThesisAdvisor();
             $ta->setStudentThesis($student_thesis);
             $ta->setEmployeeId($id);
             $ta->save();
         }
     }
     if ($student_thesis->getStatus() == StudentThesis::STATUS_DONE) {
         $ce = new ComprehensiveExam();
         $ce->setStudentId($student_thesis->getStudentId());
         $ce->setStatus(ComprehensiveExam::STATUS_PROPOSED);
         $ce->setAcademicCalendarId($student_thesis->getAcademicCalendarId());
         $ce->save();
     }
     return $this->redirect('student_thesis/list');
 }