Changeset 50

Show
Ignore:
Timestamp:
05/24/08 16:10:19 (2 years ago)
Author:
nperriault
Message:
  • migrated user registration form to sf1.1 form
  • templating
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/apps/main/config/routing.yml

    r46 r50  
    273273  param: { module: sfGuardAuth, action: register } 
    274274 
     275user_register_done: 
     276  url:   /register/done 
     277  param: { module sfGuardAuth, action: registerDone } 
     278 
    275279user_password_change: 
    276280  url:   /profile/password/change 
  • trunk/apps/main/modules/applications/templates/_filterForm.php

    r2 r50  
    1 <?php echo form_tag('@application_home', 'method=get id=country_form') ?
     1<form action="<?php echo url_for('@application_home') ?>" method="get" id="country_form"
    22  <p> 
    33    <?php echo label_for('country', __('Filter by country')) ?> 
     
    1414    <?php echo submit_tag(__('Filter')) ?> 
    1515  </p> 
    16 <?php echo end_form() ?
     16</form
  • trunk/apps/main/modules/applications/templates/_form.php

    r2 r50  
    1010</p> 
    1111 
    12 <?php echo form_tag($form_route, 'multipart=true') ?
     12<form action="<?php echo url_for($form_route) ?>" method="post" enctype="multipart/form-data"
    1313  <div class="fiftypercent"> 
    1414    <fieldset> 
     
    8383    </p> 
    8484  </div> 
    85 <?php echo end_form() ?
     85</form
  • trunk/apps/main/modules/applications/templates/connectAsCompanySuccess.php

    r2 r50  
    3232</p> 
    3333 
    34 <?php echo form_tag($sf_data->getRaw('form_action')) ?
     34<form action="<?php echo url_for($sf_data->getRaw('form_action')) ?>" method="post"
    3535  <div class="fiftypercent"> 
    3636    <fieldset> 
     
    8080    </p> 
    8181  </div> 
    82 <?php echo end_form() ?
     82</form
  • trunk/apps/main/modules/applications/templates/connectAsDeveloperSuccess.php

    r2 r50  
    3636</p> 
    3737 
    38 <?php echo form_tag($sf_data->getRaw('form_action')) ?
     38<form action="<?php echo url_for($sf_data->getRaw('form_action')) ?>" method="post"
    3939  <div class="fiftypercent"> 
    4040    <fieldset> 
     
    7373    </p> 
    7474  </div> 
    75 <?php echo end_form() ?
     75</form
  • trunk/apps/main/modules/sfGuardAuth/actions/actions.class.php

    r48 r50  
    222222  } 
    223223   
    224   public function executeRegister(
     224  public function executeRegister(sfWebRequest $request
    225225  { 
    226226    if ($this->getUser()->isAuthenticated()) 
     
    229229    } 
    230230     
    231     if ($this->getRequest()->getMethod() !== sfRequest::POST) 
    232     { 
     231    $this->form = new RegisterForm(); 
     232     
     233    if (!$request->isMethod('post') or !$this->form->bindAndSave($request->getParameter('user'))) 
     234    { 
     235      return sfView::SUCCESS; // redisplay form with errors 
     236    } 
     237     
     238    // At this point we got a valid form and a created sfGuardUser object 
     239    $user = $this->form->getObject(); 
     240     
     241    // Create activation entry 
     242    $activation = new Activation(); 
     243    $activation->setUserId($user->getId()); 
     244    $activation->setHash(md5(rand(100000, 999999))); 
     245    $activation->save(); 
     246     
     247    // Send user an activation email 
     248    $this->getRequest()->setAttribute('user', $user); 
     249    $this->getRequest()->setAttribute('activation', $activation); 
     250    $mailSent = $this->sendSwiftSmtpPlainMail('mail', 'register', 
     251                                              $user->getEmail(), 
     252                                              $this->__('Please confirm your Symfonians account creation request')); 
     253     
     254    // If mail sending failed,  
     255    if (!$mailSent) 
     256    { 
     257      $this->getRequest()->setError('errors', $this->__('We were unable to send you an activation email. Registration process failed.')); 
     258      $activation->delete(); 
     259      $user->delete(); 
    233260      return sfView::SUCCESS; 
    234261    } 
    235      
    236     try 
    237     { 
    238       $user = new sfGuardUser(); 
    239       $user->setUsername($this->getRequestParameter('username')); 
    240       $user->setEmail($this->getRequestParameter('email')); 
    241       $user->setPassword($this->getRequestParameter('password')); 
    242       $user->setIsActive(false); 
    243       $user->save(); 
    244        
    245       $activation = new Activation(); 
    246       $activation->setUserId($user->getId()); 
    247       $activation->setHash(md5(rand(100000, 999999))); 
    248       $activation->save(); 
    249        
    250       $this->getRequest()->setAttribute('user', $user); 
    251       $this->getRequest()->setAttribute('activation', $activation); 
    252        
    253       $mailSent = $this->sendSwiftSmtpPlainMail('mail', 'register', 
    254                                                 $user->getEmail(), 
    255                                                 $this->__('Please confirm your Symfonians account creation request')); 
    256        
    257       if (!$mailSent) 
    258       { 
    259         $this->getRequest()->setError('errors', $this->__('We were unable to send you your activation email. Registration process failed.')); 
    260         $activation->delete(); 
    261         $user->delete(); 
    262         return sfView::SUCCESS; 
    263       } 
    264       $this->getUser()->setFlash('notice', sfContext::getInstance()->getI18N() 
    265                       ->__('A confirmation mail has been sent to %mail%', 
    266                            array('%mail%' => $user->getEmail()))); 
    267       $this->forward('sfGuardAuth', 'registerDone'); 
    268     } 
    269     catch (sfStopException $e) 
    270     { 
    271       return sfView::HEADER_ONLY; 
    272     } 
    273     catch (Exception $e) 
    274     { 
    275       $this->getRequest()->setError('errors', $this->__('Unable to register your account')); 
    276       sfContext::getInstance()->getLogger()->err('Blocking error at account registration time: '.$e->getMessage()); 
    277       return sfView::SUCCESS; 
    278     } 
     262    $this->getUser()->setFlash('notice', $this->__('A confirmation mail has been sent to %mail%', 
     263                                                   array('%mail%' => $user->getEmail()))); 
     264    $this->redirect('@user_register_done'); 
    279265  } 
    280266   
  • trunk/apps/main/modules/sfGuardAuth/templates/registerSuccess.php

    r2 r50  
    2727</p> 
    2828 
    29 <?php echo form_tag('@user_register') ?
     29<form action="<?php echo url_for('@user_register') ?>" method="post"
    3030  <div class="fiftypercent"> 
    3131    <fieldset> 
    3232      <legend><?php echo __('Account informations') ?></legend> 
     33      <?php echo $form ?> 
     34      <?php /* 
    3335      <div class="form-row required"> 
    3436        <label for="username"><?php echo __('Username') ?></label> 
     
    5456        <?php echo form_error('password2') ?> 
    5557      </div> 
     58      */?> 
    5659    </fieldset> 
    5760  </div> 
     
    6063      <legend><?php echo __('Security') ?></legend> 
    6164      <div class="form-row required"> 
     65        <?php /* 
    6266        <?php echo label_for('captcha', __('Security code')) ?> 
    6367        <?php echo input_tag('captcha', null, 'id=captcha style=width:100px'); ?> 
     
    6872          <?php echo __('This codes aims at detecting if you are a bot or a human person.') ?> 
    6973        </p> 
     74        */ ?> 
    7075      </div> 
    7176    </fieldset> 
     
    7479    </p> 
    7580    <p style="text-align:center"> 
    76       <?php echo submit_tag(__('Click here to register your account')) ?
     81      <input type="submit" value="<?php echo __('Click here to register your account') ?>" /
    7782    </p> 
    7883  </div> 
  • trunk/lib/form/BaseFormPropel.class.php

    r48 r50  
    11<?php 
    2  
    32/** 
    43 * Project form base class. 
     
    1110  public function setup() 
    1211  { 
     12    sfWidgetFormSchema::setDefaultFormFormatterName('list'); 
    1313  } 
    1414} 
  • trunk/plugins

    • Property svn:externals changed from
      sfPropelAlternativeSchemaPlugin http://svn.symfony-project.com/plugins/sfPropelAlternativeSchemaPlugin
      sfWebBrowserPlugin http://svn.symfony-project.com/plugins/sfWebBrowserPlugin
      sfPagerNavigationPlugin http://svn.symfony-project.com/plugins/sfPagerNavigationPlugin
      sfFeed2Plugin http://svn.symfony-project.com/plugins/sfFeed2Plugin
      sfPropelMigrationsLightPlugin -r7087 http://svn.symfony-project.com/plugins/sfPropelMigrationsLightPlugin/trunk/
      sfSwiftPlugin -r6447 http://svn.symfony-project.com/plugins/sfSwiftPlugin/trunk
      sfLucenePlugin http://svn.symfony-project.com/plugins/sfLucenePlugin/branches/1.1
      sfGuardPlugin http://svn.symfony-project.com/plugins/sfGuardPlugin/branches/1.1
      to
      sfPropelAlternativeSchemaPlugin http://svn.symfony-project.com/plugins/sfPropelAlternativeSchemaPlugin
      sfWebBrowserPlugin http://svn.symfony-project.com/plugins/sfWebBrowserPlugin
      sfPagerNavigationPlugin http://svn.symfony-project.com/plugins/sfPagerNavigationPlugin
      sfFeed2Plugin http://svn.symfony-project.com/plugins/sfFeed2Plugin
      sfPropelMigrationsLightPlugin -r7087 http://svn.symfony-project.com/plugins/sfPropelMigrationsLightPlugin/trunk/
      sfSwiftPlugin -r6447 http://svn.symfony-project.com/plugins/sfSwiftPlugin/trunk
      sfLucenePlugin http://svn.symfony-project.com/plugins/sfLucenePlugin/branches/1.1
      sfGuardPlugin http://svn.symfony-project.com/plugins/sfGuardPlugin/branches/1.1
      sfFormExtraPlugin http://svn.symfony-project.com/plugins/sfFormExtraPlugin/