Beispiel #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->aCamp !== null) {
             if ($this->aCamp->isModified() || $this->aCamp->isNew()) {
                 $affectedRows += $this->aCamp->save($con);
             }
             $this->setCamp($this->aCamp);
         }
         if ($this->aPassenger !== null) {
             if ($this->aPassenger->isModified() || $this->aPassenger->isNew()) {
                 $affectedRows += $this->aPassenger->save($con);
             }
             $this->setPassenger($this->aPassenger);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = CampPassengerPeer::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->setNew(false);
             } else {
                 $affectedRows += CampPassengerPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Beispiel #2
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->aMember !== null) {
             if ($this->aMember->isModified() || $this->aMember->isNew()) {
                 $affectedRows += $this->aMember->save($con);
             }
             $this->setMember($this->aMember);
         }
         if ($this->aCamp !== null) {
             if ($this->aCamp->isModified() || $this->aCamp->isNew()) {
                 $affectedRows += $this->aCamp->save($con);
             }
             $this->setCamp($this->aCamp);
         }
         if ($this->aMissionLeg !== null) {
             if ($this->aMissionLeg->isModified() || $this->aMissionLeg->isNew()) {
                 $affectedRows += $this->aMissionLeg->save($con);
             }
             $this->setMissionLeg($this->aMissionLeg);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = PilotRequestPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = PilotRequestPeer::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 += PilotRequestPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collPilotDates !== null) {
             foreach ($this->collPilotDates as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Beispiel #3
0
 /**
  * Searches for camps
  * CODE:camp_create
  */
 public function executeUpdate(sfWebRequest $request)
 {
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Coordinator'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');
     $this->agencies = AgencyPeer::getForSelectParent();
     $this->agency = trim($this->getRequestParameter('agency', '*')) == '' ? '*' : trim($this->getRequestParameter('agency', '*'));
     $this->airport = trim($this->getRequestParameter('airport', '*')) == '' ? '*' : trim($this->getRequestParameter('airport', '*'));
     $this->airports = AirportPeer::doSelect(new Criteria());
     if ($request->getParameter('id')) {
         $camp = CampPeer::retrieveByPK($request->getParameter('id'));
         $this->forward404Unless($camp);
         if (isset($camp)) {
             if ($camp->getAgencyId()) {
                 $agency = AgencyPeer::retrieveByPK($camp->getAgencyId());
                 if (isset($agency)) {
                     $this->agency_id = $agency->getId();
                 }
             }
             if ($camp->getAirportId()) {
                 $airport = AirportPeer::retrieveByPK($camp->getAirportId());
                 if (isset($airport)) {
                     $this->airport_id = $airport->getId();
                 }
             }
         }
         $this->title = 'Edit camp';
         $success = 'Camp information has been successfully changed!';
         slot('nav_menu', array('mission_coord', ''));
     } else {
         $camp = new Camp();
         if ($request->getParameter('agency_id')) {
             $this->agency_id = $request->getParameter('agency_id');
         }
         $this->title = 'Add new camp';
         $success = 'Camp information has been successfully created!';
         slot('nav_menu', array('mission_coord', 'add-camp'));
     }
     //Agency PopUp Form
     $agency = new Agency();
     $this->form_a = new AgencyForm($agency);
     $this->a_referer = $request->getReferer();
     //Aiport PopUp Form
     $airport = new Airport();
     $this->form_airport = new AirportForm($airport);
     $this->airport_referer = $request->getReferer();
     $this->form = new CampForm($camp);
     if ($request->isMethod('post')) {
         $this->referer = $request->getParameter('referer');
         $this->form->bind($request->getParameter('camp'));
         $ma = '';
         foreach ($this->form as $pass_key => $pass_data) {
             $ma .= $pass_data . '|';
         }
         if ($this->form->isValid() && $request->getParameter('agency') != null) {
             if ($request->getParameter('agency')) {
                 $agency = AgencyPeer::getByName($request->getParameter('agency'));
             }
             if (isset($agency) && $agency instanceof Agency) {
                 $camp->setAgencyId($agency->getId());
             }
             //$aId = $camp->getAirportId();
             //$aInd = $request->getParameter('airport');
             $airport = AirportPeer::getByIdent($request->getParameter('airport'));
             /*if(!empty($aId)){
                 if(!empty($aInd)){
                     $camp->setAirportId($airport->getId());
                 }
                 else{
                     $camp->setAirportId($aId);
                 }
               }else{
                 if($airport) $camp->setAirportId($airport->getId());
               }*/
             /*if($request->getParameter('airport')){
                 $camp->setAirportId(null);
               }else{
                 $airport = AirportPeer::getByIdent($request->getParameter('airport'));
                 if(isset($airport) instanceof Airport){
                   $camp->setAirportId($airport->getId());
                 }
               }*/
             //$camp->setAirport($request->getParameter('airport_name'));
             $camp->setAirport($airport);
             $camp->setSession($this->form->getValue('session'));
             $camp->setCampName($this->form->getValue('camp_name'));
             $camp->setArrivalDate($this->form->getValue('arrival_date'));
             $camp->setDepartureDate($this->form->getValue('departure_date'));
             $camp->setArrivalComment($this->form->getValue('arrival_comment'));
             $camp->setDepartureComment($this->form->getValue('departure_comment'));
             $camp->setComment($this->form->getValue('comment'));
             if ($camp->isNew()) {
                 $content = $this->getUser()->getName() . ' added new Camp: ' . $camp->getCampName();
                 ActivityPeer::log($content);
             }
             $camp->save();
             $this->getUser()->setFlash('success', $success);
             if ($this->form->isNew()) {
                 $this->redirect('camp/view?id=' . $camp->getId());
             } else {
                 $this->redirect('camp/index?showlist=true');
             }
             //add passengers to camp then create new mission, legs
             //missions assocated with camps that will be a group mission
         } else {
             if ($request->getParameter('agency_id') == null) {
                 $this->getUser()->setFlash('warning', 'Please choose Agency!');
             }
         }
     } else {
         # Set referer URL
         $this->referer = $request->getReferer() ? $request->getReferer() : '@camp';
         //echo $this->referer;      exit ();
     }
     $this->camp = $camp;
 }