public function saveDivisionPreceptorList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['division_preceptor_list'])) {
         // somebody has unset this widget
         return;
     }
     if (is_null($con)) {
         $con = $this->getConnection();
     }
     foreach ($this->getObject()->getDivisionPreceptors() as $division_preceptor) {
         $division_preceptor->delete($con);
     }
     $values = $this->getValue('division_preceptor_list');
     if (is_array($values)) {
         $con->beginTransaction();
         try {
             foreach ($values as $value) {
                 $division_preceptor = new DivisionPreceptor();
                 $division_preceptor->setDivision($this->getObject());
                 $division_preceptor->setPreceptorId($value);
                 $division_preceptor->save();
             }
             $con->commit();
         } catch (Exception $e) {
             $con->rollBack();
         }
     }
 }
Ejemplo n.º 2
0
 public function createPreceptor($division, $con)
 {
     if ($this->getUser()->isPreceptor() && $division->isNew()) {
         $division_preceptor = new DivisionPreceptor();
         $division_preceptor->setDivision($division);
         $preceptor = PersonalPeer::retrievePreceptorBySfGuardUserId($this->getUser()->getGuardUser()->getId());
         $division_preceptor->setPreceptorId($preceptor->getId());
         $division_preceptor->save($con);
     }
 }
Ejemplo n.º 3
0
 public function copyPreceptorsToDivision(PropelPDO $con = null, $division)
 {
     $division_preceptors = $this->getDivisionPreceptors();
     foreach ($division_preceptors as $division_preceptor) {
         $new_division_preceptor = new DivisionPreceptor();
         $new_division_preceptor->setDivision($division);
         $new_division_preceptor->setPreceptorId($division_preceptor->getPreceptor()->getId());
         $new_division_preceptor->save($con);
         $new_division_preceptor->clearAllReferences(true);
         unset($new_division_preceptor);
         $division_preceptor->clearAllReferences(true);
         unset($division_preceptor);
     }
     unset($division_preceptors);
     $division->clearAllReferences(true);
     unset($division);
 }