Development

Changeset 28839 for plugins

You must first sign up to be able to contribute.

Changeset 28839 for plugins

Show
Ignore:
Timestamp:
03/28/10 19:33:57 (3 years ago)
Author:
fizyk
Message:

fix in schema.yml and added reCaptcha support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfForkedDoctrineApplyPlugin/trunk/config/doctrine/schema.yml

    r28651 r28839  
    1818    #TODO! Should be used by task that will erase all validate fields created x days ago and not used. 
    1919    validate_at: 
    20       type: datetime 
     20      type: timestamp 
    2121    validate: 
    2222      type: string(33) 
  • plugins/sfForkedDoctrineApplyPlugin/trunk/lib/action/sfApplyActionsLibrary.class.php

    r28770 r28839  
    1717        if( $request->isMethod('post') ) 
    1818        { 
    19             //Extracting parameters from sent sfApplyApply form 
    20             $this->form->bind($request->getParameter('sfApplyApply')); 
     19            //gathering form request in one array 
     20            $formValues = $request->getParameter('sfApplyApply'); 
     21            if(sfConfig::get('app_recaptcha_enabled') ) 
     22            { 
     23                $captcha = array( 
     24                  'recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 
     25                  'recaptcha_response_field'  => $request->getParameter('recaptcha_response_field'), 
     26                ); 
     27                //Adding captcha to form array 
     28                $formValues = array_merge( $formValues, array('captcha' => $captcha)  ); 
     29            } 
     30            //binding request form parameters with form 
     31            $this->form->bind($formValues); 
    2132            if ($this->form->isValid()) 
    2233            { 
     
    5364        { 
    5465            $this->redirect( 'sfApply/reset' ); 
    55 //            $guardUser = $this->getUser()->getGuardUser(); 
    56 //            $this->forward404Unless($guardUser); 
    57 //            return $this->resetRequestBody($guardUser); 
    5866        } 
    5967        else 
     
    6270            if ($request->isMethod('post')) 
    6371            { 
    64                 $this->form->bind($request->getParameter('sfApplyResetRequest')); 
     72                //gathering form request in one array 
     73                $formValues = $request->getParameter('sfApplyResetRequest'); 
     74                if(sfConfig::get('app_recaptcha_enabled') ) 
     75                { 
     76                    $captcha = array( 
     77                      'recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 
     78                      'recaptcha_response_field'  => $request->getParameter('recaptcha_response_field'), 
     79                    ); 
     80                    //Adding captcha to form array 
     81                    $formValues = array_merge( $formValues, array('captcha' => $captcha)  ); 
     82                } 
     83                //binding request form parameters with form 
     84                $this->form->bind($formValues); 
    6585                if ($this->form->isValid()) 
    6686                { 
     
    97117        // Note that this only works if you set foreignAlias and 
    98118        // foreignType correctly 
    99         $sfGuardUser = Doctrine_Query::create()-> 
    100         from("sfGuardUser u")-> 
    101         innerJoin("u.Profile p with p.validate = ?", $validate)-> 
    102         fetchOne(); 
     119        $sfGuardUser = Doctrine_Query::create() 
     120            ->from("sfGuardUser u") 
     121            ->innerJoin("u.Profile p with p.validate = ?", $validate) 
     122            ->fetchOne(); 
    103123        if (!$sfGuardUser) 
    104124        { 
  • plugins/sfForkedDoctrineApplyPlugin/trunk/lib/form/doctrine/PluginsfGuardUserProfileBasisForm.class.php

    r28651 r28839  
    1111abstract class PluginsfGuardUserProfileBasisForm extends BasesfGuardUserProfileBasisForm 
    1212{ 
     13    public function setup() 
     14    { 
     15        parent::setup(); 
     16        sfProjectConfiguration::getActive()->loadHelpers(array('I18N')); 
     17         
     18    } 
    1319} 
  • plugins/sfForkedDoctrineApplyPlugin/trunk/lib/form/sfApplyApplyForm.class.php

    r28651 r28839  
    113113        } 
    114114 
     115        //Include captcha if enabled 
     116        if ($this->isCaptchaEnabled() ) 
     117        { 
     118            $this->addCaptcha(); 
     119        } 
     120 
    115121        $this->validatorSchema->setPostValidator( new sfValidatorAnd($postValidators) ); 
    116122    } 
     
    144150    } 
    145151 
     152    public function isCaptchaEnabled() 
     153    { 
     154        return sfConfig::get('app_recaptcha_enabled'); 
     155    } 
     156 
     157    public function addCaptcha() 
     158    { 
     159        $this->widgetSchema['captcha'] = new sfWidgetFormReCaptcha(array( 
     160          'public_key' => sfConfig::get('app_recaptcha_public_key') 
     161        )); 
     162 
     163        $this->validatorSchema['captcha'] = new sfValidatorReCaptcha(array( 
     164          'private_key' => sfConfig::get('app_recaptcha_private_key') 
     165        )); 
     166        $this->validatorSchema['captcha'] 
     167            ->setMessage('captcha', __('The captcha is not valid (%error%).', array(), 'sfForkedApply')) 
     168            ->setMessage('server_problem', __('Unable to check the captcha from the server (%error%).', array(), 'sfForkedApply')); 
     169    } 
     170 
    146171 
    147172    function removeFields() 
  • plugins/sfForkedDoctrineApplyPlugin/trunk/lib/form/sfApplyResetRequestForm.class.php

    r28651 r28839  
    44class sfApplyResetRequestForm extends sfForm 
    55{ 
    6   public function configure() 
    7   { 
    8     parent::configure(); 
     6    public function configure() 
     7    { 
     8        parent::configure(); 
     9        sfProjectConfiguration::getActive()->loadHelpers(array('I18N')); 
    910 
    10     $this->setWidget('username_or_email', 
    11       new sfWidgetFormInput( array(), array('maxlength' => 100))); 
     11        $this->setWidget('username_or_email', 
     12          new sfWidgetFormInput( array(), array('maxlength' => 100))); 
    1213 
    13     $this->setValidator('username_or_email', 
    14       new sfValidatorOr( array( 
    15           new sfValidatorAnd( array(  
    16               new sfValidatorString( array( 
    17                   'required' => true, 
    18                   'trim' => true, 
    19                   'min_length' => 4, 
    20                   'max_length' => 16 ) ), 
    21               new sfValidatorDoctrineChoice( array( 
    22                   'model' => 'sfGuardUser', 
    23                   'column' => 'username' ), 
    24                       array( "invalid" => "There is no such user.")))), 
    25           new sfValidatorEmail(array('required' => true) ) ) 
    26     )); 
     14        $this->setValidator('username_or_email', 
     15          new sfValidatorOr( array( 
     16              new sfValidatorAnd( array( 
     17                  new sfValidatorString( array( 
     18                      'required' => true, 
     19                      'trim' => true, 
     20                      'min_length' => 4, 
     21                      'max_length' => 16 ) ), 
     22                  new sfValidatorDoctrineChoice( array( 
     23                      'model' => 'sfGuardUser', 
     24                      'column' => 'username' ), 
     25                          array( "invalid" => "There is no such user.")))), 
     26              new sfValidatorEmail(array('required' => true) ) ) 
     27        )); 
    2728         
    28     $this->widgetSchema->setNameFormat('sfApplyResetRequest[%s]'); 
    29     $this->widgetSchema->setFormFormatterName('list'); 
    30   } 
     29        $this->widgetSchema->setNameFormat('sfApplyResetRequest[%s]'); 
     30        $this->widgetSchema->setFormFormatterName('list'); 
     31 
     32        //Include captcha if enabled 
     33        if ($this->isCaptchaEnabled() ) 
     34        { 
     35            $this->addCaptcha(); 
     36        } 
     37    } 
     38 
     39    public function isCaptchaEnabled() 
     40    { 
     41        return sfConfig::get('app_recaptcha_enabled'); 
     42    } 
     43 
     44    public function addCaptcha() 
     45    { 
     46        $this->widgetSchema['captcha'] = new sfWidgetFormReCaptcha(array( 
     47          'public_key' => sfConfig::get('app_recaptcha_public_key') 
     48        )); 
     49 
     50        $this->validatorSchema['captcha'] = new sfValidatorReCaptcha(array( 
     51          'private_key' => sfConfig::get('app_recaptcha_private_key') 
     52        )); 
     53        $this->validatorSchema['captcha'] 
     54            ->setMessage('captcha', __('The captcha is not valid (%error%).', array(), 'sfForkedApply')) 
     55            ->setMessage('server_problem', __('Unable to check the captcha from the server (%error%).', array(), 'sfForkedApply')); 
     56    } 
    3157} 
    3258 
  • plugins/sfForkedDoctrineApplyPlugin/trunk/package.xml.tmpl

    r28819 r28839  
    5252  <phprelease></phprelease> 
    5353  <changelog> 
     54      <release> 
     55        <version> 
     56          <release>1.1.0</release> 
     57          <api>1.1.0</api> 
     58        </version> 
     59        <stability> 
     60         <release>stable</release> 
     61         <api>stable</api> 
     62        </stability> 
     63        <license uri="http://www.symfony-project.org/license">MIT license</license> 
     64        <date>2010-03-28</date> 
     65        <license>MIT</license> 
     66        <notes> 
     67            * fizyk: added recaptcha functionality to Apply and ResetRequests forms (based on vjCommentPlugin) 
     68            * fizyk: changed type of validate_at to timestamp from datetime. No change on generated sql (reported by Magician). 
     69        </notes> 
     70      </release> 
    5471      <release> 
    5572        <version>