Index: branches/5.3.x/units/products/products_event_handler.php =================================================================== diff -u -N -r15671 -r15695 --- branches/5.3.x/units/products/products_event_handler.php (.../products_event_handler.php) (revision 15671) +++ branches/5.3.x/units/products/products_event_handler.php (.../products_event_handler.php) (revision 15695) @@ -1,6 +1,6 @@ GetDBField('InventoryStatus') == 2)) { // if combination id present and inventory by combinations - $poc_idfield = $this->Application->getUnitOption('poc', 'IDField'); - $poc_tablename = $this->Application->getUnitOption('poc', 'TableName'); + $poc_config = $this->Application->getUnitConfig('poc'); + $sql = 'SELECT QtyInStock - FROM '.$poc_tablename.' - WHERE '.$poc_idfield.' = '.$combination_id; + FROM '. $poc_config->getTableName() .' + WHERE '. $poc_config->getIDField() .' = '.$combination_id; $stock_qty = $this->Conn->GetOne($sql); } else { @@ -620,13 +620,13 @@ // my favorite products: begin if ( in_array('wish_list', $types) || in_array('wish_list', $except_types) ) { $sql = 'SELECT ResourceId - FROM ' . $this->Application->getUnitOption('fav', 'TableName') . ' + FROM ' . $this->Application->getUnitConfig('fav')->getTableName() . ' WHERE PortalUserId = ' . (int)$this->Application->RecallVar('user_id'); - $wishlist_ids = $this->Conn->GetCol($sql); + $wish_list_ids = $this->Conn->GetCol($sql); - if ( $wishlist_ids ) { - $type_clauses['wish_list']['include'] = '%1$s.ResourceId IN (' . implode(',', $wishlist_ids) . ') AND PrimaryCat = 1'; - $type_clauses['wish_list']['except'] = '%1$s.ResourceId NOT IN (' . implode(',', $wishlist_ids) . ') AND PrimaryCat = 1'; + if ( $wish_list_ids ) { + $type_clauses['wish_list']['include'] = '%1$s.ResourceId IN (' . implode(',', $wish_list_ids) . ') AND PrimaryCat = 1'; + $type_clauses['wish_list']['except'] = '%1$s.ResourceId NOT IN (' . implode(',', $wish_list_ids) . ') AND PrimaryCat = 1'; } else { $type_clauses['wish_list']['include'] = '0'; @@ -893,9 +893,11 @@ return false; } + $orders_config = $this->Application->getUnitConfig('ord'); + $sql = 'SELECT PortalUserId - FROM ' . $this->Application->getUnitOption('ord', 'TableName') . ' - WHERE ' . $this->Application->getUnitOption('ord', 'IDField') . ' = ' . $field_values['OrderId']; + FROM ' . $orders_config->getTableName() . ' + WHERE ' . $orders_config->getIDField() . ' = ' . $field_values['OrderId']; $user_id = $this->Conn->GetOne($sql); $group_id = $item_data['PortalGroupId']; @@ -935,19 +937,18 @@ $sub_order->SetDBField('NextCharge_time', $expire); } - function OnDownloadableApprove($event) + function OnDownloadableApprove(kEvent $event) { $field_values = $event->getEventParam('field_values'); $product_id = $field_values['ProductId']; - $sql = 'SELECT PortalUserId FROM '.$this->Application->getUnitOption('ord', 'TableName').' + $sql = 'SELECT PortalUserId FROM '.$this->Application->getUnitConfig('ord')->getTableName().' WHERE OrderId = '.$field_values['OrderId']; $user_id = $this->Conn->GetOne($sql); $sql = 'INSERT INTO '.TABLE_PREFIX.'UserFileAccess VALUES("", '.$product_id.', '.$user_id.')'; $this->Conn->Query($sql); } - protected function OnPackageApprove(kEvent $event) - { + function OnPackageApprove(kEvent $event){ $field_values = $event->getEventParam('field_values'); $item_data = unserialize($field_values['ItemData']); $package_content_ids = $item_data['PackageContent']; @@ -956,9 +957,9 @@ /* @var $object_item ProductsItem */ foreach ($package_content_ids as $package_item_id) { - $object_field_values = array (); + $object_field_values = array(); - // query processing data from product and run approve event + // query processing data from product and run approve event $sql = 'SELECT ProcessingData FROM ' . TABLE_PREFIX . 'Products WHERE ProductId = ' . $package_item_id; @@ -1456,9 +1457,11 @@ ORDER BY MinQty LIMIT 0,1'; - $calculated_fields = $this->Application->getUnitOption($event->Prefix, 'CalculatedFields'); - $calculated_fields['']['Price'] = 'IFNULL((' . $sub_select . '), ' . $calculated_fields['']['Price'] . ')'; - $this->Application->setUnitOption($event->Prefix, 'CalculatedFields', $calculated_fields); + $config = $event->getUnitConfig(); + + $calculated_fields = $config->getCalculatedFieldsBySpecial(''); + $calculated_fields['Price'] = 'IFNULL((' . $sub_select . '), ' . $calculated_fields['Price'] . ')'; + $config->setCalculatedFieldsBySpecial('', $calculated_fields); } /** @@ -1482,9 +1485,9 @@ */ function OnModifyPaidListingConfig($event) { - $edit_tab_presets = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'EditTabPresets'); - $edit_tab_presets['Default']['shopping_cart'] = Array ('title' => 'la_tab_ShopCartEntry', 't' => 'in-commerce/paid_listings/paid_listing_type_shopcart', 'priority' => 2); - $this->Application->setUnitOption($event->MasterEvent->Prefix, 'EditTabPresets', $edit_tab_presets); + $event->MasterEvent->getUnitConfig()->addEditTabPresetTabs('Default', Array ( + 'shopping_cart' => Array ('title' => 'la_tab_ShopCartEntry', 't' => 'in-commerce/paid_listings/paid_listing_type_shopcart', 'priority' => 2), + )); } /** @@ -1499,17 +1502,18 @@ parent::OnCloneSubItem($event); if ( $event->MasterEvent->Prefix == 'rev' ) { - $clones = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'Clones'); - $subitem_prefix = $event->Prefix . '-' . $event->MasterEvent->Prefix; + $sub_item_prefix = $event->Prefix . '-' . $event->MasterEvent->Prefix; - $clones[$subitem_prefix]['ConfigMapping'] = Array ( + $event->MasterEvent->getUnitConfig()->addClones(Array ( + $sub_item_prefix => Array ( + 'ConfigMapping' => Array ( 'PerPage' => 'Comm_Perpage_Reviews', 'ReviewDelayInterval' => 'product_ReviewDelay_Value', 'ReviewDelayValue' => 'product_ReviewDelay_Interval', - ); - - $this->Application->setUnitOption($event->MasterEvent->Prefix, 'Clones', $clones); + ), + ), + )); } }