Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class CheckoutForm extends User {
- public $authed;
- public $restid;
- public $use_creditcard;
- public $cc_serial;
- public $cc_holder;
- public $cc_exp_month;
- public $cc_exp_year;
- public $cc_ccv;
- public $method;
- public $address;
- public $phonenumber;
- public $instruction;
- public $doorman;
- public $verifyPassword;
- public $verifyCode;
- public function addressArea($attribute, $params)
- {
- if( $attribute == "" )
- return;
- {
- $maps = new GoogleMaps();
- $mapresult = $maps->geoGetCoordsFull($this->$attribute );
- if ($mapresult->status != "OK" || !isset( $mapresult->results[0]->types[0] ) || $mapresult->results[0]->types[0] != 'sublocality_level_4' )
- {
- $this->addError($attribute, LangControl::GetText('GENERAL_VALIDATION_ADDRESS') );
- }
- }
- }
- public function rules() {
- $rules = array(
- array('address', 'addressArea' ),
- array('method, authed, use_creditcard, address, restid', 'required'),
- );
- // Add validation rules USER STATUS
- if( $this->authed == 0 )
- {
- $rules[] = array('password, verifyPassword, email', 'required');
- $rules[] = array('password', 'length', 'max'=>128, 'min' => 4,'message' => UserModule::t("Incorrect password (minimal length 4 symbols)."));
- $rules[] = array('email', 'email');
- $rules[] = array('email', 'unique', 'message' => UserModule::t("This user's email address already exists."));
- $rules[] = array('verifyPassword', 'compare', 'compareAttribute'=>'password', 'message' => UserModule::t("Retype Password is incorrect."));
- }
- else if( $this->authed == 1 )
- {
- $rules[] = array('email', 'safe');
- $rules[] = array('password', 'safe');
- $rules[] = array('verifyPassword', 'safe');
- }
- // Add validation rules for PAYMENT
- if( $this->use_creditcard == 1 )
- {
- $rules[] = array('cc_holder', 'required');
- $rules[] = array('cc_holder', 'length', 'min'=>5, 'max'=>40 );
- $rules[] = array('cc_serial', 'required');
- $rules[] = array('cc_serial', 'length', 'is'=>16 );
- $rules[] = array('cc_serial', 'numerical', 'integerOnly'=>true);
- $rules[] = array('cc_exp_month', 'required');
- $rules[] = array('cc_exp_month', 'type', 'type'=>'date', 'dateFormat'=>'MM');
- $rules[] = array('cc_exp_year', 'required');
- $rules[] = array('cc_exp_year', 'type', 'type'=>'date', 'dateFormat'=>'yyyy');
- $rules[] = array('cc_ccv', 'safe');
- }
- else if( $this->use_creditcard == 0 )
- {
- $rules[] = array('cc_holder', 'safe');
- $rules[] = array('cc_serial', 'safe');
- $rules[] = array('cc_exp_month', 'safe');
- $rules[] = array('cc_exp_year', 'safe');
- $rules[] = array('cc_ccv', 'safe');
- }
- // Add validation rules for METHOD
- if( $this->method == 0 )
- {
- $rules[] = array('phonenumber', 'safe');
- $rules[] = array('doorman', 'safe');
- $rules[] = array('instruction', 'safe');
- }
- else if( $this->method == 1 )
- {
- $rules[] = array('instruction', 'required');
- $rules[] = array('phonenumber', 'required');
- $rules[] = array('phonenumber', 'numerical', 'min'=>10, 'max'=>11 );
- $rules[] = array('doorman', 'safe');
- }
- return $rules;
- }
- }
Add Comment
Please, Sign In to add comment