ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 7876


Ignore:
Timestamp:
Jul 30, 2008, 4:57:33 PM (14 years ago)
Author:
ebihara
Message:

#2857:登録時に sfOpenPNEAuthForm の他に MemberForm?ProfileForm? を同時に扱うことを想定し、各フォームの生成と save() メソッドのコールを sfOpenPNEAuthForm からおこなうことで、アクションにフォーム関連処理のコードが必要以上に羅列されていたのを改善

Location:
OpenPNE3/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/apps/pc_frontend/modules/member/actions/actions.class.php

    r7875 r7876  
    6161  public function executeRegisterInput($request)
    6262  {
    63     $this->memberForm = new MemberForm();
    64 
    65     $this->authForm = $this->getUser()->getAuthForm();
    66     $this->authForm->setForRegisterWidgets();
    67 
    68     $this->profileForm = new ProfileForm();
    69     $this->profileForm->setRegisterWidgets();
     63    $this->form = $this->getUser()->getAuthForm();
     64    $this->form->setForRegisterWidgets();
    7065
    7166    if ($request->isMethod('post')) {
    72       $this->memberForm->bind($request->getParameter('member'));
    73       $this->authForm->bind($request->getParameter('auth'));
    74       $this->profileForm->bind($request->getParameter('profile'));
    75 
    76       if ($this->memberForm->isValid() && $this->authForm->isValid() && $this->profileForm->isValid()) {
    77         $memberResult = $this->memberForm->save();
    78         $profileResult = $this->profileForm->save($memberResult->getId());
    79         $formResult = $this->getUser()->register($memberResult->getId(), $this->authForm);
    80         $this->redirectIf(($memberResult && $profileResult && $formResult), $this->getUser()->getRegisterEndAction());
     67      $this->form->bindAll($request);
     68      if ($this->form->isValidAll()) {
     69        $result = $this->getUser()->register($this->form);
     70        $this->redirectIf($result, $this->getUser()->getRegisterEndAction());
    8171      }
    8272    }
  • OpenPNE3/trunk/apps/pc_frontend/modules/member/templates/registerInputSuccess.php

    r7874 r7876  
    11<form action="<?php echo url_for('member/registerInput') ?>" method="post">
    22<table>
    3 <?php echo $memberForm ?>
    4 <?php echo $authForm ?>
    5 <?php echo $profileForm ?>
     3<?php echo $form ?>
    64<tr>
    75<td colspan="2"><input type="submit" value="登録" /></td>
  • OpenPNE3/trunk/plugins/sfOpenPNEAuthLoginIDPlugin/lib/form/sfOpenPNEAuthForm_LoginID.class.php

    r7874 r7876  
    2222    )));
    2323
    24     $this->widgetSchema->setNameFormat('auth[%s]');
    2524    $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('authform_login_id');
     25
     26    parent::configure();
    2627  }
    2728
    2829  public function setForRegisterWidgets()
    2930  {
     31    parent::setForRegisterWidgets();
     32
    3033    $this->validatorSchema['password_confirm'] = new sfValidatorString();
    3134    $this->widgetSchema['password_confirm'] = new sfWidgetFormInputPassword();
  • OpenPNE3/trunk/plugins/sfOpenPNEAuthLoginIDPlugin/modules/loginId/actions/actions.class.php

    r7836 r7876  
    1818  public function executeRegisterEnd($request)
    1919  {
    20     $memberId = $this->getUser()->getMemberId();
    21 
    22     $member = MemberPeer::retrieveByPk($memberId);
     20    $member = $this->getUser()->getMember();
    2321    $member->setIsActive(true);
    2422    $member->save();
  • OpenPNE3/trunk/plugins/sfOpenPNESecurityUserPlugin/lib/form/sfOpenPNEAuthForm.class.php

    r7834 r7876  
    1010abstract class sfOpenPNEAuthForm extends sfForm
    1111{
     12  public $memberForm;
     13  public $profileForm;
     14
     15  public function configure()
     16  {
     17    $this->widgetSchema->setNameFormat('auth[%s]');
     18  }
     19
     20  public function __toString()
     21  {
     22    $result = '';
     23
     24    if ($this->memberForm) {
     25      $result .= $this->memberForm;
     26    }
     27
     28    $result .= parent::__toString();
     29
     30    if ($this->profileForm) {
     31      $result .= $this->profileForm;
     32    }
     33
     34    return $result;
     35  }
     36
    1237  public function setForRegisterWidgets()
    1338  {
     39    $this->memberForm = new MemberForm();
     40    $this->profileForm = new ProfileForm();
     41    $this->profileForm->setRegisterWidgets();
     42  }
     43
     44  public function bindAll($request)
     45  {
     46    if ($this->memberForm) {
     47      $this->memberForm->bind($request->getParameter('member'));
     48    }
     49
     50    if ($this->profileForm) {
     51      $this->profileForm->bind($request->getParameter('profile'));
     52    }
     53
     54      $this->bind($request->getParameter('auth'));
     55  }
     56
     57  public function isValidAll()
     58  {
     59    if ($this->memberForm && !$this->memberForm->isValid()) {
     60      return false;
     61    }
     62
     63    if ($this->profileForm && !$this->profileForm->isValid()) {
     64      return false;
     65    }
     66
     67    return $this->isValid();
    1468  }
    1569}
  • OpenPNE3/trunk/plugins/sfOpenPNESecurityUserPlugin/lib/user/sfOpenPNEAuthContainer.class.php

    r7836 r7876  
    2121   * Registers data to storage container.
    2222   *
     23   * @param  sfForm $form
    2324   * @param  int    $memberId
    24    * @param  sfForm $form
    2525   * @return bool
    2626   */
    2727  abstract public function registerData($memberId, $form);
     28
     29  public function register($form, $memberId = 0)
     30  {
     31    $member = true;
     32    $profile = true;
     33
     34    if ($form->memberForm) {
     35      $member = $form->memberForm->save();
     36      $memberId = $member->getId();
     37    }
     38
     39    if ($form->profileForm) {
     40      $profile = $form->profileForm->save($memberId);
     41    }
     42
     43    $auth = $this->registerData($memberId, $form);
     44
     45    if ($member && $profile && $auth) {
     46      return $memberId;
     47    }
     48
     49    return false;
     50  }
    2851
    2952  /**
  • OpenPNE3/trunk/plugins/sfOpenPNESecurityUserPlugin/lib/user/sfOpenPNESecurityUser.class.php

    r7869 r7876  
    8181  }
    8282
    83   public function register($memberId = null, $form = null)
     83  public function register($form = null, $memberId = 0)
    8484  {
    85     $isRegisterData = $this->getAuthContainer()->registerData($memberId, $form);
    86     if ($isRegisterData) {
     85    $result = $this->getAuthContainer()->register($form, $memberId);
     86    if ($result) {
    8787      $this->setAuthenticated(true);
    88       $this->setAttribute('member_id', $memberId, 'sfOpenPNESecurityUser');
     88      $this->setAttribute('member_id', $result, 'sfOpenPNESecurityUser');
    8989      return true;
    9090    }
Note: See TracChangeset for help on using the changeset viewer.