Esempio 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;
 }