コード例 #1
0
ファイル: actions.class.php プロジェクト: 42medien/spreadly
 public function executeApply_api(sfWebRequest $request)
 {
     $this->pUser = $this->getUser()->getGuardUser();
     $this->pPaymentMethods = $this->getUser()->getGuardUser()->getPaymentMethods();
     $this->pPaymentMethodForm = new PaymentMethodForm();
     if ($request->getMethod() == 'POST') {
         $lParams = $request->getPostParameters();
         $lIsNew = true;
         $lParams['sf_guard_user_id'] = $this->getUser()->getUserId();
         //check if the user selected an old address or if he inserted a new
         //if he selected an old, overwrite the form-values with the database-data -> needet for validation
         if (isset($lParams['existing_pm_id']) && $lParams['existing_pm_id'] != 'false') {
             //find the selected pm object
             $lSelectedPM = PaymentMethodTable::getInstance()->find($lParams['existing_pm_id']);
             //fill the values for validation
             $lParams['company'] = $lSelectedPM->getCompany();
             $lParams['contact_name'] = $lSelectedPM->getContactName();
             $lParams['address'] = $lSelectedPM->getAddress();
             $lParams['zip'] = $lSelectedPM->getZip();
             $lParams['city'] = $lSelectedPM->getCity();
             //$lParams['payment_method_id'] = $lParams['existing_pm_id'];
             //bind the object to the form -> needed for update (if you don't do this, symfony always inserts a new db entry)
             $this->pPaymentMethodForm = new PaymentMethodForm($lSelectedPM);
         }
         $lParams['api_method'] = true;
         //unset the param, that check, if user selected an existent payment method
         unset($lParams['existing_pm_id']);
         $this->pPaymentMethodForm->bind($lParams);
         if ($this->pPaymentMethodForm->isValid()) {
             $lPm = $this->pPaymentMethodForm->save();
             $lText = "Der User " . $this->pUser->getFirstName() . " " . $this->pUser->getLastName() . " (" . $this->pUser->getUsername() . ") ";
             $lText .= "mit der Email-Adresse " . $this->pUser->getEmailAddress() . " hat einen API Key beantragt. Um ihn zu bearbeiten bitte folgenden Link klicken: \n\n";
             $lText .= sfConfig::get("app_settings_url") . "/backend.php/guard/users/" . $this->pUser->getId() . "/edit";
             //backend/guard/users/2/edit
             //app_settings_support_email
             sfContext::getInstance()->getMailer()->composeAndSend(array(sfConfig::get("app_email_address") => sfConfig::get("app_email_sender")), sfConfig::get("app_settings_support_email"), 'Neue Api Anfrage', $lText);
             $this->redirect('advertiser/apply_api_thanks');
         }
     }
 }
コード例 #2
0
ファイル: actions.class.php プロジェクト: 42medien/spreadly
 /**
  * Create deal - step 4: select the payment method and insert address
  * @param sfWebRequest $request
  */
 public function executeStep_billing(sfWebRequest $request)
 {
     $this->getResponse()->setSlot('js_document_ready', $this->getPartial('deals/js_init_deals.js'));
     //$this->pForm->validate_billing();
     $this->pPaymentMethods = $this->getUser()->getGuardUser()->getPaymentMethods();
     $this->pPaymentMethodForm = new PaymentMethodForm();
     //$lPaymentMethodForm = new PaymentMethodForm();
     //$this->pForm->embedForm('payment_method', $lPaymentMethodForm);
     if ($request->getMethod() == 'POST') {
         $lParams = $request->getPostParameters();
         $lIsNew = true;
         $lParams['sf_guard_user_id'] = $this->getUser()->getUserId();
         //check if the user selected an old address or if he inserted a new
         //if he selected an old, overwrite the form-values with the database-data -> needet for validation
         if (isset($lParams['existing_pm_id']) && $lParams['existing_pm_id'] != 'false') {
             //find the selected pm object
             $lSelectedPM = PaymentMethodTable::getInstance()->find($lParams['existing_pm_id']);
             //fill the values for validation
             $lParams['company'] = $lSelectedPM->getCompany();
             $lParams['contact_name'] = $lSelectedPM->getContactName();
             $lParams['address'] = $lSelectedPM->getAddress();
             $lParams['zip'] = $lSelectedPM->getZip();
             $lParams['city'] = $lSelectedPM->getCity();
             //$lParams['payment_method_id'] = $lParams['existing_pm_id'];
             //bind the object to the form -> needed for update (if you don't do this, symfony always inserts a new db entry)
             $this->pPaymentMethodForm = new PaymentMethodForm($lSelectedPM);
             //$this->pForm->embedForm('payment_method', $lPaymentMethodForm);
         }
         //unset the param, that check, if user selected an existent payment method
         unset($lParams['existing_pm_id']);
         //var_dump($lParams);die();
         //var_dump($lParams);die();
         //bind and validatevalidate
         //unset($lParams['payment_method_id']);
         $this->pPaymentMethodForm->bind($lParams);
         //var_dump($this->pPaymentMethodForm->isValid());die();
         if ($this->pPaymentMethodForm->isValid()) {
             //aus irgendnem beschissenen grund setzt doctrine oder symfony oder was auch immer die pm-id nicht im deal beim speichern des formulars, deswegen alles nochmal schön brav per hand...doh...wenn jemand da schlauer ist, soll ers gerne alles ändern....vallah
             $lPm = $this->pPaymentMethodForm->save();
             //$lPm = $this->pForm->getEmbeddedForm('payment_method')->getObject();
             $this->pDeal->setPaymentMethodId($lPm->getId());
             $this->pDeal->save();
             $this->pDeal->complete_billing();
             $this->redirect('deals/step_verify?did=' . $this->pDeal->getId());
         }
     } else {
         if ($this->pDeal->canReset_to_billing()) {
             $this->pDeal->reset_to_billing();
         } else {
             if ($this->pDeal->getState() != DealTable::STATE_COUPON_COMPLETED) {
                 $this->redirect404();
             }
         }
     }
 }