getObject(); $module = $this->Application->GetVar('module'); $section = $this->Application->GetVar('section'); $object->addFilter('module_filter', '%1$s.ModuleOwner = '.$this->Conn->qstr($module)); $object->addFilter('section_filter', '%1$s.Section = '.$this->Conn->qstr($section)); } /** * Enter description here... * * @param kEvent $event */ function OnBeforeItemUpdate(&$event) { $object =& $event->getObject(); // if password field is empty, then don't update 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'))); } } $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 (isset($state_country_hash[$field_name])) { // if this is state field $check_state = $object->GetDBField('VariableValue'); $check_country = $field_values[ $state_country_hash[$field_name] ]['VariableValue']; if (!($check_country && $check_state)) { return true; } $cs_helper =& $this->Application->recallObject('CountryStatesHelper'); $state_iso = $cs_helper->CheckState($check_state, $check_country); if ($state_iso !== false) { $object->SetDBField('VariableValue', $state_iso); } else { $errormsgs = $this->Application->GetVar('errormsgs'); $errors = !$errormsgs || !isset($errormsgs[$event->Prefix_Special]) ? Array() : $errormsgs[$event->Prefix_Special]; $errors[$field_name] = 'la_InvalidState'; $errormsgs[$event->Prefix_Special] = $errors; $this->Application->SetVar('errormsgs', $errormsgs); $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); } } } /** * Enter description here... * * @param kEvent $event */ function OnUpdate(&$event) { if (!$this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 0)) { parent::OnUpdate($event); } $event->SetRedirectParam('opener', 's'); if ($this->Application->GetVar('errormsgs')) { // because we have list out there, and this is item $this->Application->removeObject($event->getPrefixSpecial()); $event->redirect = false; } } function OnCancel(&$event) { parent::OnCancel($event); $event->SetRedirectParam('opener', 's'); } /** * 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; } } ?>