Новости Joomla

0 Пользователей и 1 Гость просматривают эту тему.
  • 0 Ответов
  • 2110 Просмотров
*

bonus

  • Новичок
  • 4
  • 0 / 0
Здравствуйте!
На странице регистрации новых пользователей подтверждение пишет в utf-8 (т.е. крякозябрами), а у меня все в 1251.



Пробовал сделать как тут http://joomlaforum.ru/index.php/topic,60276.0.html не получилось (
Как я понял, необходимо правильно изменить принудительную кодировку в components\com_comprofiler\plugin\user\plug_cbcore\cb.core.php
Значение
Цитировать
return '<span class="cb_result_error">' . sprintf( ISOtoUtf8( _UE_EMAIL_DOES_NOT_EXISTS_ON_SITE ), htmlspecialchars( $email ) ). "</span>";

Но как, не догадался. Спецы, помогите пожалуйста)

Конфигурация:
Joomla 1.1.5RE
CB 1.2.1
Версия MySQL     5.0.89
Версия PHP     5.2.11

На всякий случай вот мой cb.core.php

Цитировать
<?php
/**
* Core plugin with tab classes for: Portrait and Contact Tabs for handling the core CB tab api
* @version $Id: cb.core.php 609 2006-12-13 17:30:15Z beat $
* @package Community Builder
* @subpackage Page Title, Portrait, Contact tabs CB core plugin
* @author Beat and JoomlaJoe
* @copyright (C) Beat, JoomlaJoe, www.joomlapolis.com and various
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU/GPL version 2
*/

/** ensure this file is being included by a parent file */
if ( ! ( defined( '_VALID_CB' ) || defined( '_JEXEC' ) || defined( '_VALID_MOS' ) ) ) { die( 'Direct Access to this location is not allowed.' ); }

global $_PLUGINS;
$_PLUGINS->registerUserFieldTypes( array(    'checkbox'      => 'CBfield_checkbox',
                                 'multicheckbox'   => 'CBfield_select_multi_radio',
                                 'date'         => 'CBfield_date',
                                    'datetime'         => 'CBfield_date',
                                 'select'      => 'CBfield_select_multi_radio',
                                 'multiselect'   => 'CBfield_select_multi_radio',
                                 'emailaddress'   => 'CBfield_email',
                                 'primaryemailaddress'   => 'CBfield_email',
                                 'editorta'      => 'CBfield_editorta',
                                 'textarea'      => 'CBfield_textarea',
                                 'text'         => 'CBfield_text',
                                 'integer'      => 'CBfield_integer',
                                 'radio'         => 'CBfield_select_multi_radio',
                                 'webaddress'   => 'CBfield_webaddress',
                                 'pm'               => 'CBfield_pm',
                                 'image'               => 'CBfield_image',
                                 'status'            => 'CBfield_status',
                                 'formatname'         => 'CBfield_formatname',
                                 'predefined'         => 'CBfield_predefined',
                                 'counter'         => 'CBfield_counter',
                                 'connections'      => 'CBfield_connections',
                                 'password'      => 'CBfield_password',
                                 'hidden'      => 'CBfield_text',
                                 'delimiter'      => 'CBfield_delimiter',
                                 'userparams'   => 'CBfield_userparams' ) );   // reserved, used now: 'other_types'
                                                                     // future reserved: 'all_types'
$_PLUGINS->registerUserFieldParams();

class CBfield_text extends cbFieldHandler {
   /**
    * Validator:
    * Validates $value for $field->required and other rules
    * Override
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user        RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit)
    * @param  string                $columnName  Column to validate
    * @param  string                $value       (RETURNED:) Value to validate, Returned Modified if needed !
    * @param  array                 $postdata    Typically $_POST (but not necessarily), filtering required.
    * @param  string                $reason      'edit' for save profile edit, 'register' for registration, 'search' for searches
    * @return boolean                            True if validate, $this->_setErrorMSG if False
    */
   function validate( &$field, &$user, $columnName, &$value, &$postdata, $reason ) {
      $validated               =   parent::validate( $field, $user, $columnName, $value, $postdata, $reason );
      if ( $validated && ( $value !== '' ) && ( $value !== null ) ) {      // empty values (e.g. non-mandatory) are treated in the parent validation.
         $fieldValidateExpression   =   $field->params->get( 'fieldValidateExpression', '' );
         if ( $fieldValidateExpression != '' ) {
            $possibilities      =   array(   'singleword'      =>   '/^[a-z]*$/i',
                                    'multiplewords'      =>   '/^([a-z]+ *)*$/i',
                                    'singleaznum'      =>   '/^[a-z]+[a-z0-9_]*$/i',
                                    'atleastoneofeach'   =>   '/^(?=.*\d)(?=.*(\W|_))(?=.*[a-z])(?=.*[A-Z]).{6,255}$/'
                                  );
            if ( isset( $possibilities[$fieldValidateExpression] ) ) {
               $pregExp      =   $possibilities[$fieldValidateExpression];
            } elseif ( $fieldValidateExpression == 'customregex' ) {
               $pregExp      =   $field->params->get( 'pregexp', '/^.*$/' );
            }

            $validated            =   preg_match( $pregExp, $value );
            if ( ! $validated ) {
               $pregExpError      =   $field->params->get( 'pregexperror', 'Not a valid input' );
               $this->_setValidationError( $field, $user, $reason, $pregExpError );
            }
         }
      }
      return $validated;
   }
}
class CBfield_textarea extends CBfield_text {
   /**
    * Accessor:
    * Returns a field in specified format
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user
    * @param  string                $output  'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
    * @param  string                $reason  'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
    * @param  int                   $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
    * @return mixed
    */
   function getField( &$field, &$user, $output, $reason, $list_compare_types ) {
      switch ( $output ) {
         case 'html':
         case 'rss':
            return str_replace( "\n", '<br />', parent::getField( $field, $user, $output, $reason, $list_compare_types ) );
         default:
            return parent::getField( $field, $user, $output, $reason, $list_compare_types );
            break;
      }
   }
}

class CBfield_predefined extends CBfield_text {
   /**
    * Returns a field in specified format
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user
    * @param  string                $output  'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
    * @param  string                $reason  'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
    * @param  int                   $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
    * @return mixed                
    */
   function getField( &$field, &$user, $output, $reason, $list_compare_types ) {
      global $_CB_framework, $ueConfig;

      $value                        =   $user->get( $field->name );

      switch ( $output ) {
         case 'html':
         case 'rss':
            if ( ( $field->type == 'predefined' ) && ( $ueConfig['allow_profilelink'] == 1 ) && ( $reason != 'profile' ) && ( $reason != 'edit' ) ) {
               $profileURL            =   $_CB_framework->userProfileUrl( $user->id, true );
               return '<a href="' . $profileURL . '">' . htmlspecialchars( $value ). '</a>';
            } else {
               return htmlspecialchars( $value );
            }
            break;

         case 'htmledit':
            if ( $field->name == 'username' ) {
//               if ( ( $ueConfig["usernameedit"] == 1 ) || ( $user->username == '' ) || ( $_CB_framework->getUi() == 2 ) ) {
               if ( ! ( ( $ueConfig['usernameedit'] == 0 ) && ( $reason == 'edit' ) && ( $_CB_framework->getUi() == 1 ) ) ) {
                  $onProfile         =   $field->profile;
                  $field->profile      =   1;      // username is always "on profile" (e.g. SEF solutions in url).

                  $html            =   $this->_fieldEditToHtml( $field, $user, $reason, 'input', 'text', $value, '' );
                  if ( ( ( $ueConfig['reg_username_checker'] == 1 ) || ( $_CB_framework->getUi() == 2 ) )
                     && ( $reason != 'search' ) )
                  {
                     $this->ajaxCheckField( $field, $user, $reason );
                  }
/*
                  $version = checkJversion();
                  if ($version == 1) {
                     // Joomla 1.5:
                     $regexp      =   '[\\<|\\>|\\"|\\\'|\\%|\\;|\\(|\\)|\\&]';
                  } elseif ( $version == -1 ) {
                     // Mambo 4.6+:
                     $regexp      =   '[^A-Za-z0-9]';
                  } else {
                     // Joomla 1.0 and Mambo 4.5:
                     $regexp      =   '[\\<|\\>|\\"|\\\'|\\%|\\;|\\(|\\)|\\&|\\+|\\-]';
                  }
                  $_CB_framework->outputCbJQuery( 'jQuery.validator.addMethod("cbusername", function(value, element) {'
                  .   '   return this.optional(element) || ! /' . $regexp . '/i.test(value);'
                  .   '}, "' . addslashes( sprintf( unhtmlentities(_VALID_AZ09), unhtmlentities(_PROMPT_UNAME), 2 ) ). '"); ');

                  if ( ( ( $ueConfig['reg_username_checker'] == 1 ) || ( $_CB_framework->getUi() == 2 ) )
                     && ( $reason != 'search' ) )
                  {
                     $html      =   $this->_fieldEditToHtml( $field, $user, $reason, 'input', 'text', $value, '', null, true, array( 'cbusername', $this->ajaxCheckField( $field, $user, $reason, array( 'minlength:3', 'maxlength:100', 'cbusername:true' ) ) ) );
                  } else {
                     $html      =   $this->_fieldEditToHtml( $field, $user, $reason, 'input', 'text', $value, '', array( 'cbusername', $this->_jsValidateClass( array( 'minlength:3', 'maxlength:100', 'cbusername:true' ) ) ) );
                  }
*/
                  $field->profile      =   $onProfile;
               } else {
                  $html            =   htmlspecialchars( $value )
                                 .   $this->_fieldEditToHtml( $field, $user, $reason, 'input', 'hidden', $value, '' );
               }
            } else {
               $html               =   $this->_fieldEditToHtml( $field, $user, $reason, 'input', 'text', $value, '' );
            }
            if ( $reason == 'search' ) {
               $html               =   $this->_fieldSearchModeHtml( $field, $user, $html, 'text', $list_compare_types );
            }
            return $html;
            break;

         default:
            return $this->_formatFieldOutput( $field->name, $value, $output );
            break;
      }
   }
   /**
    * Direct access to field for custom operations, like for Ajax
    *
    * WARNING: direct unchecked access, except if $user is set, then check
    * that the logged-in user has rights to edit that $user.
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user
    * @param  array                 $postdata
    * @param  string                $reason     'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'search' for searches
    * @return string                            Expected output.
    */
   function fieldClass( &$field, &$user, &$postdata, $reason ) {
      global $_CB_framework, $_CB_database, $ueConfig, $_GET;

      parent::fieldClass( $field, $user, $postdata, $reason );      // performs spoofcheck.

      $html               =   null;
      $function            =   cbGetParam( $_GET, 'function', '' );
      if ( $function == 'checkvalue' ) {
         $username         =   stripslashes( cbGetParam( $postdata, 'value', '' ) );
         $usernameISO      =   utf8ToISO( $username );         // AJAX sends in utf8, we need to convert back to the site's encoding.
   
         $function         =   'testnotexists';
         if ( ( ( $ueConfig['reg_username_checker'] == 1 ) || ( $_CB_framework->getUi() == 2 ) )
            && ( ( $reason == 'edit' ) || ( $reason == 'register' ) ) )
         {
            if ( ( ! $user ) || ( $usernameISO != $user->username ) ) {

               if ( ! $this->validate( $field, $user, 'username', $usernameISO, $postdata, $reason ) ) {
                  global $_PLUGINS;
                  $html         =   '<span class="cb_result_error">' . $_PLUGINS->getErrorMSG( '<br />' ). '</span>';
               } else {
                  if ( $_CB_database->isDbCollationCaseInsensitive() ) {
                     $query   =   "SELECT COUNT(*) AS result FROM #__users WHERE username = " . $_CB_database->Quote( ( trim( $usernameISO ) ) );
                  } else {
                     $query   =   "SELECT COUNT(*) AS result FROM #__users WHERE LOWER(username) = " . $_CB_database->Quote( ( strtolower( trim( $usernameISO ) ) ) );
                  }
                  $_CB_database->setQuery($query);
                  $dataObj         =   null;
                  if ( $_CB_database->loadObject( $dataObj ) ) {
                     if ( $dataObj->result ) {
                        // funily, the output does not need to be UTF8 again:
                        if ( $function == 'testexists' ) {
                           $html   =   ( '<span class="cb_result_ok">' . sprintf( ISOtoUtf8( _UE_USERNAME_EXISTS_ON_SITE ), htmlspecialchars( $username ) ). '</span>' );
                        } else {
                           $html   =   ( '<span class="cb_result_error">' . sprintf( ISOtoUtf8( _UE_USERNAME_ALREADY_EXISTS ), htmlspecialchars( $username ) ). '</span>' );
                        }
                     } else {
                        if ( $function == 'testexists' ) {
                           $html   =   ( '<span class="cb_result_error">' . sprintf( ISOtoUtf8( _UE_USERNAME_DOES_NOT_EXISTS_ON_SITE ), htmlspecialchars( $username ) ). '</span>' );
                        } else {
                           if ( $reason == 'register' ) {
                              $html   =   ( '<span class="cb_result_ok">' . sprintf( ISOtoUtf8( _UE_USERNAME_DOESNT_EXISTS ), htmlspecialchars( $username ) ). '</span>' );
                           } else {
                              $html   =   ( '<span class="cb_result_ok">' . sprintf( ISOtoUtf8( _UE_USERNAME_FREE_OK_TO_PROCEED ), htmlspecialchars( $username ) ). '</span>' );
                           }
                        }
                     }
                  } else {
                     $html         =   ( '<span class="cb_result_error">' . ISOtoUtf8( _UE_SEARCH_ERROR ). ' !' . '</span>' );
                  }
               }
            } else {
               if ( $user && ( $user->id == $_CB_framework->myId() ) ) {
                  $html         =   ( '<span class="cb_result_ok">' . sprintf( ISOtoUtf8( _UE_THIS_IS_YOUR_USERNAME ), htmlspecialchars( $username ) ). '</span>' );
               } else {
                  $html         =   ( '<span class="cb_result_ok">' . sprintf( ISOtoUtf8( _UE_THIS_IS_USERS_USERNAME ), htmlspecialchars( $username ) ). '</span>' );
               }
            }
         } else {
            $html               =   ISOtoUtf8( _UE_NOT_AUTHORIZED );
         }
      }
      return $html;
   }
   /**
    * Prepares field data for saving to database (safe transfer from $postdata to $user)
    * Override
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user      RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit)
    * @param  array                 $postdata  Typically $_POST (but not necessarily), filtering required.
    * @param  string                $reason    'edit' for save profile edit, 'register' for registration, 'search' for searches
    */
   function prepareFieldDataSave( &$field, &$user, &$postdata, $reason ) {
      global $_CB_framework, $ueConfig;

      $this->_prepareFieldMetaSave( $field, $user, $postdata, $reason );

      switch ( $field->name ) {
         case 'username':
            if ( ! ( ( $ueConfig['usernameedit'] == 0 ) && ( $reason == 'edit' ) && ( $_CB_framework->getUi() == 1 ) ) ) {
               $username            =   stripslashes( cbGetParam( $postdata, 'username', null ) );
               $fieldMinLength         =   $field->params->get( 'fieldMinLength', 3 );
               if ( cbIsoUtf_strlen( $username ) < $fieldMinLength ) {
                  $this->_setValidationError( $field, $user, $reason, sprintf( _UE_VALID_UNAME, _UE_UNAME, $fieldMinLength ) );
               } else {
                  if ( $this->validate( $field, $user, $field->name, $username, $postdata, $reason ) ) {
                     if ( ( $username !== null ) && ( $username !== $user->username ) ) {
                        $this->_logFieldUpdate( $field, $user, $reason, $user->username, $username );
                     }
                  }
               }
               if ( $username !== null ) {
                  $user->username      =   $username;
               }
            }
            break;

         case 'name':
         case 'firstname':
         case 'middlename':
         case 'lastname':
            $value                     =   stripslashes( cbGetParam( $postdata, $field->name ) );
            $col                     =   $field->name;
            if ( $value !== null ) {
               // Form name from first/middle/last name if needed:
               if ( $field->name !== 'name' ) {
                  $nameArr            =   array();
                  if ( $ueConfig['name_style'] >= 2 ) {
                     $firstname      =   stripslashes( cbGetParam( $postdata, 'firstname' ) );
                     if ( $firstname ) {
                        $nameArr[]   =    $firstname;
                     }
                     if ( $ueConfig['name_style'] == 3 ) {
                        $middlename   =   stripslashes( cbGetParam( $postdata, 'middlename' ) );
                        if ( $middlename ) {
                           $nameArr[]   =   $middlename;
                        }
                     }
                     $lastname      =   stripslashes( cbGetParam( $postdata, 'lastname' ) );
                     if ( $lastname ) {
                        $nameArr[]   =   $lastname;
                     }
                  }
                  if ( count( $nameArr ) > 0 ) {
                     $user->name         =   implode( ' ', $nameArr );
                  }
               }
            }
            if ( ( $value == '' ) && $field->required ) {
               /* $nameTitles         =   array(   'name'         => _UE_YOUR_NAME,
                                       'firstname'      => _UE_YOUR_FNAME,
                                       'middlename'   => _UE_YOUR_MNAME,
                                       'lastname'      => _UE_YOUR_LNAME );
               $this->_setValidationError( $nameTitles[$field->name] . ' : '. unHtmlspecialchars( _UE_REQUIRED_ERROR ) );
               */
               $this->_setValidationError( $field, $user, $reason, unHtmlspecialchars( _UE_REQUIRED_ERROR ) );
            } else {
               if ( $this->validate( $field, $user, $field->name, $value, $postdata, $reason ) ) {
                  if ( ( (string) $user->$col )!== (string) $value ) {
                     $this->_logFieldUpdate( $field, $user, $reason, $user->$col, $value );
                  }
               }
            }
            if ( $value !== null ) {
               $user->$col               =   $value;
            }
            break;

         default:
            $this->_setValidationError( $field, $user, $reason, "Unknown field " . $field->name );
            break;
      }
   }
   /**
    * Validator:
    * Validates $value for $field->required and other rules
    * Override
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user        RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit)
    * @param  string                $columnName  Column to validate
    * @param  string                $value       (RETURNED:) Value to validate, Returned Modified if needed !
    * @param  array                 $postdata    Typically $_POST (but not necessarily), filtering required.
    * @param  string                $reason      'edit' for save profile edit, 'register' for registration, 'search' for searches
    * @return boolean                            True if validate, $this->_setErrorMSG if False
    */
   function validate( &$field, &$user, $columnName, &$value, &$postdata, $reason ) {
      $validated         =   parent::validate( $field, $user, $columnName, $value, $postdata, $reason );
      if ( $validated ) {
         if ( $field->name == 'username' ) {
            $version = checkJversion();
            if ($version == 1) {
               // "^[a-zA-Z](([\.\-a-zA-Z0-9@])?[a-zA-Z0-9]*)*$", "i");
               // $regex      =   '/^[\\<|\\>|"|\'|\\%|\\;|\\(|\\)|\\&|\\+|\\-]*$/i';
               $regex      =   '/^[\\<|\\>|"|\\\'|\\%|\\;|\\(|\\)|\\&]*$/i';
            } elseif ( $version == -1 ) {
               $regex      =   "[^A-Za-z0-9]";
            } else {
               $regex      =   '/[\\<|\\>|"|\'|\\%|\\;|\\(|\\)|\\&|\\+|\\-]/i';
            }
            $validated      =   ! preg_match( $regex, $value );
            if ( ! $validated ) {
               $this->_setValidationError( $field, $user, $reason, sprintf( unhtmlentities(_VALID_AZ09), unhtmlentities(_PROMPT_UNAME), 2 ) );
            }
         }
      }
      return $validated;
   }
}
class CBfield_password extends CBfield_text {
   /**
    * Returns a PASSWORD field in specified format
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user
    * @param  string                $output      'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
    * @param  string                $formatting  'table', 'td', 'span', 'div', 'none'
    * @param  string                $reason      'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
    * @param  int                   $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
    * @return mixed                
    */
   function getFieldRow( &$field, &$user, $output, $formatting, $reason, $list_compare_types ) {
      global $ueConfig, $_CB_OneTwoRowsStyleToggle;

      $results                        =   null;

      if ( $output == 'htmledit' ) {

         if ( ( $field->name != 'password' ) || ( $reason != 'register' ) || ! ( isset( $ueConfig['emailpass'] ) && ( $ueConfig['emailpass'] == "1" ) ) ) {

            $verifyField               =   new moscomprofilerFields( $field->_db );
            foreach ( array_keys( get_object_vars( $verifyField ) ) as $k ) {
               $verifyField->$k         =   $field->$k;
            }
            $verifyField->name            =   $field->name . '__verify';
            $verifyField->fieldid         =   $field->fieldid . '__verify';
            $verifyField->title            =   sprintf( _UE_VERIFY_SOMETHING, getLangDefinition( $field->title ) );   // cbReplaceVars to be done only once later
            $verifyField->_identicalTo      =   $field->name;
   
            $toggleState               =   $_CB_OneTwoRowsStyleToggle;
            $results                  =   parent::getFieldRow( $field, $user, $output, $formatting, $reason, $list_compare_types );
            $_CB_OneTwoRowsStyleToggle      =   $toggleState;      // appear as in same row
            $results                  .=   parent::getFieldRow( $verifyField, $user, $output, $formatting, $reason, $list_compare_types );
   
            unset( $verifyField );

         } else {
            // case of "sending password by email" at registration time for main password field:
            $results                  =   parent::getFieldRow( $field, $user, $output, $formatting, $reason, $list_compare_types );
         }
      } else {
         $results                     =   parent::getFieldRow( $field, $user, $output, $formatting, $reason, $list_compare_types );
      }
      return $results;
   }
   /**
    * Returns a field in specified format
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user
    * @param  string                $output  'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
    * @param  string                $reason  'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
    * @param  int                   $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
    * @return mixed                
    */
   function getField( &$field, &$user, $output, $reason, $list_compare_types ) {
      global $ueConfig;

      $value                           =   '';         // passwords are never sent back to forms.

      switch ( $output ) {
         case 'htmledit':
            if ( $reason == 'search' ) {
               return null;
            }

         if ( ( $field->name != 'password' ) || ( $reason != 'register' ) || ! ( isset( $ueConfig['emailpass'] ) && ( $ueConfig['emailpass'] == "1" ) ) ) {

               $req                     =   $field->required;
               $fieldMinLength               =   $field->params->get( 'fieldMinLength', 6 );
               if ( ( $reason == 'edit' ) && in_array( $field->name, array( 'password', 'password__verify' ) ) ) {
                  $field->required         =   0;
               }

               $metaJson                  =   array();
               if ( $fieldMinLength > 0 ) {
                  $metaJson[]               =   'minlength:' . (int) $fieldMinLength;
               }
               if ( isset( $field->_identicalTo ) ) {
                  $metaJson[]               =   "equalTo:'#" . addslashes( htmlspecialchars( $field->_identicalTo ) ). "'";
               }
               if ( count( $metaJson ) > 0 ) {
                  $classesMeta            =   array( '{' . implode( ',', $metaJson ). '}' );
               } else {
                  $classesMeta            =   null;
               }
               $html                     =   $this->_fieldEditToHtml( $field, $user, $reason, 'input', $field->type, $value, '', null, true, $classesMeta );
               $field->required            =   $req;

            } else {
               // case of "sending password by email" at registration time for main password field:
               $html                     =   $this->_fieldEditToHtml( $field, $user, $reason, 'input', 'html', _SENDING_PASSWORD, '' );
            }
            return $html;
            break;

         case 'html':
            return '********';
            break;
         default:
            return null;
            break;
      }
   }
   /**
    * Prepares field data for saving to database (safe transfer from $postdata to $user)
    * Override
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user      RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit)
    * @param  array                 $postdata  Typically $_POST (but not necessarily), filtering required.
    * @param  string                $reason    'edit' for save profile edit, 'register' for registration, 'search' for searches
    */
   function prepareFieldDataSave( &$field, &$user, &$postdata, $reason ) {
      global $ueConfig;

      $this->_prepareFieldMetaSave( $field, $user, $postdata, $reason );

      // For CB main password don't save if it's on registration and passwords are auto-generated.
      if ( ( $reason == 'register' ) && ( $field->name == 'password' ) ) {
         if ( isset( $ueConfig['emailpass'] ) && ( $ueConfig['emailpass'] == "1" ) ) {
            return;
         }
      }

      foreach ( $field->getTableColumns() as $col ) {
         $value               =   stripslashes( cbGetParam( $postdata, $col,            '', _CB_ALLOWRAW ) );
         $valueVerify         =   stripslashes( cbGetParam( $postdata, $col . '__verify',   '', _CB_ALLOWRAW ) );

         if ( ( $reason == 'edit' ) && ( $user->id != 0 ) && ( $user->$col || ( $field->name == 'password' ) ) ) {
            $fieldRequired      =   $field->required;
            $field->required   =   0;
         }
         $this->validate( $field, $user, $col, $value, $postdata, $reason );

         if ( ( $reason == 'edit' ) && ( $user->id != 0 ) && ( $user->$col || ( $field->name == 'password' ) ) ) {
            $field->required   =   $fieldRequired;
         }

         $fieldMinLength         =   $field->params->get( 'fieldMinLength', 6 );

         $user->col            =   null;      // don't update unchanged (hashed) passwords unless typed-in and all validates:
         if ( $value ) {
            if ( cbIsoUtf_strlen( $value ) < $fieldMinLength ) {
               $this->_setValidationError( $field, $user, $reason, sprintf( _UE_VALID_PASS_CHARS, _UE_PASS, $fieldMinLength ) );
            } elseif ( $value != $valueVerify ) {
               $this->_setValidationError( $field, $user, $reason, _UE_REGWARN_VPASS2 );
            } else {
               // There is no event for password changes on purpose here !
               $user->$col      =   $value;         // store only if validated
            }
         }
      }
   }
   /**
    * Finder:
    * Prepares field data for saving to database (safe transfer from $postdata to $user)
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user      RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit)
    * @param  array                 $postdata  Typically $_POST (but not necessarily), filtering required.
    * @param  int                   $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
    * @param  string                $reason    'edit' for save profile edit, 'register' for registration, 'search' for searches
    * @return array of cbSqlQueryPart
    */
   function bindSearchCriteria( &$field, &$user, &$postdata, $list_compare_types, $reason ) {
      return array();
   }
}
class CBfield_select_multi_radio extends cbFieldHandler {
   /**
    * Returns a field in specified format
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user
    * @param  string                $output  'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
    * @param  string                $reason  'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
    * @param  int                   $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
    * @return mixed
    */
   function getField( &$field, &$user, $output, $reason, $list_compare_types ) {
      $value               =   $user->get( $field->name );

      switch ( $output ) {
         case 'html':
         case 'rss':
            if ( $value != '' ) {
               $chosen         =   $this->_explodeCBvalues( $value );
            } else {
               $chosen         =   array();
            }
            $class            =   trim( $field->params->get( 'field_display_class' ) );
            $displayStyle      =   $field->params->get( 'field_display_style' );
            $listType         =   ( $displayStyle == 1 ? 'ul' : ( $displayStyle == 2 ? 'ol' : ', ' ) );
            for( $i = 0, $n = count( $chosen ); $i < $n; $i++ ) {
                  $chosen[$i]      =   getLangDefinition( $chosen[$i] );
            }
            return $this->_arrayToFormat( $field, $chosen, $output, $listType, $class );
            break;

         case 'htmledit':
            global $_CB_database;

            $_CB_database->setQuery( "SELECT fieldtitle AS `value`, fieldtitle AS `text`, concat('cbf',fieldvalueid) AS id FROM #__comprofiler_field_values"      // id needed for the labels
                              . "\n WHERE fieldid = " . (int) $field->fieldid
                              . "\n ORDER BY ordering" );
            $allValues      =   $_CB_database->loadObjectList();
/*
            if ( $reason == 'search' ) {
               array_unshift( $allValues, $this->_valueDoesntMatter( $field, $reason, ( $field->type == 'multicheckbox' ) ) );
               if ( ( $field->type == 'multicheckbox' ) && ( $value === null ) ) {
                  $value   =   array( null );         // so that "None" is really not checked if not checked...
               }
            }
*/
            if ( $reason == 'search' ) {
//               $html         =   $this->_fieldEditToHtml( $field, $user, $reason, 'input', 'multicheckbox', $value, '', $allValues );
               $displayType   =   $field->type;
               switch ( $field->type ) {
                  case 'radio':
                     if ( in_array( $list_compare_types, array( 0, 2 ) ) || ( is_array( $value ) && ( count( $value ) > 1 ) ) ) {
                        $displayType   =   'multicheckbox';
                     }
                     $jqueryclass      =   'cb__js_' . $field->type;
                     break;
               
                  case 'select':
                     if ( is_array( $value ) && ( count( $value ) > 1 ) ) {
                        $displayType   =   'multiselect';
                     }
                     $jqueryclass      =   'cb__js_' . $field->type;
                     break;
               
                  default:
                     $jqueryclass      =   '';
                     break;
               }
               if ( in_array( $list_compare_types, array( 0, 2 ) ) && ( $displayType != 'multicheckbox' ) ) {
                  array_unshift( $allValues, moscomprofilerHTML::makeOption( '', _UE_NO_PREFERENCE ) );
               }
               $html         =   $this->_fieldEditToHtml( $field, $user, $reason, 'input', $displayType, $value, '', $allValues );
               $html         =   $this->_fieldSearchModeHtml( $field, $user, $html, ( strpos( $displayType, 'multi' ) === 0 ? 'multiplechoice' : 'singlechoice' ), $list_compare_types, $jqueryclass );
            } else {
               $html         =   $this->_fieldEditToHtml( $field, $user, $reason, 'input', $field->type, $value, '', $allValues );
            }
            return $html;
            break;

         case 'xml':
         case 'json':
         case 'php':
         case 'csv':
            $chosen         =   $this->_explodeCBvalues( $value );
            for( $i = 0, $n = count( $chosen ); $i < $n; $i++ ) {
                  $chosen[$i]      =   getLangDefinition( $chosen[$i] );
            }
            return $this->_arrayToFormat( $field, $chosen, $output );
            break;

         case 'csvheader':
         case 'fieldslist':
         default:
            return parent::getField( $field, $user, $output, $reason, $list_compare_types );
            break;
      }
      return '***ERROR***';
   }
   /**
    * Prepares field data for saving to database (safe transfer from $postdata to $user)
    * Override
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user      RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit)
    * @param  array                 $postdata  Typically $_POST (but not necessarily), filtering required.
    * @param  string                $reason    'edit' for save profile edit, 'register' for registration, 'search' for searches
    */
   function prepareFieldDataSave( &$field, &$user, &$postdata, $reason ) {
      global $_CB_database;

      $this->_prepareFieldMetaSave( $field, $user, $postdata, $reason );

      foreach ( $field->getTableColumns() as $col ) {
         $value                  =   cbGetParam( $postdata, $col );
//         if ( $value === null ) {
//            $value            =   array();
//         } elseif ( $field->type == 'radio' ) {
//            $value            =   array( $value );
//         }

         if ( is_array( $value ) ) {
            if ( count( $value ) > 0 ) {
   
               $_CB_database->setQuery( 'SELECT fieldtitle AS id FROM #__comprofiler_field_values'
                                 . "\n WHERE fieldid = " . (int) $field->fieldid
                                 . "\n ORDER BY ordering" );
               $authorizedValues   =   $_CB_database->loadResultArray();

               $okVals            =   array();
               foreach ( $value as $k => $v ) {
                  // revert escaping of cbGetParam:
                  $v            =   stripslashes( $v );
                  // check authorized values:
                  if ( in_array( $v, $authorizedValues ) && ! in_array( $v, $okVals ) ) {      // in case a value appears multiple times in a multi-field !
                     $okVals[$k]   =   $v;
                  }
               }
               $value            =   $this->_implodeCBvalues( $okVals );
            } else {
               $value            =   '';
            }
         } elseif ( ( $value === null ) || ( $value === '' ) ) {
            $value               =   '';
         } else {
            $value               =   stripslashes( $value );   // compensate for cbGetParam.
            $_CB_database->setQuery( 'SELECT fieldtitle AS id FROM #__comprofiler_field_values'
                                 . "\n WHERE fieldid = " . (int) $field->fieldid
                                 . "\n AND fieldtitle = " . $_CB_database->Quote( $value ) );
            $authorizedValues   =   $_CB_database->loadResultArray();
            if ( ! in_array( $value, $authorizedValues ) ) {
               $value         =   null;
            }
         }
         if ( $this->validate( $field, $user, $col, $value, $postdata, $reason ) ) {
            if ( isset( $user->$col ) && ( (string) $user->$col )!== (string) $value ) {
               $this->_logFieldUpdate( $field, $user, $reason, $user->$col, $value );
            }
         }
         $user->$col            =   $value;
      }
   }
   /**
    * Finder:
    * Prepares field data for saving to database (safe transfer from $postdata to $user)
    * Override
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $searchVals  RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit)
    * @param  array                 $postdata    Typically $_POST (but not necessarily), filtering required.
    * @param  int                   $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
    * @param  string                $reason      'edit' for save profile edit, 'register' for registration, 'search' for searches
    * @return array of cbSqlQueryPart
    */
   function bindSearchCriteria( &$field, &$searchVals, &$postdata, $list_compare_types, $reason ) {
      global $_CB_database;

      $displayType                  =   $field->type;
      if ( ( $field->type == 'radio' ) && in_array( $list_compare_types, array( 0, 2 ) ) ) {
         $displayType   =   'multicheckbox';
      }

      $query                        =   array();
      $searchMode                     =   $this->_bindSearchMode( $field, $searchVals, $postdata, ( strpos( $displayType, 'multi' ) === 0 ? 'multiplechoice' : 'singlechoice' ), $list_compare_types );
      if ( $searchMode ) {
         foreach ( $field->getTableColumns() as $col ) {
            $value                  =   cbGetParam( $postdata, $col );
            if ( is_array( $value ) ) {
               if ( count( $value ) > 0 ) {
                  $_CB_database->setQuery( 'SELECT fieldtitle AS id FROM #__comprofiler_field_values'
                                    . "\n WHERE fieldid = " . (int) $field->fieldid
                                    . "\n ORDER BY ordering" );
                  $authorizedValues   =   $_CB_database->loadResultArray();
      
                  foreach ( $value as $k => $v ) {
                     if ( ( count( $value ) == 1 ) && ( $v === '' ) ) {
                        if ( $list_compare_types == 1 ) {
                           $value      =   '';      // Advanced search: "None": checked: search for nothing selected
                        } else {
                           $value      =   null;   // Type 0 and 2 : Simple search: "Do not care" checked: do not search
                        }
                        break;
                     }
                     // revert escaping of cbGetParam:
                     $v            =   stripslashes( $v );
                     // check authorized values:
                     if ( in_array( $v, $authorizedValues ) ) {
                        $value[$k]   =   $v;
                     } else {
                        unset( $value[$k] );
                     }
                  }
      
               } else {
                  $value            =   null;
               }
               if ( ( $value !== null ) && ( $value !== '' ) && in_array( $searchMode, array( 'is', 'isnot' ) ) ) {      // keep $value array if search is not strict
                  $value            =   stripslashes( $this->_implodeCBvalues( $value ) );   // compensate for cbGetParam.
               }
            } else {
               if ( ( $value !== null ) && ( $value !== '' ) ) {
                  $value               =   stripslashes( $value );   // compensate for cbGetParam.
                  $_CB_database->setQuery( 'SELECT fieldtitle AS id FROM #__comprofiler_field_values'
                                       . "\n WHERE fieldid = " . (int) $field->fieldid
                                       . "\n AND fieldtitle = " . $_CB_database->Quote( $value ) );
                  $authorizedValues   =   $_CB_database->loadResultArray();
                  if ( ! in_array( $value, $authorizedValues ) ) {
                     $value         =   null;
                  }
               } else {
   //               if ( ( $field->type == 'multicheckbox' ) && ( $value === null ) ) {
                     $value         =   null;            // 'none' is not checked and no other is checked: search for DON'T CARE
   //               } else {
   //                  $value         =   null;
   //               }
               }
            }
            if ( $value !== null ) {
               $searchVals->$col      =   $value;
               // $this->validate( $field, $user, $col, $value, $postdata, $reason );
               $sql               =   new cbSqlQueryPart();
               $sql->tag            =   'column';
               $sql->name            =   $col;
               $sql->table            =   $field->table;
               $sql->type            =   'sql:field';
               $sql->operator         =   '=';
               $sql->value            =   $value;
               $sql->valuetype         =   'const:string';
               $sql->searchmode      =   $searchMode;
               $query[]            =   $sql;
            }
         }
      }
      return $query;
   }
}
class CBfield_checkbox extends cbFieldHandler {
   /**
    * Returns a field in specified format
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user
    * @param  string                $output  'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
    * @param  string                $reason  'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
    * @param  int                   $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
    * @return mixed
    */
   function getField( &$field, &$user, $output, $reason, $list_compare_types ) {
      $value         =   $user->get( $field->name );

      switch ( $output ) {
         case 'html':
         case 'rss':
            if ( $value == 1 ) {
               return _UE_YES;
            } elseif ( $value == 0 ) {
               return _UE_NO;
            } else {
               return null;
            }
            break;

         case 'htmledit':
            if ( $reason == 'search' ) {
               $choices   =   array();
               $choices[]   =   moscomprofilerHTML::makeOption( '', _UE_NO_PREFERENCE );
               $choices[]   =   moscomprofilerHTML::makeOption( '1', _UE_YES );
               $choices[]   =   moscomprofilerHTML::makeOption( '0', _UE_NO );
               $html      =   '<div class="cbSingleCntrl">' . $this->_fieldEditToHtml( $field, $user, $reason, 'input', 'select', $value, '', $choices ). '</div>';
               $html      =   $this->_fieldSearchModeHtml( $field, $user, $html, 'none', $list_compare_types );
               return $html;
            } else {
               $checked      =   '';
               if ( $value == 1 ) {
                  $checked   =   ' checked="checked"';
               }
               return '<div class="cbSingleCntrl">' . $this->_fieldEditToHtml( $field, $user, $reason, 'input', 'checkbox', '1', $checked ). '</div>';
            }
            break;

         case 'json':
            return "'" . $field->name . "' : " . (int) $value;
            break;

         case 'php':
            return array( $field->name => (int) $value );
            break;

         case 'xml':
         case 'csvheader':
         case 'fieldslist':
         case 'csv':
         default:
            return parent::getField( $field, $user, $output, $reason, $list_compare_types );
            break;
      }
      return '*ERR*';
   }
   /**
    * Prepares field data for saving to database (safe transfer from $postdata to $user)
    * Override
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user      RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit)
    * @param  array                 $postdata  Typically $_POST (but not necessarily), filtering required.
    * @param  string                $reason    'edit' for save profile edit, 'register' for registration, 'search' for searches
    */
   function prepareFieldDataSave( &$field, &$user, &$postdata, $reason ) {
      $this->_prepareFieldMetaSave( $field, $user, $postdata, $reason );

      foreach ( $field->getTableColumns() as $col ) {
         $value               =   stripslashes( cbGetParam( $postdata, $col ) );

         if ( $value == '' ) {
            $value            =   0;
         } elseif ( $value == '1' ) {
            $value            =   1;
         }
         $validated            =   $this->validate( $field, $user, $col, $value, $postdata, $reason );
         if ( ( $value === 0 ) || ( $value === 1 ) ) {
            if ( $validated && isset( $user->$col ) && ( ( (string) $user->$col )!== (string) $value ) ) {
               $this->_logFieldUpdate( $field, $user, $reason, $user->$col, $value );
            }
         }
         $user->$col            =   $value;
      }
   }
   /**
    * Finder:
    * Prepares field data for saving to database (safe transfer from $postdata to $user)
    * Override
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $searchVals  RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit)
    * @param  array                 $postdata    Typically $_POST (but not necessarily), filtering required.
    * @param  int                   $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
    * @param  string                $reason      'edit' for save profile edit, 'register' for registration, 'search' for searches
    * @return array of cbSqlQueryPart
    */
   function bindSearchCriteria( &$field, &$searchVals, &$postdata, $list_compare_types, $reason ) {
      $query                     =   array();
      //no searchmode for checkboxes:
      //   $searchMode                  =   $this->_bindSearchMode( $field, $searchVals, $postdata, 'none', $list_compare_types );
      //   if ( $searchMode ) {
      foreach ( $field->getTableColumns() as $col ) {
         $value                  =   stripslashes( cbGetParam( $postdata, $col ) );
         if ( $value === '0' ) {
            $value            =   0;
         } elseif ( $value == '1' ) {
            $value            =   1;
         } else {
            continue;
         }
         $searchVals->$col      =   $value;
         // $this->validate( $field, $user, $col, $value, $postdata, $reason );
         $sql               =   new cbSqlQueryPart();
         $sql->tag            =   'column';
         $sql->name            =   $col;
         $sql->table            =   $field->table;
         $sql->type            =   'sql:field';
         $sql->operator         =   '=';
         $sql->value            =   $value;
         $sql->valuetype         =   'const:int';
         $sql->searchmode      =   'is';
         $query[]            =   $sql;
      }
      // }
      return $query;
   }
}
/**
 * Basic CB integer field extender.
 */
class CBfield_integer extends CBfield_text {
   /**
    * Accessor:
    * Returns a field in specified format
    *
    * @param  moscomprofilerField  $field
    * @param  moscomprofilerUser   $user
    * @param  string               $output  'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
    * @param  string               $reason  'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
    * @param  int                  $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
    * @return mixed                
    */
   function getField( &$field, &$user, $output, $reason, $list_compare_types ) {
      $value                  =   $user->get( $field->name );

      switch ( $output ) {
         case 'htmledit':
            if ( $reason == 'search' ) {
               $minNam         =   $field->name . '__minval';
               $maxNam         =   $field->name . '__maxval';

               $minVal         =   $user->get( $minNam );
               $maxVal         =   $user->get( $maxNam );

               $fieldNameSave   =   $field->name;
               $field->name   =   $minNam;
               $minHtml      =   $this->_fieldEditToHtml( $field, $user, $reason, 'input', 'text', $minVal, '' );
               $field->name   =   $maxNam;
               $maxHtml      =   $this->_fieldEditToHtml( $field, $user, $reason, 'input', 'text', $maxVal, '' );
               $field->name   =   $fieldNameSave;
               $ret         =   $this->_fieldSearchRangeModeHtml( $field, $user, $output, $reason, $value, $minHtml, $maxHtml, $list_compare_types );

            } else {
               $ret         =   $this->_fieldEditToHtml( $field, $user, $reason, 'input', 'text', $value, '' );
            }
            break;
         case 'html':
         case 'rss':
         case 'json':
         case 'php':
         case 'xml':
         case 'csvheader':
         case 'fieldslist':
         case 'csv':
         default:
            $ret            =   parent::getField( $field, $user, $output, $reason, $list_compare_types );
            break;
      }
      return $ret;
   }

   /**
    * Mutator:
    * Prepares field data for saving to database (safe transfer from $postdata to $user)
    * Override
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user      RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit)
    * @param  array                 $postdata  Typically $_POST (but not necessarily), filtering required.
    * @param  string                $reason    'edit' for save profile edit, 'register' for registration, 'search' for searches
    */
   function prepareFieldDataSave( &$field, &$user, &$postdata, $reason ) {
      $this->_prepareFieldMetaSave( $field, $user, $postdata, $reason );

      foreach ( $field->getTableColumns() as $col ) {
         $value               =   cbGetParam( $postdata, $col );
         if ( ! is_array( $value ) ) {
            $value            =   stripslashes( $value );
            $validated         =   $this->validate( $field, $user, $col, $value, $postdata, $reason );
            if ( $value === '' ) {
               $value         =   null;
            } else {
               $value         =   (int) $value;      // int conversion to sanitize input.
            }
            if ( $validated && isset( $user->$col ) && ( ( (string) $user->$col )!== (string) $value ) ) {
               $this->_logFieldUpdate( $field, $user, $reason, $user->$col, $value );
            }
            $user->$col      =   $value;
         }
      }
   }

   /**
    * Validator:
    * Validates $value for $field->required and other rules
    * Override
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $user        RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit)
    * @param  string                $columnName  Column to validate
    * @param  string                $value       (RETURNED:) Value to validate, Returned Modified if needed !
    * @param  array                 $postdata    Typically $_POST (but not necessarily), filtering required.
    * @param  string                $reason      'edit' for save profile edit, 'register' for registration, 'search' for searches
    * @return boolean                            True if validate, $this->_setErrorMSG if False
    */
   function validate( &$field, &$user, $columnName, &$value, &$postdata, $reason ) {
      $validated               =   parent::validate( $field, $user, $columnName, $value, $postdata, $reason );
      if ( $validated && ( $value !== '' ) && ( $value !== null ) ) {      // empty values (e.g. non-mandatory) are treated in the parent validation.
         $validated            =   preg_match( '/^[-0-9]*$/', $value );
         if ( $validated ) {
            // check range:
            $min            =   (int) $field->params->get( 'integer_minimum', '0' );
            $max            =   (int) $field->params->get( 'integer_maximum', '1000000' );
            if ( $max < $min ) {
               $this->_setValidationError( $field, $user, $reason, "Min setting > Max setting !" );      // Missing language string.
               $validated      =   false;
            }
            if ( ( ( (int) $value ) < $min ) || ( ( (int) $value ) > $max ) ) {
               $this->_setValidationError( $field, $user, $reason, sprintf( _UE_YEAR_NOT_IN_RANGE, (int) $value, (int) $min, (int) $max ) );      // using that year string, as we don't have a general one.
               $validated      =   false;
            }
            if ( $validated ) {
               // check for forbidden values as integers:
               $forbiddenContent         =   $field->params->get( 'fieldValidateForbiddenList_' . $reason, '' );
               if ( $forbiddenContent != '' ) {
                  $forbiddenContent      =   explode( ',', $forbiddenContent );
                  if ( in_array( (int) $value, $forbiddenContent ) ) {
                     $this->_setValidationError( $field, $user, $reason, _UE_INPUT_VALUE_NOT_ALLOWED );
                     $validated         =   false;
                  }
               }
            }
         } else {
            $this->_setValidationError( $field, $user, $reason, "Not an integer" );      // Missing language string.
         }
      }
      return $validated;
   }
   /**
    * Finder:
    * Prepares field data for saving to database (safe transfer from $postdata to $user)
    * Override
    *
    * @param  moscomprofilerFields  $field
    * @param  moscomprofilerUser    $searchVals  RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit)
    * @param  array               &n
« Последнее редактирование: 13.02.2010, 07:55:34 от bonus »
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться
 

Возможность сделать разные типы регистрации

Автор kurz

Ответов: 0
Просмотров: 4393
Последний ответ 03.11.2022, 12:04:04
от kurz
Убрать имя (настоящее) при регистрации и в личном кабинете

Автор Vlad1

Ответов: 6
Просмотров: 3165
Последний ответ 27.09.2022, 22:01:21
от Vlad1
Есть ли 100% рабочая CAPTCHA для регистрации CB 2.0.4?

Автор Torchez

Ответов: 27
Просмотров: 5843
Последний ответ 15.03.2016, 23:33:15
от Bmw258
AJAX проверка формы входа (или не ajax)

Автор ivan.sergeev

Ответов: 8
Просмотров: 2457
Последний ответ 09.03.2016, 10:11:37
от ivan.sergeev
Выбор Joomla группы при регистрации в CommunityBuilder

Автор andrewbubblegum

Ответов: 9
Просмотров: 5028
Последний ответ 04.03.2016, 12:26:31
от dimasan57