Index: branches/5.2.x/core/units/country_states/country_state_eh.php =================================================================== diff -u -N -r14095 -r14244 --- branches/5.2.x/core/units/country_states/country_state_eh.php (.../country_state_eh.php) (revision 14095) +++ branches/5.2.x/core/units/country_states/country_state_eh.php (.../country_state_eh.php) (revision 14244) @@ -1,110 +1,110 @@ -getObject(); - /* @var $object kDBList */ - - if (($event->Special == 'selected') || ($event->Special == 'available')) { - $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper'); - /* @var $edit_picker_helper EditPickerHelper */ - - $edit_picker_helper->applyFilter($event, 'Countries'); - - // only countries - $object->addFilter('type_filter', '%1$s.Type = ' . DESTINATION_TYPE_COUNTRY); - } - } - - /** - * Makes sure, that state country is always specified - * - * @param kEvent $event - */ - function OnBeforeItemCreate(&$event) - { - parent::OnBeforeItemCreate($event); - - $this->_setRequired($event); - } - - /** - * Makes sure, that state country is always specified - * - * @param kEvent $event - */ - function OnBeforeItemUpdate(&$event) - { - parent::OnBeforeItemUpdate($event); - - $this->_setRequired($event); - } - - /** - * Makes sure, that state country is always specified - * - * @param kEvent $event - */ - function _setRequired(&$event) - { - $object =& $event->getObject(); - /* @var $object kDBItem */ - - $field_options = $object->GetFieldOptions('IsoCode'); - - if ($object->GetDBField('Type') == DESTINATION_TYPE_STATE) { - $object->setRequired('StateCountryId'); - $field_options['unique'] = Array ('Type', 'StateCountryId'); - } - else { - $object->setRequired('StateCountryId', false); - $field_options['unique'] = Array ('Type'); - } - - $object->SetFieldOptions('IsoCode', $field_options); - } - - /** - * Don't allow to delete countries, that have states - * - * @param kEvent $event - */ - function OnBeforeItemDelete(&$event) - { - parent::OnBeforeItemDelete($event); - - $object =& $event->getObject(); - /* @var $object kDBItem */ - - $cs_helper =& $this->Application->recallObject('CountryStatesHelper'); - /* @var $cs_helper kCountryStatesHelper */ - - if ($cs_helper->CountryHasStates( $object->GetDBField('IsoCode') )) { - $event->status = kEvent::erFAIL; - return ; - } - } - } +getObject(); + /* @var $object kDBList */ + + if (($event->Special == 'selected') || ($event->Special == 'available')) { + $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper'); + /* @var $edit_picker_helper EditPickerHelper */ + + $edit_picker_helper->applyFilter($event, 'Countries'); + + // only countries + $object->addFilter('type_filter', '%1$s.Type = ' . DESTINATION_TYPE_COUNTRY); + } + } + + /** + * Makes sure, that state country is always specified + * + * @param kEvent $event + */ + function OnBeforeItemCreate(&$event) + { + parent::OnBeforeItemCreate($event); + + $this->_setRequired($event); + } + + /** + * Makes sure, that state country is always specified + * + * @param kEvent $event + */ + function OnBeforeItemUpdate(&$event) + { + parent::OnBeforeItemUpdate($event); + + $this->_setRequired($event); + } + + /** + * Makes sure, that state country is always specified + * + * @param kEvent $event + */ + function _setRequired(&$event) + { + $object =& $event->getObject(); + /* @var $object kDBItem */ + + $field_options = $object->GetFieldOptions('IsoCode'); + + if ($object->GetDBField('Type') == DESTINATION_TYPE_STATE) { + $object->setRequired('StateCountryId'); + $field_options['unique'] = Array ('Type', 'StateCountryId'); + } + else { + $object->setRequired('StateCountryId', false); + $field_options['unique'] = Array ('Type'); + } + + $object->SetFieldOptions('IsoCode', $field_options); + } + + /** + * Don't allow to delete countries, that have states + * + * @param kEvent $event + */ + function OnBeforeItemDelete(&$event) + { + parent::OnBeforeItemDelete($event); + + $object =& $event->getObject(); + /* @var $object kDBItem */ + + $cs_helper =& $this->Application->recallObject('CountryStatesHelper'); + /* @var $cs_helper kCountryStatesHelper */ + + if ($cs_helper->CountryHasStates( $object->GetDBField('IsoCode') )) { + $event->status = kEvent::erFAIL; + return ; + } + } + }