Index: branches/5.2.x/core/units/configuration/configuration_event_handler.php =================================================================== diff -u -N -r14572 -r14628 --- branches/5.2.x/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 14572) +++ branches/5.2.x/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 14628) @@ -1,6 +1,6 @@ setEventParam('PermSection', $this->Application->GetVar('section')); return parent::CheckPermission($event); @@ -31,10 +33,11 @@ * Apply any custom changes to list's sql query * * @param kEvent $event + * @return void * @access protected - * @see OnListBuild + * @see kDBEventHandler::OnListBuild() */ - function SetCustomQuery(&$event) + protected function SetCustomQuery(&$event) { $object =& $event->getObject(); /* @var $object kDBList */ @@ -57,50 +60,55 @@ } /** - * Enter description here... + * Performs validation of configuration variable value * * @param kEvent $event + * @return void + * @access protected */ - function OnBeforeItemUpdate(&$event) + protected function OnBeforeItemUpdate(&$event) { static $default_field_options = null; + parent::OnBeforeItemUpdate($event); + $object =& $event->getObject(); /* @var $object kDBItem */ // ability to validate each configuration variable separately - if (!isset($default_field_options)) { + if ( !isset($default_field_options) ) { $default_field_options = $object->GetFieldOptions('VariableValue'); } $new_field_options = $default_field_options; $validation = $object->GetDBField('Validation'); - if ($validation) { + + if ( $validation ) { $new_field_options = array_merge($new_field_options, unserialize($validation)); } + $object->SetFieldOptions('VariableValue', $new_field_options); // if password field is empty, then don't update - if ($object->GetDBField('ElementType') == 'password') { - if (trim($object->GetDBField('VariableValue')) == '') { + if ( $object->GetDBField('ElementType') == 'password' ) { + if ( trim($object->GetDBField('VariableValue')) == '' ) { $field_options = $object->GetFieldOptions('VariableValue'); $field_options['skip_empty'] = 1; $object->SetFieldOptions('VariableValue', $field_options); - }else { + } + else { $password_formatter =& $this->Application->recallObject('kPasswordFormatter'); + /* @var $password_formatter kPasswordFormatter */ + $object->SetDBField('VariableValue', $password_formatter->EncryptPassword($object->GetDBField('VariableValue'), 'b38')); } } - $field_values = $this->Application->GetVar( $event->getPrefixSpecial(true) ); - - $state_country_hash = Array ( - 'Comm_State' => 'Comm_Country', - 'Comm_Shipping_State' => 'Comm_Shipping_Country' - ); - $field_name = $object->GetDBField('VariableName'); - if (array_key_exists($field_name, $state_country_hash)) { + $field_values = $this->Application->GetVar($event->getPrefixSpecial(true)); + $state_country_hash = Array ('Comm_State' => 'Comm_Country', 'Comm_Shipping_State' => 'Comm_Shipping_Country'); + + if ( array_key_exists($field_name, $state_country_hash) ) { // if this is state field $sql = 'SELECT VariableId FROM ' . $this->Application->getUnitOption('conf', 'TableName') . ' @@ -110,16 +118,16 @@ $check_state = $object->GetDBField('VariableValue'); $check_country = $field_values[$country_variable_id]['VariableValue']; - if (!$check_country || !$check_state) { - return true; + if ( !$check_country || !$check_state ) { + return; } $cs_helper =& $this->Application->recallObject('CountryStatesHelper'); /* @var $cs_helper kCountryStatesHelper */ $state_iso = $cs_helper->getStateIso($check_state, $check_country); - if ($state_iso !== false) { + if ( $state_iso !== false ) { $object->SetDBField('VariableValue', $state_iso); } else { @@ -128,13 +136,12 @@ } } - if ($object->GetDBField('VariableName') == 'AdminConsoleInterface') { + if ( $object->GetDBField('VariableName') == 'AdminConsoleInterface' ) { $can_change = $this->Application->ConfigValue('AllowAdminConsoleInterfaceChange'); - if (($object->GetDBField('VariableValue') != $object->GetOriginalField('VariableValue')) && !$can_change) { + if ( ($object->GetDBField('VariableValue') != $object->GetOriginalField('VariableValue')) && !$can_change ) { $object->SetError('VariableValue', 'not_allowed', 'la_error_OperationNotAllowed'); } - } }