Changeset 56

Show
Ignore:
Timestamp:
05/30/08 09:40:43
Author:
nperriault
Message:

trunk still broken at this time, but work has progressed:

  • updated sfGuardAuth local module to use 1.1 forms
  • added FormTemplateListener? to listen for filter_parameters event, and handle passed sfForm object instances
  • moved from cryptographp to recpatcha
  • moved sfValidatorBlacklist to sfFormExtraPlugin
  • lib/ folder layout
  • removed jQueryHelper (unused)
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/apps/main/config/mainConfiguration.class.php

    r48 r56  
    55  public function configure() 
    66  { 
     7    require_once(dirname(__FILE__).'/../lib/FormTemplateListener.class.php'); 
     8    FormTemplateListener::register($this->dispatcher); 
    79  } 
    810} 
  • trunk/apps/main/config/settings.yml

    r49 r56  
    77dev: 
    88  .settings: 
    9     error_reporting:        <?php echo E_ALL | E_STRICT."\n" ?> 
     9    error_reporting:        <?php echoln(E_ALL | E_STRICT) ?> 
    1010    web_debug:              on 
    1111    cache:                  off 
     
    1515search: 
    1616  .settings: 
    17     error_reporting:        <?php echo E_ALL | E_STRICT."\n" ?> 
     17    error_reporting:        <?php echoln(E_ALL | E_STRICT) ?> 
    1818    web_debug:              off 
    1919    cache:                  off 
     
    2323staging: 
    2424  .settings: 
    25     error_reporting:        <?php echo E_ALL | E_STRICT."\n" ?> 
     25    error_reporting:        <?php echoln(E_ALL | E_STRICT) ?> 
    2626    web_debug:              on 
    2727    cache:                  on 
     
    3131test: 
    3232  .settings: 
    33     error_reporting:        <?php echo E_ALL | E_STRICT & ~E_NOTICE."\n" ?> 
     33    error_reporting:        <?php echoln(E_ALL | E_STRICT & ~E_NOTICE) ?> 
    3434    cache:                  on 
    3535    web_debug:              off 
     
    6666    enabled_modules:        [cryptographp, sfGuardAuth, sfLucene] 
    6767    charset:                utf-8 
     68    csrf_secret:            symf0n14n5 
  • trunk/apps/main/modules/applications/actions/actions.class.php

    r48 r56  
    99{ 
    1010 
    11   public function executeAdd() 
    12   { 
    13     $this->application = new Application(); 
    14     if ($this->getRequest()->getMethod() == sfRequest::POST) 
    15     { 
    16       $this->updateFromRequest(); 
    17       parent::purgeObjectRelatedCache($this->application); 
     11  public function executeAdd(sfWebRequest $request) 
     12  { 
     13    $this->form = new ApplicationForm(); 
     14     
     15    if ($request->isMethod('post') && $this->form->bindAndSave($request->getParameter('application'))) 
     16    { 
     17      //$this->updateFromRequest(); 
     18      parent::purgeObjectRelatedCache($this->form->getObject()); 
    1819      $this->getUser()->setFlash('notice', $this->__('Application added')); 
    1920      $this->getUser()->setAttribute('from_app_creation', true, 'symfonians'); 
     
    2223  } 
    2324 
    24   public function executeCountries(
     25  public function executeCountries(sfWebRequest $request
    2526  { 
    2627    $this->countries = ApplicationPeer::retrieveCountriesWithCount(); 
    2728  } 
    2829 
    29   public function executeEdit(
     30  public function executeEdit(sfWebRequest $request
    3031  { 
    3132    $this->application = $this->getFromSlug(); 
     
    3738    } 
    3839 
    39     if ($this->getRequest()->getMethod() == sfRequest::POST
     40    if ($request->isMethod('post')
    4041    { 
    4142      $this->updateFromRequest(); 
     
    4748  } 
    4849 
    49   public function executeEditCompanyConnection(
     50  public function executeEditCompanyConnection(sfWebRequest $request
    5051  { 
    5152    $this->application = $this->getFromSlug(); 
     
    5354    $this->forward404Unless($this->connection, 'ApplicationCompany not found'); 
    5455 
    55     if ($this->getRequest()->getMethod() == sfRequest::POST
     56    if ($request->isMethod('post')
    5657    { 
    5758      $this->updateCompanyConnectionFromRequest(); 
     
    6768  } 
    6869 
    69   public function executeEditDeveloperConnection(
     70  public function executeEditDeveloperConnection(sfWebRequest $request
    7071  { 
    7172    $this->application = $this->getFromSlug(); 
     
    7374    $this->forward404Unless($this->connection, 'ApplicationDeveloper not found'); 
    7475 
    75     if ($this->getRequest()->getMethod() == sfRequest::POST
     76    if ($request->isMethod('post')
    7677    { 
    7778      $this->updateDeveloperConnectionFromRequest(); 
     
    8788  } 
    8889 
    89   public function executeConnectAsCompany(
     90  public function executeConnectAsCompany(sfWebRequest $request
    9091  { 
    9192    $this->connection = new ApplicationCompany(); 
     
    101102 
    102103    // Form has been submitted 
    103     if ($this->getRequest()->getMethod() == sfRequest::POST
     104    if ($request->isMethod('post')
    104105    { 
    105106      $this->updateCompanyConnectionFromRequest(); 
     
    113114  } 
    114115 
    115   public function executeConnectAsDeveloper(
     116  public function executeConnectAsDeveloper(sfWebRequest $request
    116117  { 
    117118    $this->connection = new ApplicationDeveloper(); 
     
    130131 
    131132    // Form has been submitted 
    132     if ($this->getRequest()->getMethod() == sfRequest::POST
     133    if ($request->isMethod('post')
    133134    { 
    134135      $this->updateDeveloperConnectionFromRequest(); 
     
    142143  } 
    143144 
    144   public function executeDelete(
     145  public function executeDelete(sfWebRequest $request
    145146  { 
    146147    $this->application = $this->getFromSlug(); 
     
    158159  } 
    159160 
    160   public function executeDetails(
     161  public function executeDetails(sfWebRequest $request
    161162  { 
    162163    $this->application = $this->getFromSlug(); 
     
    194195  } 
    195196 
    196   public function executeHome(
     197  public function executeHome(sfWebRequest $request
    197198  { 
    198199    $pager_route_params = array(); 
     
    246247  } 
    247248 
    248   public function executePromote(
     249  public function executePromote(sfWebRequest $request
    249250  { 
    250251    $this->application = $this->getFromSlug(); 
     
    261262  } 
    262263 
    263   public function executeTags(
     264  public function executeTags(sfWebRequest $request
    264265  { 
    265266    $c = new Criteria; 
  • trunk/apps/main/modules/applications/templates/_filterForm.php

    r50 r56  
    11<form action="<?php echo url_for('@application_home') ?>" method="get" id="country_form"> 
     2  <?php /* 
    23  <p> 
    3     <?php echo label_for('country', __('Filter by country')) ?
     4    <label for="country"><?php echo __('Filter by country') ?></label
    45    <?php echo select_tag('country', 
    56                          options_for_select($countries, 
     
    1415    <?php echo submit_tag(__('Filter')) ?> 
    1516  </p> 
     17  */ ?> 
    1618</form> 
  • trunk/apps/main/modules/applications/templates/_form.php

    r50 r56  
    1 <?php use_helper('Object', 'Validation', 'jQueryDate') ?> 
     1<?php use_helper('Object', 'Validation') ?> 
    22 
    33<?php echo breadcrumb(array(array(__('Applications'), '@application_home'), 
     
    1414    <fieldset> 
    1515      <legend><?php echo __('Application informations') ?></legend> 
     16      <?php echo $form ?> 
     17      <?php /* 
    1618      <div class="form-row required"> 
    1719        <label for="name"><?php echo __('Application name') ?></label> 
     
    3436        <?php echo form_error('application[tags]') ?> 
    3537      </div> 
     38      */ ?> 
    3639    </fieldset> 
    3740  </div> 
     
    3942    <fieldset> 
    4043      <legend><?php echo __('Other informations') ?></legend> 
     44      <?php /* 
    4145      <div class="form-row"> 
    4246        <label for="country"><?php echo __('Country') ?></label> 
     
    7680        <?php echo form_error('application[released_at]') ?> 
    7781      </div> 
     82      */ ?> 
    7883    </fieldset> 
    7984  </div> 
    8085  <div class="form-row" style="text-align:center;clear:left;"> 
    8186    <p> 
    82       <?php echo submit_tag($submit_label) ?
     87      <input type="submit" value="<?php echo $submit_label ?>" /
    8388    </p> 
    8489  </div> 
  • trunk/apps/main/modules/applications/templates/addSuccess.php

    r2 r56  
    55 
    66<?php include_partial('applications/form', 
    7                       array('application'      => $application, 
     7                      array('application'  => $application, 
     8                            'form'         => $form, 
    89                            'title'        => $page_title, 
    910                            'form_route'   => '@application_add', 
  • trunk/apps/main/modules/mail/actions/actions.class.php

    r2 r56  
    99{ 
    1010   
    11   public function executeContact(
     11  public function executeContact(sfWebRequest $request
    1212  { 
    13     $this->message = $this->getRequest()->getAttribute('message'); 
     13    $this->message = $request->getAttribute('message'); 
    1414  } 
    1515   
    16   public function executeForgotPassword(
     16  public function executeForgotPassword(sfWebRequest $request
    1717  { 
    18     $this->password = $this->getRequest()->getAttribute('password'); 
     18    $this->password = $request->getAttribute('password'); 
    1919  } 
    2020   
    21   public function executeRegister(
     21  public function executeRegister(sfWebRequest $request
    2222  { 
    23     $this->user = $this->getRequest()->getAttribute('user'); 
    24     $this->activation = $this->getRequest()->getAttribute('activation'); 
     23    $this->user = $request->getAttribute('user'); 
     24    $this->activation = $request->getAttribute('activation'); 
    2525  } 
    2626   
    27   public function executeResendActivation(
     27  public function executeResendActivation(sfWebRequest $request
    2828  { 
    29     $this->activation = $this->getRequest()->getAttribute('activation'); 
     29    $this->activation = $request->getAttribute('activation'); 
    3030  } 
    3131   
    32   public function executeCompanyContact(
     32  public function executeCompanyContact(sfWebRequest $request
    3333  { 
    3434    $this->user = $this->getUser()->getGuardUser(); 
    35     $this->message = $this->getRequest()->getAttribute('message'); 
    36     $this->company = $this->getRequest()->getAttribute('company'); 
     35    $this->message = $request->getAttribute('message'); 
     36    $this->company = $request->getAttribute('company'); 
    3737  } 
    3838   
    39   public function executePersonContact(
     39  public function executePersonContact(sfWebRequest $request
    4040  { 
    4141    $this->user = $this->getUser()->getGuardUser(); 
    42     $this->recipient = $this->getRequest()->getAttribute('recipient'); 
    43     $this->message = $this->getRequest()->getAttribute('message'); 
     42    $this->recipient = $request->getAttribute('recipient'); 
     43    $this->message = $request->getAttribute('message'); 
    4444  } 
    4545   
    46   public function executeRecommendationReceived(
     46  public function executeRecommendationReceived(sfWebRequest $request
    4747  { 
    48     $this->recommender = $this->getRequest()->getAttribute('recommender'); 
    49     $this->recommended = $this->getRequest()->getAttribute('recommended'); 
    50     $this->recommendation = $this->getRequest()->getAttribute('recommendation'); 
     48    $this->recommender = $request->getAttribute('recommender'); 
     49    $this->recommended = $request->getAttribute('recommended'); 
     50    $this->recommendation = $request->getAttribute('recommendation'); 
    5151  } 
    5252   
  • trunk/apps/main/modules/sfGuardAuth/actions/actions.class.php

    r54 r56  
    1010{ 
    1111 
     12  /** 
     13   * Activates a user 
     14   * 
     15   * @param  sfWebRequest $request 
     16   */ 
    1217  public function executeActivate(sfWebRequest $request) 
    1318  { 
     
    222227  } 
    223228   
     229  /** 
     230   * Registers a new member 
     231   * 
     232   * @param     sfWebRequest $request 
     233   * @sf_param  array  user  Member form informations 
     234   */ 
    224235  public function executeRegister(sfWebRequest $request) 
    225236  { 
     
    278289  } 
    279290   
     291  /** 
     292   * Resend activation mail 
     293   * 
     294   * @param     sfWebRequest $request 
     295   * @sf_param  array   user                       User form fields data 
     296   * @sf_param  string  recaptcha_challenge_field  Recaptcha challenge 
     297   * @sf_param  string  recaptcha_response_field   Recaptcha response 
     298   * @see       sfValidatorReCaptcha 
     299   */ 
    280300  public function executeResendActivation(sfWebRequest $request) 
    281301  { 
     
    284304    if ($request->isMethod('post')) 
    285305    { 
    286       // Recaptcha parameters 
    287       $captcha = array( 
    288         'recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 
    289         'recaptcha_response_field'  => $request->getParameter('recaptcha_response_field'), 
    290       ); 
    291       $params = array_merge($request->getParameter('user', array()), array('captcha' => $captcha)); 
    292        
    293       $this->form->bind($params); 
     306      $this->form->bindFromRequest($request); 
    294307       
    295308      if ($this->form->isValid()) 
    296309      { 
    297         $user = sfGuardUserPeer::retrieveByEmail($params['email']); 
     310        $user = sfGuardUserPeer::retrieveByEmail($this->form->getValue('email')); 
    298311        $this->forward404Unless($user); // theoricaly, can't happen 
    299312         
     
    311324          return sfView::SUCCESS; 
    312325        } 
     326         
    313327        $this->getUser()->setFlash('notice', $this->__('Your activation mail has been sent to '.$user->getEmail())); 
    314328        $this->redirect('@homepage'); 
     
    318332   
    319333  public function handleErrorChangePassword() 
    320   { 
    321     return sfView::SUCCESS; 
    322   } 
    323    
    324   public function handleErrorRegister() 
    325334  { 
    326335    return sfView::SUCCESS; 
  • trunk/apps/main/modules/sfGuardAuth/templates/registerSuccess.php

    r54 r56  
    3131    <fieldset> 
    3232      <legend><?php echo __('Account informations') ?></legend> 
     33      <?php echo $form->renderGlobalErrors() ?> 
    3334      <?php echo $form['username']->renderRow() ?> 
    3435      <?php echo $form['email']->renderRow() ?> 
  • trunk/apps/main/modules/sfGuardAuth/templates/resendActivationSuccess.php

    r54 r56  
    2424      <?php echo $form['email']->renderRow() ?> 
    2525      <span class="form-help"><?php echo __('Enter the email address you entered when you have registered here.') ?></span> 
    26       <?php echo $form['captcha']->renderRow() ?> 
    27       <p class="form-help"> 
    28         <?php echo __('This codes aims at detecting if you are a bot or a human person.') ?> 
    29       </p> 
     26      <?php if (true === sfConfig::get('app_recaptcha_enabled')): ?> 
     27        <?php echo $form['captcha']->renderRow() ?> 
     28        <p class="form-help"> 
     29          <?php echo __('This codes aims at detecting if you are a bot or a human person.') ?> 
     30        </p> 
     31      <?php endif; ?> 
    3032      <p> 
    3133        <?php echo $form['_csrf_token'] ?> 
  • trunk/apps/main/templates/_messages.php

    r54 r56  
    1 <?php if ($sf_context->has('form') && $form = $sf_context->get('form') && $sf_context->get('form')->hasGlobalErrors()): ?> 
     1<?php if (!is_null($activeForm) && $activeForm->hasGlobalErrors()): ?> 
    22<div class="form-errors"> 
    33  <h4><?php echo __('Errors have been encountered') ?></h4> 
    4   <?php echo $sf_context->get('form')->renderGlobalErrors() ?> 
     4  <?php echo $activeForm->renderGlobalErrors() ?> 
    55</div> 
    66<?php endif; ?> 
  • trunk/apps/main/templates/layout.php

    r48 r56  
    3838      <?php include_partial('global/menu') ?> 
    3939    </div> 
    40     <?php include_partial('global/messages') ?> 
     40    <?php include_partial('global/messages', array('activeForm' => $activeForm)) ?> 
    4141    <div id="main"> 
    4242      <div class="inner"> 
  • trunk/config/app.yml-dist

    r6 r56  
    4242   
    4343  googleanalytics: 
    44     tracker_id:          <your_google_analytics_tracker_id_here> 
     44    tracker_id:          ~ # create an account here: http://www.google.com/analytics/  
    4545   
    4646  googlemaps: 
    47     api_key:             <your_google_api_key_here> 
     47    api_key:             ~ # get an API key here: code.google.com/apis/maps/signup.html 
    4848 
    4949  homepage: 
     
    168168        default:         default_avatar48.jpg 
    169169 
     170  recaptcha:             # Get an API key at http://recaptcha.net/ 
     171    enabled:             on # set to off to disable captcha (HAZARDOUS) 
     172    private_key:         ~  # put your recatcha private api key here 
     173    public_key:          ~  # put your recatcha public api key here 
     174 
    170175  recommendations: 
    171176    max_items:           8 
     
    180185  yahoo_geocoding: 
    181186    api_gateway:         "http://local.yahooapis.com/MapsService/V1/geocode?" 
    182     api_key:             <your_yahoo_api_key_here> 
     187    api_key:             ~ # get an API key here: http://developer.yahoo.com/wsregapp/ 
  • trunk/lib/form/BaseFormPropel.class.php

    r52 r56  
    1111  { 
    1212    sfWidgetFormSchema::setDefaultFormFormatterName('div'); 
    13     self::enableCSRFProtection('symf0n14n5'); 
    1413  } 
    1514} 
  • trunk/lib/form/application/ApplicationForm.class.php

    r52 r56  
    11<?php 
    2  
    32/** 
    43 * Application form. 
     
    1211  public function configure() 
    1312  { 
     13    unset($this['created_at'], $this['updated_at']); 
    1414  } 
    1515} 
  • trunk/lib/form/user/RegisterForm.class.php

    r53 r56  
    3636        new sfValidatorString(array('min_length' => 3, 'max_length' => 20)), 
    3737        new sfValidatorRegex(array('pattern' => '/^[a-zA-Z]([a-zA-Z0-9._-]+)$/'), array('invalid' => 'Name "%value%" contains forbidden characters')), 
    38         new sfValidatorBlacklist(array('choices' => self::$forbidden_names), array('invalid' => 'Name "%value%" is blacklisted')), 
     38        new sfValidatorBlacklist(array('forbidden_values' => self::$forbidden_names), array('invalid' => 'Name "%value%" is blacklisted')), 
    3939      )), 
    4040      'email'     => new sfValidatorAnd(array( 
  • trunk/lib/form/user/ResendActivationForm.class.php

    r54 r56  
    44 * 
    55 */ 
    6 class ResendActivationForm extends sfForm  
     6class ResendActivationForm extends sfFormReCaptcha  
    77{ 
    88  public function configure() 
    99  { 
    10     self::enableCSRFProtection('symf0n14n5'); 
    11      
    1210    // Widgets 
    1311    $this->widgetSchema['email'] = new sfWidgetFormInput(); 
    14     $this->widgetSchema['captcha'] = new sfWidgetFormReCaptcha(array('public_key' => sfConfig::get('app_recaptcha_public_key'))); 
     12    if (true === sfConfig::get('app_recaptcha_enabled')) 
     13    { 
     14      $this->widgetSchema['captcha'] = new sfWidgetFormReCaptcha(array('public_key' => sfConfig::get('app_recaptcha_public_key'))); 
     15    } 
    1516     
    1617    // Validators 
     
    2021                                  array('invalid' => 'This email has never been registered here, or is already activated.')), 
    2122    )); 
    22     $this->validatorSchema['captcha'] = new sfValidatorReCaptcha(array('private_key' => sfConfig::get('app_recaptcha_private_key'))); 
     23     
     24    if (true === sfConfig::get('app_recaptcha_enabled')) 
     25    { 
     26      $this->validatorSchema['captcha'] = new sfValidatorReCaptcha(array('private_key' => sfConfig::get('app_recaptcha_private_key'))); 
     27    } 
    2328     
    2429    $this->widgetSchema->setNameFormat('user[%s]'); 
  • trunk/lib/form/user/SigninForm.class.php

    r54 r56  
    11<?php 
    2  
     2/** 
     3 * Sign in form 
     4 * 
     5 */ 
    36class SigninForm extends sfGuardFormSignin  
    47{ 
    5   public function setup() 
    6   { 
    7     sfWidgetFormSchema::setDefaultFormFormatterName('div'); 
    8     self::enableCSRFProtection('symf0n14n5'); 
    9   } 
    10    
    118  public function configure() 
    129  {