Index: in-commerce/units/affiliate_payment_types/affiliate_payment_types_event_handler.php =================================================================== --- in-commerce/units/affiliate_payment_types/affiliate_payment_types_event_handler.php (revision 15437) +++ in-commerce/units/affiliate_payment_types/affiliate_payment_types_event_handler.php (working copy) @@ -93,8 +93,7 @@ SET IsPrimary = 0'; $this->Conn->Query($sql); - $status_field = array_shift( $this->Application->getUnitOption($event->Prefix, 'StatusField') ); - $object->SetDBField($status_field, 1); + $object->SetDBField($object->getStatusField(), 1); } } Index: in-commerce/units/affiliate_plans/affiliate_plans_event_handler.php =================================================================== --- in-commerce/units/affiliate_plans/affiliate_plans_event_handler.php (revision 15437) +++ in-commerce/units/affiliate_plans/affiliate_plans_event_handler.php (working copy) @@ -96,8 +96,7 @@ SET IsPrimary = 0'; $this->Conn->Query($sql); - $status_field = array_shift($this->Application->getUnitOption($event->Prefix, 'StatusField')); - $object->SetDBField($status_field, 1); + $object->SetDBField($object->getStatusField(), 1); } } Index: in-commerce/units/affiliates/affiliates_event_handler.php =================================================================== --- in-commerce/units/affiliates/affiliates_event_handler.php (revision 15437) +++ in-commerce/units/affiliates/affiliates_event_handler.php (working copy) @@ -591,7 +591,7 @@ $ids = $this->StoreSelectedIDs($event); if ( $ids ) { - $status_field = array_shift($this->Application->getUnitOption($event->Prefix, 'StatusField')); + $status_field = $object->getStatusField(); foreach ($ids as $id) { $object->Load($id); Index: in-commerce/units/brackets/brackets_tag_processor.php =================================================================== --- in-commerce/units/brackets/brackets_tag_processor.php (revision 15437) +++ in-commerce/units/brackets/brackets_tag_processor.php (working copy) @@ -18,8 +18,9 @@ function Field($params) { $value = parent::Field($params); + $field = $this->SelectParam($params, 'name,field'); - if ( ($params['field'] == 'Start' || $params['name'] == 'End') && $value == -1) { + if ( ($field == 'Start' || $field == 'End') && $value == -1 ) { $value = '∞'; } @@ -29,6 +30,8 @@ function ShowBracketsForm($params) { $shipping_object = $this->Application->recallObject('s'); + /* @var $shipping_object kDBItem */ + $default_start = ($shipping_object->GetDBField('Type') == 1) ? 0 : 1; $brackets_helper = $this->Application->recallObject('BracketsHelper'); Index: in-commerce/units/destinations/dst_event_handler.php =================================================================== --- in-commerce/units/destinations/dst_event_handler.php (revision 15437) +++ in-commerce/units/destinations/dst_event_handler.php (working copy) @@ -92,7 +92,9 @@ $object = $event->getObject(); /* @var $object kDBItem */ - $zone_object = &$this->Application->recallObject('z'); + $zone_object = $this->Application->recallObject('z'); + /* @var $zone_object kDBItem */ + $zone_id = (int)$zone_object->GetID(); $zone_type = $zone_object->GetDBField('Type'); Index: in-commerce/units/orders/orders_event_handler.php =================================================================== --- in-commerce/units/orders/orders_event_handler.php (revision 15437) +++ in-commerce/units/orders/orders_event_handler.php (working copy) @@ -54,7 +54,8 @@ return false; } - $status_field = array_shift($this->Application->getUnitOption($event->Prefix, 'StatusField')); + $status_field = $order_dummy->getStatusField(); + if ( isset($field_values[$status_field]) && $order_dummy->GetDBField($status_field) != $field_values[$status_field] ) { // user can't change status by himself return false; @@ -3389,7 +3390,7 @@ */ function OnGoToOrder($event) { - $id = array_shift( $this->StoreSelectedIDs($event) ); + $id = current($this->StoreSelectedIDs($event)); $id_field = $this->Application->getUnitOption($event->Prefix,'IDField'); $table = $this->Application->getUnitOption($event->Prefix,'TableName'); Index: in-commerce/units/payment_type/payment_type_event_handler.php =================================================================== --- in-commerce/units/payment_type/payment_type_event_handler.php (revision 15437) +++ in-commerce/units/payment_type/payment_type_event_handler.php (working copy) @@ -84,7 +84,7 @@ $ids = $this->getSelectedIDs($event); if ( $ids ) { - $status_field = array_shift($this->Application->getUnitOption($event->Prefix, 'StatusField')); + $status_field = $object->getStatusField(); foreach ($ids as $id) { $object->Load($id); @@ -120,7 +120,7 @@ $object = $event->getObject(); /* @var $object kDBItem */ - $status_field = array_shift( $this->Application->getUnitOption($event->Prefix, 'StatusField') ); + $status_field = $object->getStatusField(); if ( $object->GetDBField('IsPrimary') == 1 && $object->GetDBField($status_field) == 0 ) { $object->SetDBField($status_field, 1); Index: in-commerce/units/pricing/pricing_event_handler.php =================================================================== --- in-commerce/units/pricing/pricing_event_handler.php (revision 15437) +++ in-commerce/units/pricing/pricing_event_handler.php (working copy) @@ -14,7 +14,7 @@ defined('FULL_PATH') or die('restricted access!'); // include globals.php from current folder -kUtil::includeOnce(MODULES_PATH .'/in-commerce/units/pricing/globals.php'); +kUtil::includeOnce(MODULES_PATH . '/in-commerce/units/pricing/globals.php'); class PricingEventHandler extends kDBEventHandler { Index: in-commerce/units/products/products_event_handler.php =================================================================== --- in-commerce/units/products/products_event_handler.php (revision 15437) +++ in-commerce/units/products/products_event_handler.php (working copy) @@ -115,7 +115,8 @@ if ($object->GetDBField('InventoryStatus') == 2) { // inventory by options (use first selected combination in grid) - $combination_id = array_shift( array_keys( $this->Application->GetVar('poc_grid') ) ); + $combinations = $this->Application->GetVar('poc_grid'); + list ($combination_id, ) = each($combinations); } else { // inventory by product @@ -945,21 +946,25 @@ $this->Conn->Query($sql); } - function OnPackageApprove($event){ + protected function OnPackageApprove(kEvent $event) + { $field_values = $event->getEventParam('field_values'); $item_data = unserialize($field_values['ItemData']); $package_content_ids = $item_data['PackageContent']; + $object_item = $this->Application->recallObject('p.packageitem', null, array ('skip_autoload' => true)); + /* @var $object_item ProductsItem */ + foreach ($package_content_ids as $package_item_id) { + $object_field_values = array (); - $object_item = &$this->Application->recallObject('p.packageitem', null, array('skip_autoload'=>true)); - foreach ($package_content_ids as $package_item_id) { - $object_field_values = array(); - // query processing data from product and run approve event - $sql = 'SELECT ProcessingData FROM '.TABLE_PREFIX.'Products WHERE ProductId = '.$package_item_id; + // query processing data from product and run approve event + $sql = 'SELECT ProcessingData + FROM ' . TABLE_PREFIX . 'Products + WHERE ProductId = ' . $package_item_id; $processing_data = $this->Conn->GetOne($sql); - if($processing_data) - { + + if ( $processing_data ) { $processing_data = unserialize($processing_data); $approve_event = new kEvent($processing_data['ApproveEvent']); @@ -974,10 +979,7 @@ $approve_event->setEventParam('field_values', $object_field_values); $this->Application->HandleEvent($approve_event); } - - } - } /** @@ -1219,7 +1221,7 @@ } - function ProcessPackageItems($event) + function ProcessPackageItems(kEvent $event) { //$this->Application->SetVar('p_mode', 't'); @@ -1239,7 +1241,7 @@ /* $this->Application->SetVar('p_mode', false); - $list = &$this->Application->recallObject('p.content', 'p_List', array('types'=>'content')); + $list = $this->Application->recallObject('p.content', 'p_List', array('types'=>'content')); $this->Application->SetVar('p_mode', 't'); Index: in-commerce/units/products/products_tag_processor.php =================================================================== --- in-commerce/units/products/products_tag_processor.php (revision 15437) +++ in-commerce/units/products/products_tag_processor.php (working copy) @@ -177,7 +177,8 @@ function ListRelatedProducts($params) { -// $related = &$this->Application->recallObject('rel'); +// $related = $this->Application->recallObject('rel'); + return $this->PrintList2($params); } @@ -536,13 +537,17 @@ function IsSubscription($params) { - $object = &$this->Application->recallObject($this->getPrefixSpecial()); + $object = $this->getObject($params); + /* @var $object kDBItem */ + return ($object->GetDBField('Type') == 2); } function IsTangible($params) { - $object = &$this->Application->recallObject($this->getPrefixSpecial()); + $object = $this->getObject($params); + /* @var $object kDBItem */ + return ($object->GetDBField('Type') == 1); } Index: in-commerce/units/shipping/shipping_tag_processor.php =================================================================== --- in-commerce/units/shipping/shipping_tag_processor.php (revision 15437) +++ in-commerce/units/shipping/shipping_tag_processor.php (working copy) @@ -13,6 +13,9 @@ defined('FULL_PATH') or die('restricted access!'); +// include globals.php from current folder +kUtil::includeOnce(MODULES_PATH . '/in-commerce/units/pricing/globals.php'); + class ShippingTagProcessor extends kDBTagProcessor { function CostInputSize($params) @@ -300,24 +303,35 @@ return $o; } - function ListGroups($params) + protected function ListGroups($params) { + $object = $this->getObject($params); + /* @var $object kDBItem */ - $object = $this->getObject($params); + $o = ''; $selected = trim($object->GetDBField('PortalGroups'), ','); $selected_arr = explode(',', $selected); - $all_groups = $this->Conn->Query('SELECT GroupId, Name FROM '.TABLE_PREFIX.'UserGroups ORDER BY NAME', 'GroupId'); - $o = ''; - foreach ($all_groups as $a_group) - { + $sql = 'SELECT GroupId, Name + FROM ' . TABLE_PREFIX . 'UserGroups + ORDER BY Name'; + $all_groups = $this->Conn->Query($sql, 'GroupId'); + + $mode = array_key_exists('mode', $params) ? $params['mode'] : false; + + foreach ($all_groups as $a_group) { $is_selected = in_array($a_group['GroupId'], $selected_arr); - $continue = $params['mode'] == 'selected' ? !$is_selected : $is_selected; - if ($continue) continue; + $continue = $mode == 'selected' ? !$is_selected : $is_selected; + + if ( $continue ) { + continue; + } + $block_params = $a_group; - $block_params['name'] = $params['render_as']; + $block_params['name'] = $params['render_as']; $o .= $this->Application->ParseBlock($block_params); } + return $o; } } \ No newline at end of file Index: in-commerce/units/taxes/taxes_event_handler.php =================================================================== --- in-commerce/units/taxes/taxes_event_handler.php (revision 15437) +++ in-commerce/units/taxes/taxes_event_handler.php (working copy) @@ -239,7 +239,8 @@ function OnCountryChange($event) { - $destinations = &$this->Application->recallObject('taxdst'); + $destinations = $this->Application->recallObject('taxdst'); + /* @var $destinations kDBItem */ $queryDel="DELETE FROM ".$destinations->TableName." WHERE TaxZoneId=".(int)$this->Application->GetVar('tax_id'); $this->Conn->Query($queryDel); Index: in-commerce/units/taxesdestinations/taxes_dst_event_handler.php =================================================================== --- in-commerce/units/taxesdestinations/taxes_dst_event_handler.php (revision 15437) +++ in-commerce/units/taxesdestinations/taxes_dst_event_handler.php (working copy) @@ -138,7 +138,9 @@ $object = $event->getObject(); /* @var $object kDBItem */ - $zone_object = &$this->Application->recallObject('tax'); + $zone_object = $this->Application->recallObject('tax'); + /* @var $zone_object kDBItem */ + $zone_id = (int)$this->Application->GetVar('tax_id'); $zone_type = $zone_object->GetDBField('Type'); Index: in-commerce/units/zones/zones_event_handler.php =================================================================== --- in-commerce/units/zones/zones_event_handler.php (revision 15437) +++ in-commerce/units/zones/zones_event_handler.php (working copy) @@ -220,7 +220,8 @@ function OnCountryChange($event) { - $destinations = &$this->Application->recallObject('dst'); + $destinations = $this->Application->recallObject('dst'); + /* @var $destinations kDBItem */ $queryDel="DELETE FROM ".$destinations->TableName." WHERE ShippingZoneId=".$this->Application->GetVar($event->Prefix.'_id'); $this->Conn->Query($queryDel); @@ -242,7 +243,7 @@ { parent::OnCancel($event); - $dst_object = &$this->Application->recallObject('dst'); + $dst_object = $this->Application->recallObject('dst'); /* @var $dst_object kDBItem */ $sql = 'DELETE FROM ' . $dst_object->TableName . '