Exemple #1
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aPerson !== null) {
             if ($this->aPerson->isModified() || $this->aPerson->isNew()) {
                 $affectedRows += $this->aPerson->save($con);
             }
             $this->setPerson($this->aPerson);
         }
         if ($this->aWing !== null) {
             if ($this->aWing->isModified() || $this->aWing->isNew()) {
                 $affectedRows += $this->aWing->save($con);
             }
             $this->setWing($this->aWing);
         }
         if ($this->aMemberClass !== null) {
             if ($this->aMemberClass->isModified() || $this->aMemberClass->isNew()) {
                 $affectedRows += $this->aMemberClass->save($con);
             }
             $this->setMemberClass($this->aMemberClass);
         }
         if ($this->aMemberRelatedByMasterMemberId !== null) {
             if ($this->aMemberRelatedByMasterMemberId->isModified() || $this->aMemberRelatedByMasterMemberId->isNew()) {
                 $affectedRows += $this->aMemberRelatedByMasterMemberId->save($con);
             }
             $this->setMemberRelatedByMasterMemberId($this->aMemberRelatedByMasterMemberId);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = MemberPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = MemberPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += MemberPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collApplications !== null) {
             foreach ($this->collApplications as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collAvailabilitys !== null) {
             foreach ($this->collAvailabilitys as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collCoordinators !== null) {
             foreach ($this->collCoordinators as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collMembersRelatedByMasterMemberId !== null) {
             foreach ($this->collMembersRelatedByMasterMemberId as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collMemberWingJobs !== null) {
             foreach ($this->collMemberWingJobs as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collMissionLegsRelatedByCopilotId !== null) {
             foreach ($this->collMissionLegsRelatedByCopilotId as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collMissionLegsRelatedByBackupCopilotId !== null) {
             foreach ($this->collMissionLegsRelatedByBackupCopilotId as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collPilots !== null) {
             foreach ($this->collPilots as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collPilotAircrafts !== null) {
             foreach ($this->collPilotAircrafts as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collPilotDates !== null) {
             foreach ($this->collPilotDates as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collPilotRequests !== null) {
             foreach ($this->collPilotRequests as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Exemple #2
0
 /**
  * Specifies the master member. It will show option to add or search a member
  * CODE: member_class_create
  */
 public function executeUpdateMclass(sfWebRequest $request)
 {
     if (!$this->getUser()->hasCredential(array('Administrator'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     if ($request->getParameter('id')) {
         $mclass = MemberClassPeer::retrieveByPK($request->getParameter('id'));
         $this->title = 'Edit Member Class';
         $success = 'Member Class has successfully created!';
     } else {
         $mclass = new MemberClass();
         $this->title = 'Add Member Class';
         $success = 'Member Class has successfully changed!';
     }
     $this->back = $request->getReferer();
     $this->form = new MemberClassForm($mclass);
     $this->mclass = $mclass;
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter('mclass'));
         $this->referer = $request->getReferer();
         if ($this->form->isValid()) {
             $mclass->setName($this->form->getValue('name'));
             $mclass->setInitialFee($this->form->getValue('initial_fee'));
             $mclass->setRenewalFee($this->form->getValue('renewal_fee'));
             $mclass->setSubInitialFee($this->form->getValue('sub_initial_fee'));
             $mclass->setSubRenewalFee($this->form->getValue('sub_renewal_fee'));
             $mclass->setRenewalPeriod($this->form->getValue('renewal_period'));
             if ($this->form->getValue('fly_missions') == null) {
                 $mclass->setFlyMissions(0);
             } else {
                 $mclass->setFlyMissions($this->form->getValue('fly_missions'));
             }
             if ($this->form->getValue('newsletters') == null) {
                 $mclass->setNewsletters(0);
             } else {
                 $mclass->setNewsletters($this->form->getValue('newsletters'));
             }
             if ($this->form->getValue('sub_newsletters') == null) {
                 $mclass->setSubNewsletters(0);
             } else {
                 $mclass->setSubNewsletters($this->form->getValue('sub_newsletters'));
             }
             if ($mclass->isNew()) {
                 $content = $this->getUser()->getName() . ' added new Member Class: ' . $mclass->getName();
                 ActivityPeer::log($content);
             }
             $mclass->save();
             $this->getUser()->setFlash('success', $success);
             $this->redirect('mclass');
         } else {
             $this->error_msg = 'Please confirm required fields !';
         }
     } else {
         # Set referer URL
         $this->referer = $request->getReferer() ? $request->getReferer() : '@mclass';
     }
     $this->mclass = $mclass;
 }