Index: branches/5.3.x/units/pricing/pricing_config.php =================================================================== diff -u -N -r15656 -r16192 --- branches/5.3.x/units/pricing/pricing_config.php (.../pricing_config.php) (revision 15656) +++ branches/5.3.x/units/pricing/pricing_config.php (.../pricing_config.php) (revision 16192) @@ -1,6 +1,6 @@ Array ( - 'Access' => Array ( - 'Icons' => Array ('default'=> 'icon16_pricing.gif', '0'=> 'icon16_pricing.gif', '1'=> 'icon16_pricing_primary.gif'), - 'Fields' => Array ( - 'AccessDuration' => Array ('data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'), - 'AccessUnit' => Array ( 'title'=> 'column:la_fld_AccessDurationUnit', 'filter_block' => 'grid_options_filter'), - 'Description' => Array ('filter_block' => 'grid_like_filter'), - 'Price' => Array ( 'filter_block' => 'grid_range_filter'), + 'Grids' => array( + 'Access' => array( + 'Icons' => array( + 'default' => 'icon16_item.png', + '0' => 'icon16_item.png', + '1' => 'icon16_primary.png', + 'module' => 'core', ), + 'Fields' => array( + 'AccessDuration' => array('data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'), + 'AccessUnit' => array('title' => 'column:la_fld_AccessDurationUnit', 'filter_block' => 'grid_options_filter'), + 'Description' => array('filter_block' => 'grid_like_filter'), + 'Price' => array('filter_block' => 'grid_range_filter'), + ), ), ), -); \ No newline at end of file +); Index: branches/5.3.x/units/affiliates/affiliates_tag_processor.php =================================================================== diff -u -N -r16106 -r16192 --- branches/5.3.x/units/affiliates/affiliates_tag_processor.php (.../affiliates_tag_processor.php) (revision 16106) +++ branches/5.3.x/units/affiliates/affiliates_tag_processor.php (.../affiliates_tag_processor.php) (revision 16192) @@ -1,6 +1,6 @@ getObject($params); - /* @var $object kDBItem */ - $params['affiliate'] = $object->GetDBField('AffiliateCode'); - $params['prefix'] = '_FRONT_END_'; - $params['index_file'] = 'index.php'; - - // to build non-SSL link without SID in case, when SSL is enabled (or SSL domain doesn't match non-SSL domain) - $params['__SSL__'] = 0; - $params['__NO_SID__'] = 1; - - $link = $this->Application->ProcessParsedTag('m', 'Link', $params); - - // remove env manually - return preg_replace('/(.*)\/index.php\?env=(.*?)&(.*)/', '\\1/index.php?\\3', $link); + return $this->buildAffiliateLink($object); } /** * Returns link to be placed on other sites (for current user) * - * @param Array $params + * @param array $params Tag params. + * * @return string */ - function GetUserAffiliateLink($params) + protected function GetUserAffiliateLink(array $params) { - $object = $this->getObject(kUtil::array_merge_recursive($params, array('skip_autoload' => true))); - /* @var $object kDBItem */ + /** @var kDBItem $object */ + $object = $this->Application->recallObject($this->Prefix . '.manual', null, array('skip_autoload' => true)); + $object->Load($this->Application->RecallVar('user_id'), 'PortalUserId'); - $object->Load(array('PortalUserId' => $this->Application->RecallVar('user_id'))); + return $this->buildAffiliateLink($object); + } - $params['index_file'] = 'index.php'; + /** + * Builds affiliate link for given affiliate record. + * + * @param kDBBase $object Affiliate. + * + * @return string + */ + protected function buildAffiliateLink(kDBBase $object) + { $params['affiliate'] = $object->GetDBField('AffiliateCode'); - // to build non-SSL link without SID in case, when SSL is enabled (or SSL domain doesn't match non-SSL domain) + if ( $this->Application->isAdmin ) { + $params['prefix'] = '_FRONT_END_'; + } + + // Force defaults to remove "index.html" in Mod-Rewrite mode. + $params['template'] = 'index'; + $params['m_lang'] = $this->Application->GetDefaultLanguageId(); + $params['m_theme'] = $this->Application->GetDefaultThemeId(); + + // Build non-SSL link without SID in case, when SSL is enabled (or SSL domain doesn't match non-SSL domain). $params['__SSL__'] = 0; $params['__NO_SID__'] = 1; + // Use Mod-Rewrite, when available. + if ( $this->Application->ConfigValue('UseModRewrite') ) { + $params['__MOD_REWRITE__'] = 1; + } + else { + $params['index_file'] = 'index.php'; + } + $link = $this->Application->ProcessParsedTag('m', 'Link', $params); - // remove env manually + // Manually remove "env". return preg_replace('/(.*)\/index.php\?env=(.*?)&(.*)/', '\\1/index.php?\\3', $link); } @@ -171,4 +189,4 @@ $this->Application->HandleEvent(new kEvent($prefix . ':OnNew')); } } - } \ No newline at end of file + } Index: branches/5.3.x/admin_templates/orders/orders_edit_shipping.tpl =================================================================== diff -u -N -r15492 -r16192 --- branches/5.3.x/admin_templates/orders/orders_edit_shipping.tpl (.../orders_edit_shipping.tpl) (revision 15492) +++ branches/5.3.x/admin_templates/orders/orders_edit_shipping.tpl (.../orders_edit_shipping.tpl) (revision 16192) @@ -208,14 +208,14 @@ - + - + - +    ', 'OnDownloadLabel'); return false;"> @@ -243,4 +243,4 @@ - \ No newline at end of file + Index: branches/5.3.x/units/products/products_config.php =================================================================== diff -u -N -r16174 -r16192 --- branches/5.3.x/units/products/products_config.php (.../products_config.php) (revision 16174) +++ branches/5.3.x/units/products/products_config.php (.../products_config.php) (revision 16192) @@ -1,6 +1,6 @@ hAFTER, + 'Mode' => hBEFORE, 'Conditional' => false, 'HookToPrefix' => 'lst', 'HookToSpecial' => '*', Index: branches/5.3.x/units/addresses/addresses_config.php =================================================================== diff -u -N -r15656 -r16192 --- branches/5.3.x/units/addresses/addresses_config.php (.../addresses_config.php) (revision 15656) +++ branches/5.3.x/units/addresses/addresses_config.php (.../addresses_config.php) (revision 16192) @@ -1,6 +1,6 @@ 'OnUpdateProfileAddress', ), Array ( - 'Mode' => hAFTER, + 'Mode' => hBEFORE, 'Conditional' => false, 'HookToPrefix' => '#PARENT#', 'HookToSpecial' => '*', Index: branches/5.3.x/units/orders/orders_event_handler.php =================================================================== diff -u -N -r16106 -r16192 --- branches/5.3.x/units/orders/orders_event_handler.php (.../orders_event_handler.php) (revision 16106) +++ branches/5.3.x/units/orders/orders_event_handler.php (.../orders_event_handler.php) (revision 16192) @@ -1,6 +1,6 @@ getInventoryObject($product_object, $combination_item, $combinations[ $rec['ProductId'].'_'.$rec['OptionsSalt'] ]); $lack = $rec['Quantity'] - $rec['QuantityReserved']; - if ($lack > 0) { - // reserve lack or what is available (in case if we need to reserve anything, by Alex) - $to_reserve = min($lack, $inv_object->GetDBField('QtyInStock') - $product_object->GetDBField('QtyInStockMin')); - if ($to_reserve < $lack) $event->status = kEvent::erFAIL; // if we can't reserve the full lack + if ( $lack > 0 ) { + // Reserve lack or what is available (in case if we need to reserve anything, by Alex). + $to_reserve = min( + $lack, + $inv_object->GetDBField('QtyInStock') - $product_object->GetDBField('QtyInStockMin') + ); - //reserve in order - $order_item->SetDBFieldsFromHash($rec); - $order_item->SetDBField('QuantityReserved', $rec['QuantityReserved'] + $to_reserve); - $order_item->SetId($rec['OrderItemId']); - $order_item->Update(); + // If we can't reserve the full lack. + if ( $to_reserve < $lack ) { + $event->status = kEvent::erFAIL; + } - //update product - increase reserved, decrease in stock + // Reserve in order. + $order_item->SetDBFieldsFromHash($rec); + $order_item->SetDBField('QuantityReserved', $rec['QuantityReserved'] + $to_reserve); + $new_lack = $order_item->GetDBField('Quantity') - $order_item->GetDBField('QuantityReserved'); + $order_item->SetDBField('BackOrderFlag', abs($new_lack) <= 0.0001 ? 0 : 1); + $order_item->SetId($rec['OrderItemId']); + $order_item->Update(); + + // Update product - increase reserved, decrease in stock. $inv_object->SetDBField('QtyReserved', $inv_object->GetDBField('QtyReserved') + $to_reserve); $inv_object->SetDBField('QtyInStock', $inv_object->GetDBField('QtyInStock') - $to_reserve); $inv_object->SetDBField('QtyBackOrdered', $inv_object->GetDBField('QtyBackOrdered') - $to_reserve); $inv_object->Update(); - if ($product_object->GetDBField('InventoryStatus') == 2) { - // inventory by options, then restore changed combination values back to common $combinations array !!! - $combinations[ $rec['ProductId'].'_'.$rec['OptionsSalt'] ] = $inv_object->GetFieldValues(); + if ( $product_object->GetDBField('InventoryStatus') == 2 ) { + // Inventory by options, then restore changed combination + // values back to common $combinations array !!! + $combinations[$rec['ProductId'] . '_' . $rec['OptionsSalt']] = $inv_object->GetFieldValues(); } } $order_items->GoNext(); @@ -3810,9 +3820,7 @@ return ; } - $copied_ids = unserialize($this->Application->RecallVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize(Array ()))); - - foreach ($copied_ids as $id) { + foreach ( $this->trackCopiedOrderIDs($event) as $id ) { $an_event = new kEvent($this->Prefix . ':Dummy'); $this->Application->SetVar($this->Prefix . '_id', $id); $this->Application->SetVar($this->Prefix . '_mode', ''); // this is to fool ReserveItems to use live table @@ -3821,22 +3829,39 @@ } /** - * Occurs before an item is copied to live table (after all foreign keys have been updated) - * Id of item being copied is passed as event' 'id' param + * Occurs after an item has been copied to live table + * Id of copied item is passed as event' 'id' param * * @param kEvent $event * @return void * @access protected */ - protected function OnBeforeCopyToLive(kEvent $event) + protected function OnAfterCopyToLive(kEvent $event) { - parent::OnBeforeCopyToLive($event); + parent::OnAfterCopyToLive($event); - $id = $event->getEventParam('id'); - $copied_ids = unserialize($this->Application->RecallVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize(array ()))); - array_push($copied_ids, $id); + $this->trackCopiedOrderIDs($event, $event->getEventParam('id')); + } - $this->Application->StoreVar($event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'), serialize($copied_ids)); + /** + * Tracks copied order IDs. + * + * @param kEvent $event Event. + * @param integer $id Order ID. + * + * @return array + */ + protected function trackCopiedOrderIDs(kEvent $event, $id = null) + { + $setting_name = $event->Prefix . '_copied_ids' . $this->Application->GetVar('wid'); + $ids = $this->Application->GetVar($setting_name, array()); + + if ( isset($id) ) { + array_push($ids, $id); + $this->Application->SetVar($setting_name, $ids); + } + + return $ids; } /** Index: branches/5.3.x/units/shipping/shipping_tag_processor.php =================================================================== diff -u -N -r15671 -r16192 --- branches/5.3.x/units/shipping/shipping_tag_processor.php (.../shipping_tag_processor.php) (revision 15671) +++ branches/5.3.x/units/shipping/shipping_tag_processor.php (.../shipping_tag_processor.php) (revision 16192) @@ -1,6 +1,6 @@ Application->isAdminUser && $key ) { + + if ( $this->Application->isAdminUser && isset($key) && $key ) { $orig_name = ltrim($last_shippings[$package_id][$key]['ShippingName'], 'Original: '); $last_shippings[$package_id][$key]['ShippingName'] = $orig_name; } @@ -334,4 +335,4 @@ return $o; } -} \ No newline at end of file +} Index: branches/5.3.x/admin_templates/orders/orders_edit_billing.tpl =================================================================== diff -u -N -r15971 -r16192 --- branches/5.3.x/admin_templates/orders/orders_edit_billing.tpl (.../orders_edit_billing.tpl) (revision 15971) +++ branches/5.3.x/admin_templates/orders/orders_edit_billing.tpl (.../orders_edit_billing.tpl) (revision 16192) @@ -106,8 +106,6 @@ - - @@ -155,8 +153,6 @@ - - @@ -217,4 +213,4 @@ - \ No newline at end of file + Index: branches/5.3.x/units/sections/sections_config.php =================================================================== diff -u -N -r15492 -r16192 --- branches/5.3.x/units/sections/sections_config.php (.../sections_config.php) (revision 15492) +++ branches/5.3.x/units/sections/sections_config.php (.../sections_config.php) (revision 16192) @@ -1,6 +1,6 @@ Array ( Array ( - 'Mode' => hAFTER, + 'Mode' => hBEFORE, 'Conditional' => false, 'HookToPrefix' => 'site-domain', 'HookToSpecial' => '*', Index: branches/5.3.x/units/reports/reports_config.php =================================================================== diff -u -N -r15925 -r16192 --- branches/5.3.x/units/reports/reports_config.php (.../reports_config.php) (revision 15925) +++ branches/5.3.x/units/reports/reports_config.php (.../reports_config.php) (revision 16192) @@ -1,6 +1,6 @@ Array ( Array ( - 'Mode' => hAFTER, + 'Mode' => hBEFORE, 'Conditional' => false, 'HookToPrefix' => 'rep', 'HookToSpecial' => '*',