Index: branches/5.3.x/units/links/links_event_handler.php =================================================================== diff -u -N -r15672 -r15696 --- branches/5.3.x/units/links/links_event_handler.php (.../links_event_handler.php) (revision 15672) +++ branches/5.3.x/units/links/links_event_handler.php (.../links_event_handler.php) (revision 15696) @@ -1,6 +1,6 @@ Application->getUnitOption($event->Prefix, 'IDField'); - $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); + $config = $event->getUnitConfig(); + $id_field = $config->getIDField(); + $table_name = $config->getTableName(); + $sql = 'SELECT * FROM ' . $table_name . ' WHERE ' . $id_field . ' IN (' . implode(',', $ids) . ')'; @@ -245,13 +247,14 @@ { parent::OnAfterConfigRead($event); - if (defined('IS_INSTALL') && IS_INSTALL) { - return ; + if ( defined('IS_INSTALL') && IS_INSTALL ) { + return; } + $config = $event->getUnitConfig(); $free_listings = $this->Application->ConfigValue('Link_AllowFreeListings'); - $virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields'); + $virtual_fields = $config->getVirtualFields(); $virtual_fields['ListingTypeId']['options'] = $free_listings ? Array (0 => 'lu_free_listing') : Array (); $language_id = $this->Application->GetVar('m_lang'); @@ -261,11 +264,11 @@ $default = $virtual_fields['DuplicateCheckFields']['default']; $virtual_fields['DuplicateCheckFields']['default'] = str_replace('|Name|', '|l' . $language_id . '_Name|', $default); - $this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields); + $config->setVirtualFields($virtual_fields); - if (!$this->Application->isAdminUser) { + if ( !$this->Application->isAdminUser ) { // for now only on Front-End - $this->Application->setUnitOption($event->Prefix, 'PopulateMlFields', true); + $event->getUnitConfig()->setPopulateMlFields(true); } } @@ -425,8 +428,9 @@ $link_helper = $this->Application->recallObject('LinkHelper'); /* @var $link_helper LinkHelper */ - $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); - $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); + $config = $event->getUnitConfig(); + $id_field = $config->getIDField(); + $table_name = $config->getTableName(); // 1. verify all links, that were not verified previously $sql = 'SELECT ' . $id_field . ' @@ -493,8 +497,10 @@ $load_keys[$field] = $field . ' = ' . $this->Conn->qstr($value); } - $sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . ' - FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . ' + $config = $event->getUnitConfig(); + + $sql = 'SELECT ' . $config->getIDField() . ' + FROM ' . $config->getTableName() . ' WHERE (' . implode(') AND (', $load_keys) . ')'; $id = $this->Conn->GetOne($sql); } @@ -527,22 +533,24 @@ parent::OnCloneSubItem($event); if ( $event->MasterEvent->Prefix == 'rev' ) { - $clones = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'Clones'); - $subitem_prefix = $event->Prefix . '-' . $event->MasterEvent->Prefix; + $master_config = $event->MasterEvent->getUnitConfig(); + $sub_item_prefix = $event->Prefix . '-' . $event->MasterEvent->Prefix; - $clones[$subitem_prefix]['ConfigMapping'] = Array ( - 'PerPage' => 'Perpage_LinkReviews', - 'ShortListPerPage' => 'Perpage_LinkReviews_Short', - 'DefaultSorting1Field' => 'Link_ReviewsSort', - 'DefaultSorting2Field' => 'Link_ReviewsSort2', - 'DefaultSorting1Dir' => 'Link_ReviewsOrder', - 'DefaultSorting2Dir' => 'Link_ReviewsOrder2', + $master_config->addClones(Array ( + $sub_item_prefix => Array ( + 'ConfigMapping' => Array ( + 'PerPage' => 'Perpage_LinkReviews', + 'ShortListPerPage' => 'Perpage_LinkReviews_Short', + 'DefaultSorting1Field' => 'Link_ReviewsSort', + 'DefaultSorting2Field' => 'Link_ReviewsSort2', + 'DefaultSorting1Dir' => 'Link_ReviewsOrder', + 'DefaultSorting2Dir' => 'Link_ReviewsOrder2', - 'ReviewDelayInterval' => 'link_ReviewDelay_Interval', - 'ReviewDelayValue' => 'link_ReviewDelay_Value', - ); - - $this->Application->setUnitOption($event->MasterEvent->Prefix, 'Clones', $clones); + 'ReviewDelayInterval' => 'link_ReviewDelay_Interval', + 'ReviewDelayValue' => 'link_ReviewDelay_Value', + ) + ) + )); } } @@ -562,10 +570,11 @@ $link_id = $event->getEventParam('original_id'); $new_resource_id = $object->GetDBField('ResourceId'); + $config = $event->getUnitConfig(); $sql = 'SELECT ResourceId - FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . ' - WHERE ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . '=' . $link_id; + FROM ' . $config->getTableName() . ' + WHERE ' . $config->getIDField() . '=' . $link_id; $old_resource_id = $this->Conn->GetOne($sql); $this->Application->SetVar('original_resource_id', $old_resource_id); @@ -605,7 +614,7 @@ protected function changeResourceId($prefix, $field, $old_resource_id, $new_resource_id) { $fields_hash = Array ($field => $new_resource_id); - $table_name = $this->Application->getUnitOption($prefix, 'TableName'); + $table_name = $this->Application->getUnitConfig($prefix)->getTableName(); $this->Conn->doUpdate($fields_hash, $table_name, $field . ' = ' . $old_resource_id); }