Ejemplo n.º 1
0
 /**
  * Add or edit afaorgs
  * It also handles followings:
  * CODE: afaorg_create
  */
 public function executeUpdate(sfWebRequest $request)
 {
     # security
     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');
     }
     sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');
     slot('nav_menu', array('reference', ''));
     if ($request->getParameter('id')) {
         $afa = AfaOrgPeer::retrieveByPK($request->getParameter('id'));
         $this->forward404Unless($afa);
         $this->title = 'Edit Linking Organization';
         $success = 'Linking Organization information has been successfully changed!';
     } else {
         $afa = new AfaOrg();
         $this->title = 'Add Linking Organization';
         $success = 'Linking Organization information has been successfully created!';
     }
     $this->form = new AfaOrgForm($afa);
     if ($request->isMethod('post')) {
         $this->referer = $request->getReferer();
         $this->form->bind($request->getParameter('afa'));
         if ($this->form->isValid()) {
             $afa->setName($this->form->getValue('name'));
             $afa->setOrgPhone($this->form->getValue('org_phone'));
             $afa->setHomePageUrl($this->form->getValue('home_page_url'));
             $afa->setOrgFax($this->form->getValue('org_fax'));
             $afa->setRefContactName($this->form->getValue('ref_contact_name'));
             $afa->setRefContactEmail($this->form->getValue('ref_contact_email'));
             $afa->setVpoSoapServerUrl($this->form->getValue('vpo_soap_server_url'));
             $afa->setVpoRequestPostEmail($this->form->getValue('vpo_request_post_email'));
             $afa->setVpoUserId($this->form->getValue('vpo_user_id'));
             $afa->setVpoUserPassword($this->form->getValue('vpo_user_password'));
             $afa->setVpoOrgId($this->form->getValue('vpo_org_id'));
             $afa->setAfidsRequesterUserName($this->form->getValue('afids_requester_user_name'));
             $afa->setAfidsRequesterPassword($this->form->getValue('afids_requester_password'));
             $afa->setAfidsSoapServerUrl($this->form->getValue('afids_soap_server_url'));
             $afa->setAfidsRequestPostEmail($this->form->getValue('afids_request_post_email'));
             $afa->setPhoneNumber1($this->form->getValue('phone_number1'));
             $afa->setPhoneNumber2($this->form->getValue('phone_number2'));
             if ($afa->isNew()) {
                 $content = $this->getUser()->getName() . ' added Linking Organization: ' . $afa->getName();
                 ActivityPeer::log($content);
             }
             $afa->save();
             $this->getUser()->setFlash('success', $success);
             return $this->redirect('@afaOrg');
         }
     } else {
         # Set referer URL
         $this->referer = $request->getReferer() ? $request->getReferer() : '@afaorg';
     }
     $this->afa = $afa;
 }
Ejemplo n.º 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->aMissionLeg !== null) {
             if ($this->aMissionLeg->isModified() || $this->aMissionLeg->isNew()) {
                 $affectedRows += $this->aMissionLeg->save($con);
             }
             $this->setMissionLeg($this->aMissionLeg);
         }
         if ($this->aAircraft !== null) {
             if ($this->aAircraft->isModified() || $this->aAircraft->isNew()) {
                 $affectedRows += $this->aAircraft->save($con);
             }
             $this->setAircraft($this->aAircraft);
         }
         if ($this->aAfaOrg !== null) {
             if ($this->aAfaOrg->isModified() || $this->aAfaOrg->isNew()) {
                 $affectedRows += $this->aAfaOrg->save($con);
             }
             $this->setAfaOrg($this->aAfaOrg);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = AfaLegPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = AfaLegPeer::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 += AfaLegPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }