protected function validateField( $field, $value )
    {
        switch ( $field )
        {
            case 'website':
                return ezcomUtility::validateURLString( $value );
            case 'email':
                // just validate anonymous's input email
                $user = eZUser::currentUser();
                if( $user->isAnonymous() )
                {
                    $result = eZMail::validate( $value );
                    if ( !$result )
                    {
                        return ezpI18n::tr( 'ezcomments/comment/add', 'Not a valid email address.' );
                    }
                }
                return true;
            case 'recaptcha':
                require_once 'recaptchalib.php';
                $ini = eZINI::instance( 'ezcomments.ini' );
                $privateKey = $ini->variable( 'RecaptchaSetting' , 'PrivateKey' );
                $http = eZHTTPTool::instance();
                if( $http->hasPostVariable( 'recaptcha_challenge_field' ) &&
                    $http->hasPostVariable( 'recaptcha_response_field' ) )
                {
                    $ip = $_SERVER["REMOTE_ADDR"];
                    $challengeField = $http->postVariable( 'recaptcha_challenge_field' );
                    $responseField = $http->postVariable( 'recaptcha_response_field' );
                    $capchaResponse = recaptcha_check_answer( $privateKey, $ip, $challengeField, $responseField );
                    if( !$capchaResponse->is_valid )
                    {
                         return ezpI18n::tr( 'ezcomments/comment/add', 'The words you input are incorrect.' );
                    }
                }
                else
                {
                    return ezpI18n::tr( 'ezcomments/comment/add', 'Captcha parameter error.' );
                }
                return true;
            default:
                return true;
        }
    }
protected function validateField( $field, $value )
    {
        switch ( $field )
        {
            case 'website':
                return ezcomUtility::validateURLString( $value );
            case 'email':
                // just validate anonymous's input email
                $user = eZUser::currentUser();
                if( $user->isAnonymous() )
                {
                    $result = eZMail::validate( $value );
                    if ( !$result )
                    {
                        return ezpI18n::tr( 'ezcomments/comment/add', 'Not a valid email address.' );
                    }
                }
                return true;
            case 'recaptcha':
                require_once 'recaptchalib.php';
                $ini = eZINI::instance( 'ezcomments.ini' );
                $privateKey = $ini->variable( 'RecaptchaSetting' , 'PrivateKey' );
                $http = eZHTTPTool::instance();
                if( $http->hasPostVariable( 'recaptcha_challenge_field' ) &&
                    $http->hasPostVariable( 'recaptcha_response_field' ) )
                {
                    $ip = $_SERVER["REMOTE_ADDR"];
                    $challengeField = $http->postVariable( 'recaptcha_challenge_field' );
                    $responseField = $http->postVariable( 'recaptcha_response_field' );
                    $capchaResponse = recaptcha_check_answer( $privateKey, $ip, $challengeField, $responseField );
                    if( !$capchaResponse->is_valid )
                    {
                         return ezpI18n::tr( 'ezcomments/comment/add', 'The words you input are incorrect.' );
                    }
                }
                else
                {
                    return ezpI18n::tr( 'ezcomments/comment/add', 'Captcha parameter error.' );
                }
                return true;
            default:
                return true;
        }
    }
protected function validateField ( $ field , $ value ) { switch ( $ field ) { case 'website' : return ezcomUtility :: validateURLString ( $ value ) ; case 'email' : // just validate anonymous's input email $ user = eZUser :: currentUser ( ) ; if ( $ user -> isAnonymous ( ) ) { $ result = eZMail :: validate ( $ value ) ; if ( ! $ result ) { return ezpI18n :: tr ( 'ezcomments/comment/add' , 'Not a valid email address.' ) ; } } return true ; case 'recaptcha' : require_once 'recaptchalib.php' ; $ ini = eZINI :: instance ( 'ezcomments.ini' ) ; $ privateKey = $ ini -> variable ( 'RecaptchaSetting' , 'PrivateKey' ) ; $ http = eZHTTPTool :: instance ( ) ; if ( $ http -> hasPostVariable ( 'recaptcha_challenge_field' ) && $ http -> hasPostVariable ( 'recaptcha_response_field' ) ) { $ ip = $ _SERVER [ "REMOTE_ADDR" ] ; $ challengeField = $ http -> postVariable ( 'recaptcha_challenge_field' ) ; $ responseField = $ http -> postVariable ( 'recaptcha_response_field' ) ; $ capchaResponse = recaptcha_check_answer ( $ privateKey , $ ip , $ challengeField , $ responseField ) ; if ( ! $ capchaResponse -> is_valid ) { return ezpI18n :: tr ( 'ezcomments/comment/add' , 'The words you input are incorrect.' ) ; } } else { return ezpI18n :: tr ( 'ezcomments/comment/add' , 'Captcha parameter error.' ) ; } return true ; default : return true ; } }
Implement the validatation in adding comment
@see extension/ezcomments/classes/ezcomFormTool#validateField($field)
Implement the validatation in adding comment