Index: branches/5.3.x/core/units/custom_fields/custom_fields_event_handler.php =================================================================== diff -u -N -r15483 -r15698 --- branches/5.3.x/core/units/custom_fields/custom_fields_event_handler.php (.../custom_fields_event_handler.php) (revision 15483) +++ branches/5.3.x/core/units/custom_fields/custom_fields_event_handler.php (.../custom_fields_event_handler.php) (revision 15698) @@ -1,6 +1,6 @@ Conn->qstr( $this->Application->GetVar('cf_type') ); + FROM ' . TABLE_PREFIX . 'ItemTypes + WHERE ItemType = ' . $this->Conn->qstr($this->Application->GetVar('cf_type')); $main_prefix = $this->Conn->GetOne($sql); - $section = $this->Application->getUnitOption($main_prefix.'.custom', 'PermSection'); + $section = $this->Application->getUnitConfig($main_prefix)->getPermSectionByName('custom'); $event->setEventParam('PermSection', $section); return parent::CheckPermission($event); @@ -52,9 +52,10 @@ /* @var $object kDBList */ $item_type = $this->Application->GetVar('cf_type'); + if ( !$item_type ) { $prefix = $event->getEventParam('SourcePrefix'); - $item_type = $this->Application->getUnitOption($prefix, 'ItemType'); + $item_type = $this->Application->getUnitConfig($prefix)->getItemType(); } if ( $event->Special == 'general' ) { @@ -85,10 +86,11 @@ function _getSourcePrefix($event) { $prefix = $event->getEventParam('SourcePrefix'); - if (!$prefix) { + + if ( !$prefix ) { $sql = 'SELECT Prefix FROM ' . TABLE_PREFIX . 'ItemTypes - WHERE ItemType = ' . $this->Conn->qstr( $this->Application->GetVar('cf_type') ); + WHERE ItemType = ' . $this->Conn->qstr($this->Application->GetVar('cf_type')); $prefix = $this->Conn->GetOne($sql); } @@ -104,17 +106,15 @@ */ protected function _getHiddenFields($event) { - $prefix = $this->_getSourcePrefix($event); - $hidden_fields = Array (); - $virtual_fields = $this->Application->getUnitOption($prefix, 'VirtualFields', Array ()); - $custom_fields = $this->Application->getUnitOption($prefix, 'CustomFields', Array ()); - /* @var $custom_fields Array */ + $config = $this->Application->getUnitConfig($this->_getSourcePrefix($event)); - foreach ($custom_fields as $custom_field) { + foreach ($config->getCustomFields(Array ()) as $custom_field) { $check_field = 'cust_' . $custom_field; - $show_mode = array_key_exists('show_mode', $virtual_fields[$check_field]) ? $virtual_fields[$check_field]['show_mode'] : true; + $field_options = $config->getVirtualFieldByName($check_field); + $show_mode = array_key_exists('show_mode', $field_options) ? $field_options['show_mode'] : true; + if ( ($show_mode === false) || (($show_mode === smDEBUG) && !(defined('DEBUG_MODE') && DEBUG_MODE)) ) { $hidden_fields[] = $custom_field; } @@ -138,7 +138,7 @@ /* @var $object kDBItem */ $sql = 'SELECT COUNT(*) - FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . ' + FROM ' . $event->getUnitConfig()->getTableName() . ' WHERE FieldName = ' . $this->Conn->qstr($object->GetDBField('FieldName')) . ' AND Type = ' . $object->GetDBField('Type'); $found = $this->Conn->GetOne($sql); @@ -169,7 +169,7 @@ /* @var $ml_helper kMultiLanguageHelper */ // call main item config to clone cdata table - $this->Application->getUnitOption($main_prefix, 'TableName'); + $this->Application->getUnitConfig($main_prefix)->getTableName(); $ml_helper->deleteField($main_prefix . '-cdata', $event->getEventParam('id')); } @@ -212,7 +212,7 @@ // call main item config to clone cdata table define('CUSTOM_FIELD_ADDED', 1); // used in cdata::scanCustomFields method - $this->Application->getUnitOption($main_prefix, 'TableName'); + $this->Application->getUnitConfig($main_prefix)->getTableName(); $ml_helper->createFields($main_prefix . '-cdata'); }