/** * 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; }
/** * Declares an association between this object and a Camp object. * * @param Camp $v * @return PilotRequest The current object (for fluent API support) * @throws PropelException */ public function setCamp(Camp $v = null) { if ($v === null) { $this->setGroupCampId(NULL); } else { $this->setGroupCampId($v->getId()); } $this->aCamp = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Camp object, it will not be re-added. if ($v !== null) { $v->addPilotRequest($this); } return $this; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Camp $value A Camp object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Camp $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }