Index: trunk/kernel/units/configuration/configuration_event_handler.php =================================================================== diff -u -N --- trunk/kernel/units/configuration/configuration_event_handler.php (revision 1557) +++ trunk/kernel/units/configuration/configuration_event_handler.php (revision 0) @@ -1,163 +0,0 @@ -getObject(); - - $module_owner=$this->Application->GetVar('module'); - if ($module_owner===false) { - $module_owner=$this->myUrlDecode($this->Application->GetVar('conf_module')); - $this->Application->SetVar("module", $module_owner); - } - - $section=$this->Application->GetVar('section'); - if ($section===false){ - $section=$this->myUrlDecode($this->Application->GetVar('conf_section')); - $this->Application->SetVar("section", $section); - } - - $object->addFilter('module_filter', '%1$s.ModuleOwner = "'.$module_owner.'"'); - $object->addFilter('section_filter', '%1$s.Section = "'.$section.'"'); - $object->AddOrderField('DisplayOrder', 'ASC'); - } - - /** - * Enter description here... - * - * @param kEvent $event - */ - function OnBeforeItemUpdate(&$event) - { - $object =& $event->getObject(); - if($object->GetDBField('element_type') == 'password') - { - if (trim($object->GetDBField('VariableValue'))=='') { - $field_options=$object->GetFieldOptions('VariableValue'); - $field_options['skip_empty']=1; - $object->SetFieldOptions('VariableValue', $field_options); - }else{ - $object->SetDBField('VariableValue', md5($object->GetDBField('VariableValue'))); - } - } - - $this->country_state_pairs = Array('Comm_Country' => 'Comm_State', 'Comm_Shipping_Country' => 'Comm_Shipping_State'); - - if ( isset($this->country_state_pairs[$object->GetDBField('VariableName')]) ){ - $this->state_country_codes[$this->country_state_pairs[$object->GetDBField('VariableName')]]=$object->GetDBField('VariableValue'); - } - - if( isset($this->state_country_codes[$object->GetDBField('VariableName')]) ) - { - $cs_helper = &$this->Application->recallObject('CountryStatesHelper'); - $state_valid_code = $cs_helper->CheckState( $object->GetDBField('VariableValue'), $this->state_country_codes[$object->GetDBField('VariableName')] ); - if ($state_valid_code !== false) - { - $object->SetDBField('VariableValue', $state_valid_code); - } - else - { - $errormsgs = $this->Application->GetVar('errormsgs'); - $errors = !$errormsgs || !isset($errormsgs[$event->Prefix_Special]) ? Array() : $errormsgs[$event->Prefix_Special]; - - $errors[ $object->GetDBField('VariableName') ] = 'la_InvalidState'; - $errormsgs[$event->Prefix_Special] = $errors; - - $this->Application->SetVar('errormsgs', $errormsgs); - - $event->redirect = false; - $event->status = erFAIL; - } - } - - } - - /** - * Enter description here... - * - * @param kEvent $event - */ - function OnAfterItemUpdate(&$event) - { - $object =& $event->getObject(); - if($object->GetDBField('element_type') == 'password') - { - if (trim($object->GetDBField('VariableValue'))=='') { - $field_options=$object->GetFieldOptions('VariableValue'); - unset($field_options['skip_empty']); - $object->SetFieldOptions('VariableValue', $field_options); - } - } - } - - function OnUpdate(&$event) - { - parent::OnUpdate($event); - $module_owner=$this->Application->GetVar('module'); - $section=$this->Application->GetVar('section'); - - $event->redirect_params = Array('opener' => 's','conf_section'=>$this->myUrlEncode($section), 'conf_module'=>$this->myUrlEncode($module_owner),'pass'=>'all,conf'); //stay! - if ($this->Application->GetVar('errormsgs')){ - $event->redirect = false; - } - } - - function OnCancel(&$event) - { - parent::OnCancel($event); - $module_owner=$this->Application->GetVar('module'); - $section=$this->Application->GetVar('section'); - - $event->redirect_params = Array('opener' => 's','conf_section'=>$this->myUrlEncode($section), 'conf_module'=>$this->myUrlEncode($module_owner),'pass'=>'all,conf'); //stay! - } - - function myUrlDecode($str){ - $str=str_replace(';',':', $str); - $str=str_replace('!','-', $str); - return $str; - } - - function myUrlEncode($str){ - $str=str_replace('-', '!', $str); - $str=str_replace(':', ';', $str); - return $str; - } - - /** - * Enter description here... - * - * @param kEvent $event - */ - function OnChangeCountry(&$event) - { - $event->setPseudoClass('_List'); - $object = &$event->getObject( Array('per_page'=>-1) ); - $object->Query(); - //$object->SetDBField(''); - $array_records = &$object->Records; - foreach($array_records as $i=>$record){ - if ($record['VariableName']=='Comm_Country'){ - $values = $this->Application->GetVar('conf'); - $array_records[$i]['VariableValue'] = $values['Comm_Country']['VariableValue']; - } - } - - $event->redirect_params = Array('opener' => 's', 'pass'=>'all,conf'); //stay! - $event->redirect = false; - } - - - - } - - - -?> \ No newline at end of file