choiceSubscriptionForm.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. class choiceSubscriptionForm extends sfForm {
  3. public function configure() {
  4. unset($this->validatorSchema['is_anonymous'], $this->validatorSchema['katao_node_id'], $this->validatorSchema['accounting_code'], $this->validatorSchema['accounting_code_sol'], $this->validatorSchema['initial_amount'], $this->validatorSchema['is_referer'], $this->validatorSchema['is_delegate'], $this->validatorSchema['katao_member_id'], $this->validatorSchema['user_status'], $this->validatorSchema['katao_index'], $this->validatorSchema['created_at'], $this->validatorSchema['updated_at'],$this->validatorSchema['user_birthday'],$this->validatorSchema['user_situation'],$this->validatorSchema['parrain_name']);
  5. unset($this->widgetSchema['is_anonymous'], $this->widgetSchema['katao_node_id'], $this->widgetSchema['accounting_code'], $this->widgetSchema['accounting_code_sol'], $this->widgetSchema['initial_amount'], $this->widgetSchema['is_referer'], $this->widgetSchema['is_delegate'], $this->widgetSchema['katao_member_id'], $this->widgetSchema['user_status'], $this->widgetSchema['katao_index'], $this->widgetSchema['created_at'], $this->widgetSchema['updated_at'], $this->widgetSchema['user_birthday'], $this->widgetSchema['user_situation'], $this->widgetSchema['parrain_name']);
  6. $this->widgetSchema['subscribe'] = new sfWidgetFormSelectRadio(array('choices' => array('Adhérer pour la première fois?', 'Ré-adhérer ?')));
  7. //$this->validatorSchema['first_name'] = new sfValidatorString(array('max_length' => 255));
  8. $this->setDefault('subscribe', 0);
  9. $this->widgetSchema['no_spam'] = new sfWidgetFormInputHidden();
  10. $this->setDefault('no_spam', '');
  11. }
  12. protected function doSave($con = null) {
  13. $katao_user = new KataoUser();
  14. $katao_user->setStatus(KataoUser::STATUS_PENDING);
  15. $katao_user->setEmail($this->getValue('user_email'));
  16. $katao_user->setPhone($this->getValue('user_phone'));
  17. $katao_user->setFax($this->getValue('user_fax'));
  18. $katao_user->setAddress1($this->getValue('user_address1'));
  19. $katao_user->setAddress2($this->getValue('user_address2'));
  20. $katao_user->setZip($this->getValue('user_zip'));
  21. $katao_user->setCity($this->getValue('user_city'));
  22. $katao_user->setLogin($this->getValue('user_login'));
  23. if ($this->getValue('user_password') && $this->getValue('user_password_confirmation') && $this->getValue('user_password') == $this->getValue('user_password_confirmation')) {
  24. $katao_user->setPassword($this->getValue('user_password'));
  25. }
  26. $katao_user->save($con);
  27. $this->getObject()->setKataoNodeRelatedByKataoNodeId(sfContext::getInstance()->getUser()->getActiveNode()?sfContext::getInstance()->getUser()->getActiveNode():KataoNodePeer::getDefaultOne());
  28. $this->getObject()->setIsMember(false);
  29. $return = parent::doSave($con);
  30. $katao_user->setKataoMember($this->getObject());
  31. $katao_user->save();
  32. return $return;
  33. }
  34. }