Page MenuHomeIn-Portal Phabricator

in-commerce
No OneTemporary

File Metadata

Created
Sun, Feb 2, 8:15 PM

in-commerce

Index: branches/5.2.x/units/affiliate_plans_items/affiliate_plans_items_tag_processor.php
===================================================================
--- branches/5.2.x/units/affiliate_plans_items/affiliate_plans_items_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/affiliate_plans_items/affiliate_plans_items_tag_processor.php (revision 15156)
@@ -1,48 +1,48 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class AffiliatePlansItemsTagProcessor extends kDBTagProcessor {
function IsEntireOrder($params)
{
$table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
if ($this->Application->IsTempMode($this->Prefix)) {
$table_name = $this->Application->GetTempName($table_name, 'prefix:' . $this->Prefix);
}
$sql = 'SELECT COUNT(*)
FROM ' . $table_name . '
WHERE (ItemType = 0) AND (AffiliatePlanId = ' . $this->Application->GetVar('ap_id') . ')';
return $this->Conn->GetOne($sql);
}
function ItemIcon($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBList */
if ($object->GetDBField('ItemType') == 2) {
$cat_object = $this->Application->recallObject('c');
$cat_object->Load( $object->GetDBField('CategoryId') );
$cat_tag_processor = $this->Application->recallObject('c_TagProcessor');
return $cat_tag_processor->ItemIcon();
}
return parent::ItemIcon($params);
}
}
\ No newline at end of file
Index: branches/5.2.x/units/gateways/gw_tag_processor.php
===================================================================
--- branches/5.2.x/units/gateways/gw_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/gateways/gw_tag_processor.php (revision 15156)
@@ -1,127 +1,127 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class GatewayTagProcessor extends kDBTagProcessor {
/**
* Payment gateway config values for current payment type
*
* @var Array
* @access private
*/
var $ConfigValues=Array();
/**
* Payment type id for current gateway values
*
* @var int
* @access private
*/
var $PaymentTypeID=0;
function initGWConfigValues()
{
$payment_type_id = $this->Application->GetVar('pt_id');
$GWConfigValue = $this->Application->recallObject('gwfv');
$sql = 'SELECT Value, GWConfigFieldId FROM '.$GWConfigValue->TableName.' WHERE PaymentTypeId = '.$payment_type_id;
$this->ConfigValues = $this->Conn->GetCol($sql,'GWConfigFieldId');
}
function gwConfigValue($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$id = $object->GetID();
$value = isset($this->ConfigValues[$id]) ? $this->ConfigValues[$id] : '';
if ( !array_key_exists('no_special', $params) || !$params['no_special'] ) {
$value = htmlspecialchars($value);
}
if ( getArrayValue($params, 'checked') ) {
$value = ($value == 1) ? 'checked' : '';
}
return $value;
}
function PrintList($params)
{
$list = $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List', $params);
$id_field = $this->Application->getUnitOption($this->Prefix,'IDField');
$list->Query();
$list->GoFirst();
$block_params=$this->prepareTagParams($params);
$block_params['name']=$params['block'];
$block_params['pass_params']='true';
$payment_type_object = $this->Application->recallObject('pt');
$o = '';
while (!$list->EOL())
{
$this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) );
$display_style = $payment_type_object->GetDBField('GatewayId') == $list->GetDBField('GatewayId') ? 'table-row' : 'none';
$block_params['input_block'] = $params['input_block_prefix'].$list->GetDBField('ElementType');
$block_params['gateway_id'] = $list->GetDBField('GatewayId');
$block_params['display'] = $display_style;
$o .= $this->Application->ParseBlock($block_params, 1);
$list->GoNext();
}
return $o;
}
/**
* Prints list a all possible field options
*
* @param Array $params
* @return string
* @access protected
*/
protected function PredefinedOptions($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['pass_params'] = 'true';
$o = '';
$value = $this->gwConfigValue($params);
$options = explode(',', $object->GetDBField('ValueList'));
foreach ($options as $key_val) {
list($key, $val) = explode('=', $key_val);
$block_params['key'] = $key;
$block_params['option'] = $val;
$block_params['selected'] = ($key == $value ? ' ' . $params['selected'] : '');
$block_params['PrefixSpecial'] = $this->getPrefixSpecial();
$o .= $this->Application->ParseBlock($block_params, 1);
}
return $o;
}
}
\ No newline at end of file
Index: branches/5.2.x/units/product_options/product_options_tag_processor.php
===================================================================
--- branches/5.2.x/units/product_options/product_options_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/product_options/product_options_tag_processor.php (revision 15156)
@@ -1,175 +1,175 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class ProductOptionsTagProcessor extends kDBTagProcessor {
function ShowOptions($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$opt_helper = $this->Application->recallObject('kProductOptionsHelper');
/* @var $opt_helper kProductOptionsHelper */
$parsed = $opt_helper->ExplodeOptionValues($object->GetFieldValues());
if ( !$parsed ) {
return '';
}
$values = $parsed['Values'];
$conv_prices = $parsed['Prices'];
$conv_price_types = $parsed['PriceTypes'];
$options =& $this->GetOptions();
$mode = $this->SelectParam($params, 'mode');
$combination_prefix = $this->SelectParam($params, 'combination_prefix');
$combination_field = $this->SelectParam($params, 'combination_field');
if ( $mode == 'selected' ) {
$comb = $this->Application->recallObject($combination_prefix);
/* @var $comb kDBItem */
$options = unserialize($comb->GetDBField($combination_field));
}
$block_params['name'] = $params['render_as'];
$block_params['selected'] = '';
$block_params['pass_params'] = 1;
$lang = $this->Application->recallObject('lang.current');
/* @var $lang LanguagesItem */
$o = '';
$first_selected = false;
foreach ($values as $option) {
// list($val, $label) = explode('|', $option);
$val = $option;
if ( getArrayValue($params, 'js') ) {
$block_params['id'] = addslashes($val);
$block_params['value'] = htmlspecialchars($val);
}
else {
$block_params['id'] = htmlspecialchars($val);
$block_params['value'] = htmlspecialchars($val);
}
if ( $conv_prices[$val] ) {
if ( $conv_price_types[$val] == '$' && !getArrayValue($params, 'js') && !getArrayValue($params, 'no_currency') ) {
$iso = $this->GetISO($params['currency']);
$value = sprintf("%.2f", $this->ConvertCurrency($conv_prices[$val], $iso));
$value = $this->AddCurrencySymbol($lang->formatNumber($value, 2), $iso, true); // true to force sign
$block_params['price'] = $value;
$block_params['price_type'] = '';
$block_params['sign'] = ''; //sign is included in the formatted value
}
else {
$block_params['price'] = isset($params['js']) ? $conv_prices[$val] : $lang->formatNumber($conv_prices[$val], 2);
$block_params['price_type'] = $conv_price_types[$val];
$block_params['sign'] = $conv_prices[$val] >= 0 ? '+' : '-';
}
}
else {
$block_params['price'] = '';
$block_params['price_type'] = '';
$block_params['sign'] = '';
}
/*if ($mode == 'selected') {
$selected = $combination[$object->GetID()] == $val;
}
else*/
$selected = false;
if ( !$options && isset($params['preselect_first']) && $params['preselect_first'] && !$first_selected ) {
$selected = true;
$first_selected = true;
}
if ( is_array($options) ) {
$option_value = array_key_exists($object->GetID(), $options) ? $options[$object->GetID()] : '';
if ( $object->GetDBField('OptionType') == OptionType::CHECKBOX ) {
$selected = is_array($option_value) && in_array(htmlspecialchars($val), $option_value);
}
else { // radio buttons ?
$selected = kUtil::unhtmlentities($option_value) == $val;
}
}
if ( $selected ) {
if ( $mode == 'selected' ) {
if ( $object->GetDBField('OptionType') != OptionType::CHECKBOX ) {
$block_params['selected'] = ' selected="selected" ';
}
else {
$block_params['selected'] = ' checked="checked" ';
}
}
else {
switch ($object->GetDBField('OptionType')) {
case OptionType::DROPDOWN:
$block_params['selected'] = ' selected="selected" ';
break;
case OptionType::RADIO:
case OptionType::CHECKBOX:
$block_params['selected'] = ' checked="checked" ';
break;
}
}
}
else {
$block_params['selected'] = '';
}
$o .= $this->Application->ParseBlock($block_params);
}
return $o;
}
function &GetOptions()
{
$opt_data = $this->Application->GetVar('options');
$options = getArrayValue($opt_data, $this->Application->GetVar('p_id'));
if (!$options && $this->Application->GetVar('orditems_id')) {
$ord_item = $this->Application->recallObject('orditems.-opt', null, Array ('skip_autoload' => true));
/* @var $ord_item kDBItem */
$ord_item->Load($this->Application->GetVar('orditems_id'));
$item_data = unserialize($ord_item->GetDBField('ItemData'));
$options = getArrayValue($item_data, 'Options');
}
return $options;
}
function OptionData($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$options =& $this->GetOptions();
return getArrayValue($options, $object->GetID());
}
function ListOptions($params)
{
return $this->PrintList2($params);
}
}
\ No newline at end of file
Index: branches/5.2.x/units/pricing/pricing_tag_processor.php
===================================================================
--- branches/5.2.x/units/pricing/pricing_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/pricing/pricing_tag_processor.php (revision 15156)
@@ -1,166 +1,166 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class PricingTagProcessor extends kDBTagProcessor {
function ProductPrice($params)
{
$object = $this->Application->recallObject($params['PrefixSpecial']);
$price = $object->GetField('Price');
// display selected currency by default
if (!isset($params['currency']) || $params['currency'] == 'selected') {
$iso = $this->Application->RecallVar('curr_iso');
}
elseif ($params['currency'] == 'primary') {
$iso = 'USD';
}
else { //explicit currency
$iso = $params['currency'];
}
// convert primary currency to selected (if they are the same, converter will just return)
$converter = $this->Application->recallObject('CurrencyRates');
/* @var $converter CurrencyRates */
$price = $converter->Convert($price, 'PRIMARY', $iso);
$currency = $this->Application->recallObject('curr.-'.$iso, null, Array('skip_autoload' => true));
if( !$currency->isLoaded() ) $currency->Load($iso, 'ISO');
$symbol = $currency->GetDBField('Symbol');
if (!$symbol) $symbol = $currency->GetDBField('ISO');
$formatted = '';
if ($currency->GetDBField('SymbolPosition') == 0) {
$formatted .= $symbol;
}
$formatted .= $price;
if ($currency->GetDBField('SymbolPosition') == 1) {
$formatted .= $symbol;
}
return $formatted;
}
function Product_ListPriceBrackets($params)
{
return $this->PrintList2($params);
}
function Field($params)
{
$field = $this->SelectParam($params, 'name,field');
$value = parent::Field($params);
if (($field == 'MaxQty') && ($value == -1)) {
$value = '&infin;';
}
return $value;
}
function Product_HasQuantityPricing($params)
{
return (int)$this->TotalRecords($params) > 1;
}
function ShowPricingForm($params)
{
- $br_object =& $this->getObject( Array('skip_autoload' => true) );
+ $br_object = $this->getObject( Array('skip_autoload' => true) );
$br_data = $this->Application->GetVar("pr_tang");
$group_id = $this->Application->getVar('group_id');
if($group_id>0){
$where_group=' AND GroupId = '.$group_id.' ';
}
if(!$br_data)
{
$sql = 'SELECT * FROM '.$br_object->TableName.' WHERE ProductId = '.$this->Application->GetVar('p_id').' '.$where_group;
$brackets = $this->Conn->Query($sql, 'PriceId');
usort($brackets, 'pr_bracket_comp');
$dummy = $this->Application->recallObject($this->Prefix.'.-dummy', null, array('skip_autoload' => true));
/* @var $dummy kDBItem */
foreach($brackets as $id => $values)
{
foreach($values as $value_key=>$value_val){
$dummy->SetDBField($value_key, $value_val);
$brackets[$id][$value_key] = $dummy->GetField($value_key);
}
}
$br_data=$brackets;
$this->Application->SetVar($this->getPrefixSpecial(true), $brackets);
}
else
{
usort($br_data , 'pr_bracket_comp');
}
$ret = '';
if( is_array($br_data) )
{
$block_params=$this->prepareTagParams($params);
$block_params['IdField']='PriceId';
$block_params['name'] = $params['block'];
$first = true;
// this is needed to find next id
$br_data_copy=$br_data;
foreach($br_data as $id => $values)
{
foreach($values as $value_key=>$value_val){
$block_params[$value_key] = $value_val;
}
reset($values);
next($br_data_copy);
$next_bracket=current($br_data_copy);
$block_params['id'] = $values["PriceId"];
$block_params['min'] = ($id == -1) ? ($values['MinQty'] ? $values['MinQty'] : 0) : $values['MinQty'];
$block_params['max'] = ($values['MaxQty'] == -1) ? '&infin;' : $values['MaxQty'];
$block_params['next_min_id']=$next_bracket['PriceId'];
if ($first)
{
$block_params['first'] = 1;
$first = false;
}
else
{
$block_params['first'] = 0;
}
$ret .= $this->Application->ParseBlock($block_params, 1);
}
}
return $ret;
}
function AddToCartLink($params)
{
$value = $this->Field(array('name'=>'PriceId'));
//$this->Application->SetVar('p_id', $this->Application->GetVar($this->getPrefixSpecial().'_id'));
$this->Application->SetVar('pr_id', $value);
return $this->Application->HREF($params['template'], '', Array('pass' => 'm,p,pr,ord', 'ord_event' => 'OnAddToCart'));
}
}
\ No newline at end of file
Index: branches/5.2.x/units/affiliate_payments/affiliate_payments_tag_processor.php
===================================================================
--- branches/5.2.x/units/affiliate_payments/affiliate_payments_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/affiliate_payments/affiliate_payments_tag_processor.php (revision 15156)
@@ -1,65 +1,65 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class AffiliatePaymentsTagProcessor extends kDBTagProcessor {
/**
* Returns url for editing user from current record
*
* @param Array $params
* @return string
*/
function UserLink($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$user_id = $object->GetDBField('PortalUserId');
if (!$user_id) {
return '';
}
$url_params = Array (
'm_opener' => 'd',
'u_mode' => 't',
'u_event' => 'OnEdit',
'u_id' => $user_id,
'pass' => 'all,u'
);
return $this->Application->HREF($params['edit_template'], '', $url_params);
}
function ListPayments($params)
{
$o = '';
$params['render_as'] = $params['item_render_as'];
$o_payments = $this->PrintList($params);
if ($o_payments)
{
$payments_params = Array('name' => $params['header_render_as']);
$o = $this->Application->ParseBlock($payments_params);
$o .= $o_payments;
}
else
{
$payments_params = array('name' => $params['empty_mypayments_render_as']);
$o = $this->Application->ParseBlock($payments_params);
}
return $o;
}
}
\ No newline at end of file
Index: branches/5.2.x/units/affiliate_payment_types/affiliate_payment_types_tp.php
===================================================================
--- branches/5.2.x/units/affiliate_payment_types/affiliate_payment_types_tp.php (revision 15155)
+++ branches/5.2.x/units/affiliate_payment_types/affiliate_payment_types_tp.php (revision 15156)
@@ -1,51 +1,51 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2011 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class AffiliatePaymentTypeTagProcessor extends kDBTagProcessor {
/**
* Checks, that current affiliate payment type matches the one, being printed via PrintList tag
*
* @param $params
* @return bool
* @see kDBTagProcessor::PrintList()
* @access protected
*/
protected function Checked($params)
{
static $checked = false;
$affiliate = $this->Application->recallObject( $params['prefix'] );
/* @var $affiliate kDBItem */
$payment_type = $affiliate->GetDBField( $params['field'] );
if ( $payment_type ) {
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBList */
return $payment_type == $object->GetID();
}
if ( !$checked ) {
// make first listed affiliate payment type selected
$checked = true;
return true;
}
return false;
}
}
\ No newline at end of file
Index: branches/5.2.x/units/product_option_combinations/product_option_combinations_tag_processor.php
===================================================================
--- branches/5.2.x/units/product_option_combinations/product_option_combinations_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/product_option_combinations/product_option_combinations_tag_processor.php (revision 15156)
@@ -1,58 +1,58 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class ProductOptionCombinationsTagProcessor extends kDBTagProcessor {
function ListOptions($params)
{
$o = '';
return $o;
}
function ListValues($params)
{
$o = '';
return $o;
}
function ShowCombination($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$combination = unserialize($object->GetDBField('Combination'));
$block_params['name'] = $params['render_as'];
$opt_helper = $this->Application->recallObject('kProductOptionsHelper');
$o = '';
$i = 0;
foreach ($combination as $opt => $val) {
$i++;
$block_params['option_id'] = $opt;
$conv_key = $opt_helper->ConvertKey($opt, $object->GetDBField('ProductId'));
$block_params['option_name'] = $conv_key['Name'];
if (is_array($val)) {
$val = join(',', $val);
}
$block_params['option_value'] = $val;
$block_params['is_last'] = $i == count($combination);
$o .= $this->Application->ParseBlock($block_params);
}
return $o;
}
}
\ No newline at end of file
Index: branches/5.2.x/units/payment_type/payment_type_tag_processor.php
===================================================================
--- branches/5.2.x/units/payment_type/payment_type_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/payment_type/payment_type_tag_processor.php (revision 15156)
@@ -1,53 +1,53 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class PaymentTypeTagProcessor extends kDBTagProcessor {
function DeleteError($params){
$o = '';
$error = $this->Application->RecallVar('pt_delete_error');
if ($error){
$params['name']=$params['block'];
$o = $this->Application->ParseBlock($params);
$this->Application->RemoveVar('pt_delete_error');
}
return $o;
}
function ListGroups($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$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 = '';
$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 = $mode == 'selected' ? !$is_selected : $is_selected;
if ($continue) continue;
$block_params = $a_group;
$block_params['name'] = $params['render_as'];
$o .= $this->Application->ParseBlock($block_params);
}
return $o;
}
}
\ No newline at end of file
Index: branches/5.2.x/units/manufacturers/manufacturers_tag_processor.php
===================================================================
--- branches/5.2.x/units/manufacturers/manufacturers_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/manufacturers/manufacturers_tag_processor.php (revision 15156)
@@ -1,55 +1,55 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class ManufacturersTagProcessor extends kDBTagProcessor{
function BuildListSpecial($params)
{
if ($this->Special != '') return $this->Special;
if ( isset($params['parent_cat_id']) ) {
$parent_cat_id = $params['parent_cat_id'];
}
else {
$parent_cat_id = $this->Application->GetVar('c_id');
if (!$parent_cat_id) {
$parent_cat_id = $this->Application->GetVar('m_cat_id');
}
}
$recursive = isset($params['recursive']);
$list_unique_key = $this->getUniqueListKey($params).$recursive;
if ($list_unique_key == '') {
return parent::BuildListSpecial($params);
}
return crc32($parent_cat_id.$list_unique_key);
}
function ListManufacturers($params)
{
return $this->PrintList2($params);
}
function ManufacturerLink($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$params['pass'] = 'm,manuf';
$params['m_cat_id'] = 0;
$params['manuf_id'] = $object->GetID();
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
}
\ No newline at end of file
Index: branches/5.2.x/units/shipping/shipping_tag_processor.php
===================================================================
--- branches/5.2.x/units/shipping/shipping_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/shipping/shipping_tag_processor.php (revision 15156)
@@ -1,323 +1,323 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class ShippingTagProcessor extends kDBTagProcessor {
function CostInputSize($params)
{
$object = $this->Application->recallObject( $this->getPrefixSpecial() );
$prec_before_sep = $object->GetDBField('PrecisionBeforeSep');
$prec_after_sep = $object->GetDBField('PrecisionAfterSep');
return $prec_before_sep + $prec_after_sep + 1 + ($prec_before_sep > 3 ? 1:0);
}
function ShowCostsTable($params)
{
$object = $this->Application->recallObject( $this->getPrefixSpecial() );
$zones_object = $this->Application->recallObject('z');
$brackets_object = $this->Application->recallObject('br');
$costs_object = $this->Application->recallObject('sc');
/* @var $costs_object kDBItem */
$main_processor = $this->Application->recallObject('m_TagProcessor');
$zones_sql = 'SELECT * FROM '.$zones_object->TableName.' WHERE ShippingTypeID='.$this->Application->GetVar('s_id').' ORDER BY Name ASC';
$brackets_sql = 'SELECT * FROM '.$brackets_object->TableName.' WHERE ShippingTypeID='.$this->Application->GetVar('s_id').' ORDER BY Start ASC';
$sql = 'SELECT * FROM '.$costs_object->TableName;
$costs_array = $this->Conn->Query($sql, 'ShippingCostId');
$zones = $this->Conn->Query($zones_sql, 'ZoneID');
$brackets = $this->Conn->Query($brackets_sql, 'BracketId');
$oddevenparam['odd'] = 'table-color1';
$oddevenparam['even'] = 'table-color2';
if(!$zones || !$brackets)
{
return '<tr class="'.$main_processor->Odd_Even($oddevenparam).'"><td>'.$this->Application->Phrase('la_NoZonesOrBrackets').'</td></tr>';
}
uasort($brackets, 'bracket_comp');
if( $this->Application->GetLinkedVar('CostsTableAligment') )
{
$column_items = $brackets;
$column_object =& $brackets_object;
$column_params['header_caption'] = 'bracket_caption';
$column_params['IdField'] = 'BracketId';
$column_params['prefix'] = 'br';
$row_items = $zones;
$row_object =& $zones_object;
$row_params['header_caption'] = 'zone_caption';
$row_params['IdField'] = 'ZoneID';
$row_params['prefix'] = 'z';
}
else
{
$column_items = $zones;
$column_object =& $zones_object;
$column_params['header_caption'] = 'zone_caption';
$column_params['IdField'] = 'ZoneID';
$column_params['prefix'] = 'z';
$row_items = $brackets;
$row_object =& $brackets_object;
$row_params['header_caption'] = 'bracket_caption';
$row_params['IdField'] = 'BracketId';
$row_params['prefix'] = 'br';
}
$costs_table = '<tr class="'.$main_processor->Odd_Even($oddevenparam).'"><td>&nbsp;</td>';
foreach($column_items as $id => $record)
{
$column_object->Load($id);
$head_row_params = $column_params;
$head_row_params['name'] = 'column_header';
$costs_table .= $this->Application->ParseBlock($head_row_params);
}
$costs_table .= '</tr>';
$cost_ids = Array();
foreach($row_items as $id =>$record)
{
$costs_table .= '<tr class="'.$main_processor->Odd_Even($oddevenparam).'">';
$row_object->Load($id);
$head_row_params = $row_params;
$head_row_params['name'] = 'row_header';
$costs_table .= $this->Application->ParseBlock($head_row_params);
foreach($column_items as $col_id => $col_record)
{
$res = false;
foreach($costs_array as $cost_id => $cost_record)
{
if($cost_record[$row_params['IdField']] == $id && $cost_record[$column_params['IdField']] == $col_id)
{
$costs_object->SetDBFieldsFromHash($cost_record);
$res = true;
break;
}
}
if($res == false)
{
$costs_object->Clear();
$sql = 'SELECT MIN(ShippingCostId) FROM '.$costs_object->TableName;
$new_id = $cost_ids ? min( $this->Conn->GetOne($sql) - 1, min($cost_ids) - 1 ) : 0;
$costs_object->SetDBField( 'ShippingCostId', $new_id );
$cost_ids[] = $new_id;
}
$column_object->Load($col_id);
$costs_object->SetID($costs_object->GetDBField('ShippingCostId'));
$cost_cell_params['name'] = 'cost_cell';
$costs_table .= $this->Application->ParseBlock($cost_cell_params);
}
$costs_table .= '</tr>';
}
return $costs_table;
}
function HiddenSelection($params)
{
// $object = $this->getPrefixSpecial();
$zones = $this->Application->GetVar('z');
$brackets = $this->Application->GetVar('br');
$ret = '';
foreach($zones as $id => $record)
{
$ret .= '<input type="hidden" name="z['.$id.'][ZoneID]" value="'.$id.'">'."\n";
}
foreach ($brackets as $id => $record)
{
$ret .= '<input type="hidden" name="br['.$id.'][BracketId]" value="'.$id.'">'."\n";
}
return $ret;
}
function Order_PrintShippingTypes($params)
{
$weight = $this->Application->Parser->GetParam('weight_metric');
$items = $this->Application->Parser->GetParam('items');
$amount = $this->Application->Parser->GetParam('amount');
$selected_id = $this->Application->Parser->GetParam('selected_id');
$package_id = $this->Application->Parser->GetParam('package_num');
// free promo shipping params if applicable, if not then the same as standard
$promo_items = $this->Application->Parser->GetParam('promo_items');
$promo_amount = $this->Application->Parser->GetParam('promo_amount');
$promo_weight = $this->Application->Parser->GetParam('promo_weight_metric');
$user_country_id = $this->Application->Parser->GetParam('user_country_id');
$user_state_id = $this->Application->Parser->GetParam('user_state_id');
$user_zip = $this->Application->Parser->GetParam('user_zip');
$user_city = $this->Application->Parser->GetParam('user_city');
$user_addr1 = $this->Application->Parser->GetParam('user_addr1');
$user_addr2 = $this->Application->Parser->GetParam('user_addr2');
$user_name = $this->Application->Parser->GetParam('user_name');
$limit_types = $this->Application->Parser->GetParam('limit_types');
$this->Application->recallObject('ShippingQuoteEngine'); // TODO: why call this here?
$quote_engine_collector = $this->Application->recallObject('ShippingQuoteCollector');
/* @var $quote_engine_collector ShippingQuoteCollector */
$shipping_quote_params = Array (
'dest_country' => $user_country_id,
'dest_state' => $user_state_id,
'dest_postal' => $user_zip,
'dest_city' => $user_city,
'dest_addr1' => $user_addr1,
'dest_addr2' => $user_addr2,
'dest_name' => $user_name,
'packages' => Array (
Array (
'package_key' => 'package1',
'weight' => $weight,
'weight_unit' => 'KG',
'length' => '',
'width' => '',
'height' => '',
'dim_unit' => 'IN',
'packaging' => 'BOX',
'contents' => 'OTR',
'insurance' => '0'
),
),
'amount' => $amount,
'items' => $items,
'limit_types' => $limit_types,
'promo_params' => Array (
'items' => $promo_items,
'amount' => $promo_amount,
'weight' => $promo_weight,
)
);
$shipping_types = $quote_engine_collector->GetShippingQuotes($shipping_quote_params);
$last_shippings = $this->Application->RecallVar('LastShippings');
if ( $last_shippings ) {
$last_shippings = unserialize($last_shippings);
}
$order_object = $this->Application->recallObject('ord');
/* @var $order_object OrdersItem */
$original_shipping = $order_object->GetDBField('ShippingInfo');
$original_shipping = unserialize($original_shipping);
$shipping_type_keys = array_keys($shipping_types);
if( getArrayValue($original_shipping, $package_id, 'ShippingId') &&
( $this->Application->isAdminUser || in_array( $original_shipping[$package_id]['ShippingId'], $shipping_type_keys ) ) )
{
$original_shipping = $original_shipping[$package_id];
$key = $original_shipping['ShippingId'];
$shipping_types[$key]['TotalCost'] = $this->Application->isAdminUser ? $original_shipping['TotalCost'] : $shipping_types[$key]['TotalCost'];
$shipping_types[$key]['ShippingName'] = $this->Application->isAdminUser ? 'Original: '.$original_shipping['ShippingName'] : $shipping_types[$key]['ShippingName'];
$shipping_types[$key]['ShippingId'] = $key;
$selected_id = $key;
}
$last_shippings[$package_id] = $shipping_types;
if ( $this->Application->isAdminUser && $key ) {
$orig_name = ltrim($last_shippings[$package_id][$key]['ShippingName'], 'Original: ');
$last_shippings[$package_id][$key]['ShippingName'] = $orig_name;
}
$this->Application->StoreVar('LastShippings', serialize($last_shippings));
$o = '';
$def_block_params = Array();
$def_block_params['name'] = $this->SelectParam($params, 'render_as,block');
if ( !count($shipping_types) ) {
$this->Application->SetVar('ItemShipmentsExists', 0);
return '';
}
$lang = $this->Application->recallObject('lang.current');
/* @var $lang LanguagesItem */
foreach ($shipping_types as $shipping_type) {
if ( isset($shipping_type['InsuranceFee']) ) {
$shipping_type['TotalCost'] += $shipping_type['InsuranceFee'];
}
$shipping_type['ShippingFree'] = ($shipping_type['TotalCost'] == 0) ? 1 : 0;
$iso = $this->GetISO($params['currency']);
$amount = $this->ConvertCurrency($shipping_type['TotalCost'], $iso);
$amount = $lang->formatNumber($amount, 2);
$shipping_type['TotalCost'] = $this->AddCurrencySymbol($amount, $iso);
$block_params = array_merge($def_block_params, $shipping_type);
$block_params['selected'] = $shipping_type['ShippingId'] == $selected_id ? 'selected' : '';
if ( isset($params['selected_only']) && $block_params['selected'] == '' ) {
continue;
}
$o .= $this->Application->ParseBlock($block_params);
}
return $o;
}
function AvailableTypes($params)
{
$quote_engine_collector = $this->Application->recallObject('ShippingQuoteCollector');
/* @var $quote_engine_collector ShippingQuoteCollector */
$types = $quote_engine_collector->GetAvailableShippingTypes();
$o;
foreach ($types as $a_type)
{
$block_params = $a_type;
$block_params['name'] = $params['render_as'];
$o .= $this->Application->ParseBlock($block_params);
}
return $o;
}
function ListGroups($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$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)
{
$is_selected = in_array($a_group['GroupId'], $selected_arr);
$continue = $params['mode'] == 'selected' ? !$is_selected : $is_selected;
if ($continue) continue;
$block_params = $a_group;
$block_params['name'] = $params['render_as'];
$o .= $this->Application->ParseBlock($block_params);
}
return $o;
}
}
\ No newline at end of file
Index: branches/5.2.x/units/taxes/taxes_tag_processor.php
===================================================================
--- branches/5.2.x/units/taxes/taxes_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/taxes/taxes_tag_processor.php (revision 15156)
@@ -1,273 +1,273 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class TaxesTagProcessor extends kDBTagProcessor
{
function ShowCountries($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$destination_table = $this->getDestinationsTable($params);
$selected_country_id = (int)$this->Application->GetVar('CountrySelector');
$name_field = 'l' . $this->Application->GetVar('m_lang') . '_Name';
$id_field = $this->Application->getUnitOption('country-state', 'IDField');
$table_name = $this->Application->getUnitOption('country-state', 'TableName');
switch ($params['show']) {
case 'current':
// selected countries in current zone
$sql = 'SELECT cs.' . $name_field . ', cs.' . $id_field . '
FROM ' . $table_name . ' cs
LEFT JOIN ' . $destination_table . ' zd ON zd.StdDestId = cs.' . $id_field . '
WHERE cs.Type = ' . DESTINATION_TYPE_COUNTRY . ' AND zd.TaxZoneId = ' . $object->GetID() . '
ORDER BY cs.' . $name_field;
break;
case 'available':
// available countries in current zone
$sql = 'SELECT cs.' . $name_field . ', cs.' . $id_field . '
FROM ' . $table_name . ' cs
LEFT JOIN ' . $destination_table . ' zd ON zd.StdDestId = cs.' . $id_field . '
WHERE cs.Type = ' . DESTINATION_TYPE_COUNTRY . ' AND zd.TaxZoneId IS NULL
ORDER BY cs.' . $name_field;
break;
case 'all':
// always preselect 1st country, when user haven't selected any
if (!$selected_country_id) {
$sql = 'SELECT StdDestId
FROM ' . $destination_table . '
WHERE TaxZoneId = ' . $object->GetID();
$selected_country_id = $this->Conn->GetOne($sql);
if ($selected_country_id) {
$this->Application->SetVar('CountrySelector', $selected_country_id);
}
}
// all countries
$sql = 'SELECT ' . $name_field . ', ' . $id_field . '
FROM ' . $table_name . '
WHERE Type = ' . DESTINATION_TYPE_COUNTRY . '
ORDER BY ' . $name_field;
break;
case 'has_states':
$cs_helper = $this->Application->recallObject('CountryStatesHelper');
/* @var $cs_helper kCountryStatesHelper */
$has_states = $cs_helper->getCountriesWithStates();
if ($selected_country_id && !array_key_exists($selected_country_id, $has_states)) {
list ($selected_country_id, ) = each($has_states);
$this->Application->SetVar('CountrySelector', $selected_country_id);
}
// preselect country from 1st found state
if (!$selected_country_id) {
$sql = 'SELECT cs.StateCountryId
FROM ' . $table_name . ' cs
LEFT JOIN ' . $destination_table . ' zd ON zd.StdDestId = cs.' . $id_field . '
WHERE (cs.Type = ' . DESTINATION_TYPE_STATE . ') AND (zd.TaxZoneId = ' . $object->GetID() . ')';
$selected_country_id = $this->Conn->GetOne($sql);
if ($selected_country_id) {
$this->Application->SetVar('CountrySelector', $selected_country_id);
}
else {
list ($selected_country_id, ) = each($has_states);
$this->Application->SetVar('CountrySelector', $selected_country_id);
}
}
// gets only countries with states
$sql = 'SELECT ' . $name_field . ', ' . $id_field . '
FROM ' . $table_name . '
WHERE Type = ' . DESTINATION_TYPE_COUNTRY . ' AND ' . $id_field . ' IN (' . implode(',', array_keys($has_states)) . ')
ORDER BY ' . $name_field;
break;
default:
throw new Exception('Unknown "show" parameter value "' . $params['show'] . '" used');
break;
}
$ret = '';
$countries = $this->Conn->GetCol($sql, $id_field);
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['block'];
foreach ($countries as $country_id => $country_name) {
$block_params['id'] = $country_id;
$block_params['destination_title'] = $country_name;
$block_params['selected'] = $selected_country_id == $country_id ? ' selected="selected"' : '';
$ret .= $this->Application->ParseBlock($block_params);
}
return $ret;
}
function ShowStates($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$destination_table = $this->getDestinationsTable($params);
$name_field = 'l' . $this->Application->GetVar('m_lang') . '_Name';
$id_field = $this->Application->getUnitOption('country-state', 'IDField');
$table_name = $this->Application->getUnitOption('country-state', 'TableName');
$country_id = $this->Application->GetVar('CountrySelector');
switch ($params['show']) {
case 'current':
// selected states for current country and zone
$sql = 'SELECT cs.' . $name_field . ', cs.' . $id_field . '
FROM ' . $table_name . ' cs
LEFT JOIN ' . $destination_table . ' zd ON zd.StdDestId = cs.' . $id_field . '
WHERE
cs.Type = ' . DESTINATION_TYPE_STATE . ' AND
cs.StateCountryId = ' . $country_id . ' AND
zd.TaxZoneId = ' . $object->GetID() . '
ORDER BY cs.' . $name_field;
break;
case 'available':
// available states for current country and zone
$sql = 'SELECT cs.' . $name_field . ', cs.' . $id_field . '
FROM ' . $table_name . ' cs
LEFT JOIN ' . $destination_table . ' zd ON zd.StdDestId = cs.' . $id_field . '
WHERE
cs.Type = ' . DESTINATION_TYPE_STATE . '
AND zd.TaxZoneId IS NULL
AND cs.StateCountryId = ' . $country_id . '
ORDER BY cs.' . $name_field;
break;
case 'all':
// all possible states for selected country
$sql = 'SELECT ' . $name_field . ', ' . $id_field . '
FROM ' . $table_name . '
WHERE Type = ' . DESTINATION_TYPE_STATE . ' AND StateCountryId = ' . $country_id . '
ORDER BY ' . $name_field;
break;
default:
throw new Exception('Unknown "show" parameter value "' . $params['show'] . '" used');
break;
}
$ret = '';
$states = $this->Conn->GetCol($sql, $id_field);
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['block'];
foreach($states as $state_id => $state_name) {
$block_params['id'] = $state_id;
$block_params['destination_title'] = $state_name;
$ret .= $this->Application->ParseBlock($block_params);
}
return $ret;
}
function ShowZips($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$destination_table = $this->getDestinationsTable($params);
$country_id = (int)$this->Application->GetVar('CountrySelector');
$current_sql = 'SELECT DestValue
FROM ' . $destination_table . '
WHERE
COALESCE(DestValue, "") <> "" AND
TaxZoneId = ' . $object->GetID() . '
ORDER BY DestValue';
switch ($params['show']) {
case 'current':
$sql = $current_sql;
break;
case 'available':
$selected_zips = $this->Conn->GetCol($current_sql);
$selected_zips = $this->Conn->qstrArray($selected_zips);
$sql = 'SELECT DISTINCT DestValue
FROM ' . $this->Application->getUnitOption('taxdst', 'TableName') . '
WHERE
COALESCE(DestValue, "") <> "" AND
TaxZoneId <> ' . $object->GetID() . ' AND
' . ($selected_zips ? 'DestValue NOT IN (' . implode(',', $selected_zips) . ') AND' : '') . '
StdDestId = ' . $country_id . '
ORDER BY DestValue';
break;
default:
throw new Exception('Unknown "show" parameter value "' . $params['show'] . '" used');
break;
}
$zips = $this->Conn->GetCol($sql);
$ret = '';
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['block'];
foreach($zips as $zip) {
$block_params['id'] = '0|' . $zip;
$block_params['destination_title'] = $zip;
$ret .= $this->Application->ParseBlock($block_params);
}
return $ret;
}
/**
* Returns table for shipping zone destinations
*
* @param Array $params
* @return string
*/
function getDestinationsTable($params)
{
static $table_name = '';
if (!$table_name) {
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$table_name = $this->Application->getUnitOption('taxdst', 'TableName');
if ($object->IsTempTable()) {
$table_name = $this->Application->GetTempName($table_name, 'prefix:' . $this->Prefix);
}
}
return $table_name;
}
}
\ No newline at end of file
Index: branches/5.2.x/units/discount_items/discount_items_tag_processor.php
===================================================================
--- branches/5.2.x/units/discount_items/discount_items_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/discount_items/discount_items_tag_processor.php (revision 15156)
@@ -1,48 +1,48 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class DiscountItemsTagProcessor extends kDBTagProcessor {
function IsEntireOrder($params)
{
$table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
if ($this->Application->IsTempMode($this->Prefix)) {
$table_name = $this->Application->GetTempName($table_name, 'prefix:' . $this->Prefix);
}
$sql = 'SELECT COUNT(*)
FROM ' . $table_name . '
WHERE (ItemType = 0) AND (DiscountId = ' . $this->Application->GetVar('d_id') . ')';
return $this->Conn->GetOne($sql);
}
function ItemIcon($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBList */
if ($object->GetDBField('ItemType') == 2) {
$cat_object = $this->Application->recallObject('c');
$cat_object->Load( $object->GetDBField('CategoryId') );
$cat_tag_processor = $this->Application->recallObject('c_TagProcessor');
return $cat_tag_processor->ItemIcon();
}
return parent::ItemIcon($params);
}
}
\ No newline at end of file
Index: branches/5.2.x/units/zones/zones_tag_processor.php
===================================================================
--- branches/5.2.x/units/zones/zones_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/zones/zones_tag_processor.php (revision 15156)
@@ -1,272 +1,272 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class ZonesTagProcessor extends kDBTagProcessor
{
function ShowCountries($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$destination_table = $this->getDestinationsTable($params);
$selected_country_id = (int)$this->Application->GetVar('CountrySelector');
$name_field = 'l' . $this->Application->GetVar('m_lang') . '_Name';
$id_field = $this->Application->getUnitOption('country-state', 'IDField');
$table_name = $this->Application->getUnitOption('country-state', 'TableName');
switch ($params['show']) {
case 'current':
// selected countries in current zone
$sql = 'SELECT cs.' . $name_field . ', cs.' . $id_field . '
FROM ' . $table_name . ' cs
LEFT JOIN ' . $destination_table . ' zd ON zd.StdDestId = cs.' . $id_field . '
WHERE cs.Type = ' . DESTINATION_TYPE_COUNTRY . ' AND zd.ShippingZoneId = ' . $object->GetID() . '
ORDER BY cs.' . $name_field;
break;
case 'available':
// available countries in current zone
$sql = 'SELECT cs.' . $name_field . ', cs.' . $id_field . '
FROM ' . $table_name . ' cs
LEFT JOIN ' . $destination_table . ' zd ON zd.StdDestId = cs.' . $id_field . '
WHERE cs.Type = ' . DESTINATION_TYPE_COUNTRY . ' AND zd.ShippingZoneId IS NULL
ORDER BY cs.' . $name_field;
break;
case 'all':
// always preselect 1st country, when user haven't selected any
if (!$selected_country_id) {
$sql = 'SELECT StdDestId
FROM ' . $destination_table . '
WHERE ShippingZoneId = ' . $object->GetID();
$selected_country_id = $this->Conn->GetOne($sql);
if ($selected_country_id) {
$this->Application->SetVar('CountrySelector', $selected_country_id);
}
}
// all countries
$sql = 'SELECT ' . $name_field . ', ' . $id_field . '
FROM ' . $table_name . '
WHERE Type = ' . DESTINATION_TYPE_COUNTRY . '
ORDER BY ' . $name_field;
break;
case 'has_states':
$cs_helper = $this->Application->recallObject('CountryStatesHelper');
/* @var $cs_helper kCountryStatesHelper */
$has_states = $cs_helper->getCountriesWithStates();
if ($selected_country_id && !array_key_exists($selected_country_id, $has_states)) {
list ($selected_country_id, ) = each($has_states);
$this->Application->SetVar('CountrySelector', $selected_country_id);
}
// preselect country from 1st found state
if (!$selected_country_id) {
$sql = 'SELECT cs.StateCountryId
FROM ' . $table_name . ' cs
LEFT JOIN ' . $destination_table . ' zd ON zd.StdDestId = cs.' . $id_field . '
WHERE (cs.Type = ' . DESTINATION_TYPE_STATE . ') AND (zd.ShippingZoneId = ' . $object->GetID() . ')';
$selected_country_id = $this->Conn->GetOne($sql);
if ($selected_country_id) {
$this->Application->SetVar('CountrySelector', $selected_country_id);
}
else {
list ($selected_country_id, ) = each($has_states);
$this->Application->SetVar('CountrySelector', $selected_country_id);
}
}
// gets only countries with states
$sql = 'SELECT ' . $name_field . ', ' . $id_field . '
FROM ' . $table_name . '
WHERE Type = ' . DESTINATION_TYPE_COUNTRY . ' AND ' . $id_field . ' IN (' . implode(',', array_keys($has_states)) . ')
ORDER BY ' . $name_field;
break;
default:
throw new Exception('Unknown "show" parameter value "' . $params['show'] . '" used');
break;
}
$ret = '';
$countries = $this->Conn->GetCol($sql, $id_field);
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['block'];
foreach ($countries as $country_id => $country_name) {
$block_params['id'] = $country_id;
$block_params['destination_title'] = $country_name;
$block_params['selected'] = $selected_country_id == $country_id ? ' selected="selected"' : '';
$ret .= $this->Application->ParseBlock($block_params);
}
return $ret;
}
function ShowStates($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$destination_table = $this->getDestinationsTable($params);
$name_field = 'l' . $this->Application->GetVar('m_lang') . '_Name';
$id_field = $this->Application->getUnitOption('country-state', 'IDField');
$table_name = $this->Application->getUnitOption('country-state', 'TableName');
$country_id = $this->Application->GetVar('CountrySelector');
switch ($params['show']) {
case 'current':
// selected states for current country and zone
$sql = 'SELECT cs.' . $name_field . ', cs.' . $id_field . '
FROM ' . $table_name . ' cs
LEFT JOIN ' . $destination_table . ' zd ON zd.StdDestId = cs.' . $id_field . '
WHERE
cs.Type = ' . DESTINATION_TYPE_STATE . ' AND
cs.StateCountryId = ' . $country_id . ' AND
zd.ShippingZoneId = ' . $object->GetID() . '
ORDER BY cs.' . $name_field;
break;
case 'available':
// available states for current country and zone
$sql = 'SELECT cs.' . $name_field . ', cs.' . $id_field . '
FROM ' . $table_name . ' cs
LEFT JOIN ' . $destination_table . ' zd ON zd.StdDestId = cs.' . $id_field . '
WHERE
cs.Type = ' . DESTINATION_TYPE_STATE . '
AND zd.ShippingZoneId IS NULL
AND cs.StateCountryId = ' . $country_id . '
ORDER BY cs.' . $name_field;
break;
case 'all':
// all possible states for selected country
$sql = 'SELECT ' . $name_field . ', ' . $id_field . '
FROM ' . $table_name . '
WHERE Type = ' . DESTINATION_TYPE_STATE . ' AND StateCountryId = ' . $country_id . '
ORDER BY ' . $name_field;
break;
default:
throw new Exception('Unknown "show" parameter value "' . $params['show'] . '" used');
break;
}
$ret = '';
$states = $this->Conn->GetCol($sql, $id_field);
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['block'];
foreach($states as $state_id => $state_name) {
$block_params['id'] = $state_id;
$block_params['destination_title'] = $state_name;
$ret .= $this->Application->ParseBlock($block_params);
}
return $ret;
}
function ShowZips($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$destination_table = $this->getDestinationsTable($params);
$country_id = (int)$this->Application->GetVar('CountrySelector');
$current_sql = 'SELECT DestValue
FROM ' . $destination_table . '
WHERE
COALESCE(DestValue, "") <> "" AND
ShippingZoneID = ' . $object->GetID() . '
ORDER BY DestValue';
switch ($params['show']) {
case 'current':
$sql = $current_sql;
break;
case 'available':
$selected_zips = $this->Conn->GetCol($current_sql);
$selected_zips = $this->Conn->qstrArray($selected_zips);
$sql = 'SELECT DISTINCT DestValue
FROM ' . $this->Application->getUnitOption('dst', 'TableName') . '
WHERE
COALESCE(DestValue, "") <> "" AND
ShippingZoneID <> ' . $object->GetID() . ' AND
' . ($selected_zips ? 'DestValue NOT IN (' . implode(',', $selected_zips) . ') AND' : '') . '
StdDestId = ' . $country_id . '
ORDER BY DestValue';
break;
default:
throw new Exception('Unknown "show" parameter value "' . $params['show'] . '" used');
break;
}
$zips = $this->Conn->GetCol($sql);
$ret = '';
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['block'];
foreach($zips as $zip) {
$block_params['id'] = '0|' . $zip;
$block_params['destination_title'] = $zip;
$ret .= $this->Application->ParseBlock($block_params);
}
return $ret;
}
/**
* Returns table for shipping zone destinations
*
* @param Array $params
* @return string
*/
function getDestinationsTable($params)
{
static $table_name = '';
if (!$table_name) {
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$table_name = $this->Application->getUnitOption('dst', 'TableName');
if ($object->IsTempTable()) {
$table_name = $this->Application->GetTempName($table_name, 'prefix:' . $this->Prefix);
}
}
return $table_name;
}
}
\ No newline at end of file
Index: branches/5.2.x/units/orders/orders_tag_processor.php
===================================================================
--- branches/5.2.x/units/orders/orders_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/orders/orders_tag_processor.php (revision 15156)
@@ -1,1713 +1,1713 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class OrdersTagProcessor extends kDBTagProcessor
{
/**
* Print location using only filled in fields
*
* @param Array $params
* @access public
*/
function PrintLocation($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$type = getArrayValue($params,'type');
if($type == 'Company')
{
return $this->PrintCompanyLocation($params);
}
$fields = Array('City','State','Zip','Country');
$ret = '';
foreach($fields as $field)
{
$value = $object->GetField($type.$field);
if ($field == 'Country' && $value) $ret .= '<br/>';
if($value) $ret .= $value.', ';
}
return rtrim($ret,', ');
}
function PrintCompanyLocation($params)
{
$ret = '';
$fields = Array ('City','State','ZIP','Country');
foreach ($fields as $field) {
$value = $this->Application->ConfigValue('Comm_'.$field);
if ($field == 'Country') {
$current_language = $this->Application->GetVar('m_lang');
$primary_language = $this->Application->GetDefaultLanguageId();
$sql = 'SELECT IF(l' . $current_language . '_Name = "", l' . $primary_language . '_Name, l' . $current_language . '_Name)
FROM ' . TABLE_PREFIX . 'CountryStates
WHERE IsoCode = ' . $this->Conn->qstr($value);
$value = $this->Conn->GetOne($sql);
}
if ($field == 'Country' && $value) {
$ret .= '<br/>';
}
if ($value) {
$ret .= $value.', ';
}
}
return rtrim($ret,', ');
}
function Orditems_LinkRemoveFromCart($params)
{
return $this->Application->HREF($this->Application->GetVar('t'), '', Array('pass' => 'm,orditems,ord', 'ord_event' => 'OnRemoveFromCart', 'm_cat_id'=>0));
}
function Orderitems_ProductLink($params)
{
$object = $this->Application->recallObject('orditems');
$url_params = Array (
'p_id' => $object->GetDBField('ProductId'),
'pass' => 'm,p',
);
return $this->Application->HREF($params['template'], '', $url_params);
}
function Orderitems_ProductExists($params)
{
$object = $this->Application->recallObject('orditems');
return $object->GetDBField('ProductId') > 0;
}
function PrintCart($params)
{
$o = '';
$params['render_as'] = $params['item_render_as'];
$tag_params = array_merge($params, Array ('per_page' => -1));
$o_items = $this->Application->ProcessParsedTag(rtrim('orditems.' . $this->Special, '.'), 'PrintList', $tag_params);
if ( $o_items ) {
if ( isset($params['header_render_as']) ) {
$cart_params = array ('name' => $params['header_render_as']);
$o .= $this->Application->ParseBlock($cart_params);
}
$o .= $o_items;
if ( isset($params['footer_render_as']) ) {
$cart_params = array ('name' => $params['footer_render_as']);
$o .= $this->Application->ParseBlock($cart_params);
}
}
elseif ( isset($params['empty_cart_render_as']) ) {
$cart_params = array ('name' => $params['empty_cart_render_as']);
$o = $this->Application->ParseBlock($cart_params);
}
return $o;
}
function ShopCartForm($params)
{
return $this->Application->ProcessParsedTag('m', 'ParseBlock', array_merge($params, Array(
'name' => 'kernel_form', 'PrefixSpecial'=>'ord'
)) );
}
function BackOrderFlag($params)
{
$object = $this->Application->recallObject('orditems');
return $object->GetDBField('BackOrderFlag');
}
function OrderIcon($params)
{
$object = $this->Application->recallObject('orditems');
if ($object->GetDBField('BackOrderFlag') == 0) {
return $params['ordericon'];
} else {
return $params['backordericon'];
}
}
function Status($params)
{
$status_map = Array(
'incomplete' => ORDER_STATUS_INCOMPLETE,
'pending' => ORDER_STATUS_PENDING,
'backorder' => ORDER_STATUS_BACKORDERS,
'toship' => ORDER_STATUS_TOSHIP,
'processed' => ORDER_STATUS_PROCESSED,
'denied' => ORDER_STATUS_DENIED,
'archived' => ORDER_STATUS_ARCHIVED,
);
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$status = $object->GetDBField('Status');
$result = true;
if (isset($params['is'])) {
$result = $result && ($status == $status_map[$params['is']]);
}
if (isset($params['is_not'])) {
$result = $result && ($status != $status_map[$params['is_not']]);
}
return $result;
}
function ItemsInCart($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
if ( $object->GetDBField('Status') != ORDER_STATUS_INCOMPLETE || $object->GetID() == FAKE_ORDER_ID ) {
return 0;
}
$object = $this->Application->recallObject('orditems', 'orditems_List');
/* @var $object kDBList */
$object->Query();
return array_sum($object->GetCol('Quantity')); // $object->GetRecordsCount();
}
function CartNotEmpty($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
if ($object->GetDBField('Status') != ORDER_STATUS_INCOMPLETE || $object->GetID() == FAKE_ORDER_ID) {
return 0;
}
$order_id = $this->Application->RecallVar('ord_id');
if ($order_id) {
$sql = 'SELECT COUNT(*)
FROM ' . TABLE_PREFIX . 'OrderItems
WHERE OrderId = ' . $order_id;
return $this->Conn->GetOne($sql);
}
return 0;
}
function CartIsEmpty($params)
{
return $this->CartNotEmpty($params) ? false : true;
}
function CartHasBackorders($params = Array ())
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$sql = 'SELECT COUNT(*)
FROM ' . TABLE_PREFIX . 'OrderItems
WHERE OrderId = ' . $object->GetID() . '
GROUP BY BackOrderFlag';
$different_types = $this->Conn->GetCol($sql);
return count($different_types) > 1;
}
function PrintShippings($params)
{
$o = '';
$limitations_cache = Array ();
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$ord_id = $object->GetID();
$oi_table = $this->Application->getUnitOption('orditems', 'TableName');
if ( $object->IsTempTable() ) {
$oi_table = $this->Application->GetTempName($oi_table, 'prefix:' . $object->Prefix);
}
list ($split_shipments, $limit_types) = $this->GetShippingLimitations($ord_id);
foreach ($split_shipments as $group => $data) {
$sql = 'UPDATE ' . $oi_table . '
SET SplitShippingGroup = ' . $group . '
WHERE ProductId IN (' . implode(',', $data['Products']) . ')';
$this->Conn->Query($sql);
$limitations_cache[$group] = $data['Types'];
}
$shipping_group_option = $object->GetDBField('ShippingGroupOption');
$shipping_group_select = $shipping_group_option == ORDER_GROUP_SHIPPMENTS_AUTO ? '0' : 'oi.SplitShippingGroup';
if ( count($split_shipments) > 1 ) {
// different shipping limitations apply
$this->Application->SetVar('shipping_limitations_apply', 1);
if ( $limit_types == 'NONE' ) {
// order can't be shipped with single shipping type
$shipping_group_option = ORDER_GROUP_SHIPPMENTS_MANUAL;
$shipping_group_select = 'oi.SplitShippingGroup';
$this->Application->SetVar('shipping_limitations_apply', 2);
}
}
else {
$this->Application->SetVar('shipping_limitations_apply', 0);
}
$shipping_option = $object->GetDBField('ShippingOption');
$weight_sql = 'IF(oi.Weight IS NULL, 0, oi.Weight * oi.Quantity)';
$sql = 'SELECT
' . ($shipping_option == ORDER_SHIP_ALL_TOGETHER ? '0' : 'oi.BackOrderFlag') . ' AS BackOrderFlagCalc,
oi.ProductName,
oi.ShippingTypeId,
SUM(oi.Quantity) AS TotalItems,
SUM(' . $weight_sql . ') AS TotalWeight,
SUM(oi.Price * oi.Quantity) AS TotalAmount,
SUM(oi.Quantity) - SUM(IF(p.MinQtyFreePromoShipping > 0 AND p.MinQtyFreePromoShipping <= oi.Quantity, oi.Quantity, 0)) AS TotalItemsPromo,
SUM(' . $weight_sql . ') - SUM(IF(p.MinQtyFreePromoShipping > 0 AND p.MinQtyFreePromoShipping <= oi.Quantity, ' . $weight_sql . ', 0)) AS TotalWeightPromo,
SUM(oi.Price * oi.Quantity) - SUM(IF(p.MinQtyFreePromoShipping > 0 AND p.MinQtyFreePromoShipping <= oi.Quantity, oi.Price * oi.Quantity, 0)) AS TotalAmountPromo,
' . $shipping_group_select . ' AS SplitShippingGroupCalc
FROM ' . $oi_table . ' oi
LEFT JOIN ' . TABLE_PREFIX . 'Products p ON oi.ProductId = p.ProductId
WHERE oi.OrderId = ' . $ord_id . ' AND p.Type = ' . PRODUCT_TYPE_TANGIBLE . '
GROUP BY BackOrderFlagCalc, SplitShippingGroupCalc
ORDER BY BackOrderFlagCalc ASC, SplitShippingGroupCalc ASC';
$shipments = $this->Conn->Query($sql);
$block_params = Array ();
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['user_country_id'] = $object->GetDBField('ShippingCountry');
$block_params['user_state_id'] = $object->GetDBField('ShippingState');
$block_params['user_zip'] = $object->GetDBField('ShippingZip');
$block_params['user_city'] = $object->GetDBField('ShippingCity');
$block_params['user_addr1'] = $object->GetDBField('ShippingAddress1');
$block_params['user_addr2'] = $object->GetDBField('ShippingAddress2');
$block_params['user_name'] = $object->GetDBField('ShippingTo');
$group = 1;
foreach ($shipments as $shipment) {
$where = Array ('OrderId = ' . $ord_id);
if ( $shipping_group_option == ORDER_GROUP_SHIPPMENTS_MANUAL ) {
$where[] = 'SplitShippingGroup = ' . $shipment['SplitShippingGroupCalc'];
}
if ( $shipping_option != ORDER_SHIP_ALL_TOGETHER ) {
$where[] = 'BackOrderFlag = ' . $shipment['BackOrderFlagCalc'];
}
$sql = 'UPDATE ' . $oi_table . '
SET PackageNum = ' . $group . '
WHERE ' . implode(' AND ', $where);
$this->Conn->Query($sql);
$group++;
}
$group = 1;
$this->Application->RemoveVar('LastShippings');
$this->Application->SetVar('ShipmentsExists', 1);
foreach ($shipments as $shipment) {
$block_params['package_num'] = $group;
$block_params['limit_types'] = $shipping_group_option == ORDER_GROUP_SHIPPMENTS_AUTO ? $limit_types : $limitations_cache[ $shipment['SplitShippingGroupCalc'] ];
$this->Application->SetVar('ItemShipmentsExists', 1); // also set from Order_PrintShippingTypes tag
switch ( $shipment['BackOrderFlagCalc'] ) {
case 0:
if ( $this->CartHasBackOrders() && $shipping_option == ORDER_SHIP_ALL_TOGETHER ) {
$block_params['shipment'] = $this->Application->Phrase('lu_all_available_backordered');
}
else {
$block_params['shipment'] = $this->Application->Phrase('lu_ship_all_available');;
}
break;
case 1:
$block_params['shipment'] = $this->Application->Phrase('lu_ship_all_backordered');;
break;
default:
$block_params['shipment'] = $this->Application->Phrase('lu_ship_backordered');
break;
}
$block_params['promo_weight_metric'] = $shipment['TotalWeightPromo'];
$block_params['promo_amount'] = $shipment['TotalAmountPromo'];
$block_params['promo_items'] = $shipment['TotalItemsPromo'];
$block_params['weight_metric'] = $shipment['TotalWeight'];
$block_params['weight'] = $shipment['TotalWeight'];
if ( $block_params['weight_metric'] == '' ) {
$block_params['weight'] = $this->Application->Phrase('lu_NotAvailable');
}
else {
$block_params['weight'] = $this->_formatWeight( $block_params['weight'] );
}
$block_params['items'] = $shipment['TotalItems'];
$amount = $this->ConvertCurrency($shipment['TotalAmount'], $this->GetISO( $params['currency'] ));
$amount = sprintf("%.2f", $amount);
$block_params['amount'] = $shipment['TotalAmount'];
$block_params['field_name'] = $this->InputName( Array('field' => 'ShippingTypeId') ) . '[' . $group . ']';
$parsed_block = $this->Application->ParseBlock($block_params);
if ( $this->Application->GetVar('ItemShipmentsExists') ) {
$o .= $parsed_block;
}
else {
$this->Application->SetVar('ShipmentsExists', 0);
if ( getArrayValue($params, 'no_shipments_render_as') ) {
$block_params['name'] = $params['no_shipments_render_as'];
return $this->Application->ParseBlock($block_params);
}
}
$group++;
}
if ( getArrayValue($params, 'table_header_render_as') ) {
$o = $this->Application->ParseBlock(Array ('name' => $params['table_header_render_as'])) . $o;
}
if ( getArrayValue($params, 'table_footer_render_as') ) {
$o .= $this->Application->ParseBlock(Array ('name' => $params['table_footer_render_as']));
}
return $o;
}
/**
* Checks, that all given address fields are valid
*
* @param Array $params
* @return bool
*/
function AddressValid($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$address_type = isset($params['type']) ? strtolower($params['type']) : 'shipping';
$address_type = ucfirst($address_type);
$check_fields = Array ('Address1', 'City', 'Zip', 'Country');
foreach ($check_fields as $check_field) {
if ( $object->GetDBField($address_type . $check_field) == '' ) {
return false;
}
}
return true;
}
function GetShippingLimitations($ord_id)
{
$limit_types = false;
$types_index = $split_shipments = $cat_limitations = Array ();
$sql = 'SELECT p.ShippingLimitation, p.ShippingMode, oi.ProductId AS ProductId
FROM ' . TABLE_PREFIX . 'Products p
LEFT JOIN ' . TABLE_PREFIX . 'OrderItems AS oi ON oi.ProductId = p.ProductId
WHERE oi.OrderId = ' . $ord_id . ' AND p.Type = ' . PRODUCT_TYPE_TANGIBLE;
$limitations = $this->Conn->Query($sql, 'ProductId');
// group products by shipping type range and calculate intersection of all types available for ALL products
// the intersection calculation is needed to determine if the order can be shipped with single type or not
if ($limitations) {
foreach ($limitations as $product_id => $row) {
// if shipping types are limited - get the types
$types = $row['ShippingLimitation'] != '' ? explode('|', substr($row['ShippingLimitation'], 1, -1)) : Array ('ANY');
// if shipping is NOT limited to selected types (default - so products with no limitations at all also counts)
if ($row['ShippingMode'] == PRODUCT_SHIPPING_MODE_ANY_AND_SELECTED) {
array_push($types, 'ANY'); // can be shipped with ANY (literally) type
$types = array_unique($types);
}
//adding product id to split_shipments group by types range
$i = array_search(serialize($types), $types_index);
if ($i === false) {
$types_index[] = serialize($types);
$i = count($types_index) - 1;
}
$split_shipments[$i]['Products'][] = $product_id;
$split_shipments[$i]['Types'] = serialize($types);
if ($limit_types === false) {
// it is false only when we process first item with limitations
$limit_types = $types; // initial scope
}
// this is to avoid ANY intersect CUST_1 = (), but allows ANY intersect CUST_1,ANY = (ANY)
if ( in_array('ANY', $limit_types) && !in_array('ANY', $types) ) {
array_splice($limit_types, array_search('ANY', $limit_types), 1, $types);
}
// this is to avoid CUST_1 intersect ANY = (), but allows CUST_1 intersect CUST_1,ANY = (ANY)
if ( !in_array('ANY', $limit_types) && in_array('ANY', $types) ) {
array_splice($types, array_search('ANY', $types), 1, $limit_types);
}
$limit_types = array_intersect($limit_types, $types);
}
$limit_types = count($limit_types) > 0 ? serialize(array_unique($limit_types)) : 'NONE';
}
return Array ($split_shipments, $limit_types);
}
function PaymentTypeForm($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$payment_type_id = $object->GetDBField('PaymentType');
if($payment_type_id)
{
$this->Application->SetVar('pt_id', $payment_type_id);
$block_params['name'] = $this->SelectParam($params, $this->UsingCreditCard($params) ? 'cc_render_as,block_cc' : 'default_render_as,block_default' );
return $this->Application->ParseBlock($block_params);
}
return '';
}
/**
* Returns true in case if credit card was used as payment type for order
*
* @param Array $params
* @return bool
*/
function UsingCreditCard($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$pt = $object->GetDBField('PaymentType');
if (!$pt) {
$pt = $this->Conn->GetOne('SELECT PaymentTypeId FROM '.TABLE_PREFIX.'PaymentTypes WHERE IsPrimary = 1');
$object->SetDBField('PaymentType', $pt);
}
$pt_table = $this->Application->getUnitOption('pt','TableName');
$sql = 'SELECT GatewayId FROM %s WHERE PaymentTypeId = %s';
$gw_id = $this->Conn->GetOne( sprintf( $sql, $pt_table, $pt ) );
$sql = 'SELECT RequireCCFields FROM %s WHERE GatewayId = %s';
return $this->Conn->GetOne( sprintf($sql, TABLE_PREFIX.'Gateways', $gw_id) );
}
function PaymentTypeDescription($params)
{
return $this->Application->ProcessParsedTag('pt', 'Field', array_merge($params, Array(
'field' => 'Description'
)) );
}
function PaymentTypeInstructions($params)
{
return $this->Application->ProcessParsedTag('pt', 'Field', array_merge($params, Array(
'field' => 'Instructions'
)) );
}
function PrintMonthOptions($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$date = explode('/', $object->GetDBField($params['date_field_name']));
if (!$date || sizeof($date) != 2) {
$date=array("", "");
}
$o = '';
$params['name'] = $params['block'];
for ($i = 1; $i <= 12; $i++) {
$month_str = str_pad($i, 2, "0", STR_PAD_LEFT);
if ($date[0] == $month_str) {
$params['selected'] = ' selected';
}else {
$params['selected'] = '';
}
$params['mm'] = $month_str;
$o .= $this->Application->ParseBlock($params);
}
return $o;
}
function PrintYearOptions($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$value = $object->GetDBField( $params['field'] );
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$o = '';
$this_year = adodb_date('y');
for($i = $this_year; $i <= $this_year + 10; $i++)
{
$year_str = str_pad($i, 2, '0', STR_PAD_LEFT);
$block_params['selected'] = ($value == $year_str) ? $params['selected'] : '';
$block_params['key'] = $year_str;
$block_params['option'] = $year_str;
$o .= $this->Application->ParseBlock($block_params);
}
return $o;
}
function PrintMyOrders($params)
{
}
/**
* Checks, that order data can be editied based on it's status
*
* @param Array $params
* @return bool
*/
function OrderEditable($params)
{
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
$table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
if ($this->Application->IsTempMode($this->Prefix, $this->Special)) {
$table_name = $this->Application->GetTempName($table_name, 'prefix:' . $this->Prefix);
}
// use direct select here (not $this->getObject) because this tag is
// used even before "combined_header" block is used (on "orders_edit_items" template)
$sql = 'SELECT Status, PaymentType
FROM ' . $table_name . '
WHERE ' . $id_field . ' = ' . $this->Application->GetVar( $this->getPrefixSpecial() . '_id' );
$order_data = $this->Conn->GetRow($sql);
if (!$order_data) {
// new order adding, when even not in database
return true;
}
switch ($order_data['Status']) {
case ORDER_STATUS_INCOMPLETE:
$ret = true;
break;
case ORDER_STATUS_PENDING:
case ORDER_STATUS_BACKORDERS:
$sql = 'SELECT PlacedOrdersEdit
FROM ' . $this->Application->getUnitOption('pt', 'TableName') . '
WHERE ' . $this->Application->getUnitOption('pt', 'IDField') . ' = ' . $order_data['PaymentType'];
$ret = $this->Conn->GetOne($sql);
break;
default:
$ret = false;
break;
}
return $ret;
}
function CheckoutSteps($params)
{
$steps = explode(',', $params['steps']);
foreach ($steps as $key => $item)
{
$templates[$key] = trim($item);
}
$templates = explode(',', $params['templates']);
foreach ($templates as $key => $item)
{
$templates[$key] = trim($item);
}
$total_steps = count($templates);
$t = $this->Application->GetVar('t');
$o = '';
$block_params = array();
$i = 0;
$passed_current = preg_match("/".preg_quote($templates[count($templates)-1], '/')."/", $t);
foreach ($steps as $step => $name)
{
if (preg_match("/".preg_quote($templates[$step], '/')."/", $t)) {
$block_params['name'] = $this->SelectParam($params, 'current_step_render_as,block_current_step');
$passed_current = true;
}
else {
$block_params['name'] = $passed_current ? $this->SelectParam($params, 'render_as,block') : $this->SelectParam($params, 'passed_step_render_as,block_passed_step');
}
$block_params['title'] = $this->Application->Phrase($name);
$block_params['template'] = $templates[$i];
$block_params['template_link'] = $this->Application->HREF($templates[$step], '', Array('pass'=>'m'));
$block_params['next_step_template'] = isset($templates[$i + 1]) ? $templates[$i + 1] : '';
$block_params['number'] = $i + 1;
$i++;
$o.= $this->Application->ParseBlock($block_params, 1);
}
return $o;
}
function ShowOrder($params)
{
$order_params = $this->prepareTagParams($params);
// $order_params['Special'] = 'myorders';
// $order_params['PrefixSpecial'] = 'ord.myorders';
$order_params['name'] = $this->SelectParam($order_params, 'render_as,block');
// $this->Application->SetVar('ord.myorders_id', $this->Application->GetVar('ord_id'));
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
if (!$object->GetDBField('OrderId')) {
return;
}
return $this->Application->ParseBlock($order_params);
}
function BuildListSpecial($params)
{
if ($this->Special != '') {
return $this->Special;
}
$list_unique_key = $this->getUniqueListKey($params);
if ($list_unique_key == '') {
return parent::BuildListSpecial($params);
}
return crc32($list_unique_key);
}
function ListOrders($params)
{
$o = '';
$params['render_as'] = $params['item_render_as'];
$o_orders = $this->PrintList2($params);
if ($o_orders) {
$orders_params = array('name' => $params['header_render_as']);
$o = $this->Application->ParseBlock($orders_params);
$o .= $o_orders;
} else {
$orders_params = array('name' => $params['empty_myorders_render_as']);
$o = $this->Application->ParseBlock($orders_params);
}
return $o;
}
function HasRecentOrders($params)
{
$per_page = $this->SelectParam($params, 'per_page,max_items');
if ($per_page !== false) {
$params['per_page'] = $per_page;
}
return (int)$this->TotalRecords($params) > 0 ? 1 : 0;
}
function ListOrderItems($params)
{
$prefix_special = rtrim('orditems.'.$this->Special, '.');
return $this->Application->ProcessParsedTag($prefix_special, 'PrintList', array_merge($params, Array(
'per_page' => -1
)) );
}
function OrdersLink(){
$params['pass']='m,ord';
$main_processor = $this->Application->recallObject('m_TagProcessor');
return $main_processor->Link($params);
}
function PrintAddresses($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$address_list = $this->Application->recallObject('addr','addr_List', Array('per_page'=>-1, 'skip_counting'=>true) );
$address_list->Query();
$address_id = $this->Application->GetVar($params['type'].'_address_id');
if (!$address_id) {
$sql = 'SELECT '.$address_list->IDField.'
FROM '.$address_list->TableName.'
WHERE PortalUserId = '.$object->GetDBField('PortalUserId').' AND LastUsedAs'.ucfirst($params['type']).' = 1';
$address_id = (int)$this->Conn->GetOne($sql);
}
$ret = '';
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$address_list->GoFirst();
while (!$address_list->EOL()) {
$selected = ($address_list->GetID() == $address_id);
if ($selected && $address_list->GetDBField('IsProfileAddress')) {
$this->Application->SetVar($this->Prefix.'_IsProfileAddress', true);
}
$block_params['key'] = $address_list->GetID();
$block_params['value'] = $address_list->GetDBField('ShortAddress');
$block_params['selected'] = $selected ? ' selected="selected"' : '';
$ret .= $this->Application->ParseBlock($block_params, 1);
$address_list->GoNext();
}
return $ret;
}
function PrefillRegistrationFields($params)
{
if ( $this->Application->GetVar('fields_prefilled') ) {
return false;
}
if ( isset($params['user_prefix']) ) {
$user = $this->Application->recallObject($params['user_prefix']);
/* @var $user kDBItem */
}
else {
$user = $this->Application->recallObject('u', null, Array ('skip_autoload' => true));
/* @var $user kDBItem */
}
$order = $this->Application->recallObject($this->Prefix . '.last');
/* @var $order OrdersItem */
$order_helper = $this->Application->recallObject('OrderHelper');
/* @var $order_helper OrderHelper */
$user_fields = $order_helper->getUserFields($order, $params['type'] == 'billing' ? 'Billing' : 'Shipping');
foreach ($user_fields as $field => $value) {
if ( !$user->GetDBField($field) ) {
$user->SetDBField($field, $value);
}
}
$cs_helper = $this->Application->recallObject('CountryStatesHelper');
/* @var $cs_helper kCountryStatesHelper */
$cs_helper->PopulateStates(new kEvent('u:OnBuild'), 'State', 'Country');
}
function UserLink($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$user_id = $object->GetDBField( $params['user_field'] );
if ($user_id) {
$url_params = Array (
'm_opener' => 'd',
'u_mode' => 't',
'u_event' => 'OnEdit',
'u_id' => $user_id,
'pass' => 'all,u',
'no_pass_through' => 1,
);
return $this->Application->HREF($params['edit_template'], '', $url_params);
}
}
function UserFound($params)
{
$virtual_users = Array(USER_ROOT, USER_GUEST, 0);
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
return !in_array( $object->GetDBField( $params['user_field'] ) , $virtual_users );
}
/**
* Returns a link for editing order
*
* @param Array $params
* @return string
*/
function OrderLink($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$url_params = Array (
'm_opener' => 'd',
$this->Prefix.'_mode' => 't',
$this->Prefix.'_event' => 'OnEdit',
$this->Prefix.'_id' => $object->GetID(),
'pass' => 'all,'.$this->Prefix,
'no_pass_through' => 1,
);
return $this->Application->HREF($params['edit_template'], '', $url_params);
}
function HasOriginalAmount($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$original_amount = $object->GetDBField('OriginalAmount');
return $original_amount && ($original_amount != $object->GetDBField('TotalAmount') );
}
/**
* Returns true, when order has tangible items
*
* @param Array $params
* @return bool
*
* @todo This is copy from OrdersItem::HasTangibleItems. Copy to helper (and create it) and use here.
*/
function OrderHasTangibleItems($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
if ($object->GetID() == FAKE_ORDER_ID) {
return false;
}
$sql = 'SELECT COUNT(*)
FROM '.TABLE_PREFIX.'OrderItems orditems
LEFT JOIN '.TABLE_PREFIX.'Products p ON p.ProductId = orditems.ProductId
WHERE (orditems.OrderId = '.$object->GetID().') AND (p.Type = '.PRODUCT_TYPE_TANGIBLE.')';
return $this->Conn->GetOne($sql) ? true : false;
}
function ShipmentsExists($params)
{
return $this->Application->GetVar('ShipmentsExists') ? 1 : 0;
}
function Field($params)
{
$value = parent::Field($params);
$field = $this->SelectParam($params,'name,field');
if( ($field == 'PaymentAccount') && getArrayValue($params,'masked') )
{
$value = str_repeat('X',12).substr($value,-4);
}
return $value;
}
function CartHasError($params)
{
return $this->Application->RecallVar('checkout_errors');
}
function CheckoutError($params)
{
$errors = $this->Application->RecallVar('checkout_errors');
if ( !$errors ) {
return '';
}
// $this->Application->RemoveVar('checkout_errors');
$errors = unserialize($errors);
if ( isset($errors[OrderCheckoutErrorType::COUPON]) ) {
$mapping = Array (
OrderCheckoutError::COUPON_APPLIED => 'coupon_applied',
OrderCheckoutError::COUPON_REMOVED => 'code_removed',
OrderCheckoutError::COUPON_REMOVED_AUTOMATICALLY => 'code_removed_automatically',
OrderCheckoutError::COUPON_CODE_INVALID => 'invalid_code',
OrderCheckoutError::COUPON_CODE_EXPIRED => 'code_expired',
);
$error_phrase = $mapping[ $errors[OrderCheckoutErrorType::COUPON] ];
}
elseif ( isset($errors[OrderCheckoutErrorType::GIFT_CERTIFICATE]) ) {
$mapping = Array (
OrderCheckoutError::GC_APPLIED => 'gift_certificate_applied',
OrderCheckoutError::GC_REMOVED => 'gc_code_removed',
OrderCheckoutError::GC_REMOVED_AUTOMATICALLY => 'gc_code_removed_automatically',
OrderCheckoutError::GC_CODE_INVALID => 'invalid_gc_code',
OrderCheckoutError::GC_CODE_EXPIRED => 'gc_code_expired',
);
$error_phrase = $mapping[ $errors[OrderCheckoutErrorType::GIFT_CERTIFICATE] ];
}
else {
$mapping = Array (
OrderCheckoutError::QTY_UNAVAILABLE => 'qty_unavailable',
OrderCheckoutError::QTY_OUT_OF_STOCK => 'outofstock',
OrderCheckoutError::QTY_CHANGED_TO_MINIMAL => 'min_qty',
);
foreach ($errors as $error_type => $error_code) {
if ( isset($mapping[$error_code]) ) {
$error_phrase = $mapping[$error_code];
break;
}
}
if ( !isset($error_phrase) ) {
$error_phrase = 'state_changed'; // 'changed_after_login'
}
}
return $this->Application->Phrase( $params[$error_phrase] );
}
/**
* Returns checkout errors in JSON format
*
* @param Array $params
* @return string
*/
function PrintOrderInfo($params)
{
$order_helper = $this->Application->recallObject('OrderHelper');
/* @var $order_helper OrderHelper */
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$currency = isset($params['currency']) ? $params['currency'] : 'selected';
return json_encode( $order_helper->getOrderInfo($object, $currency) );
}
/**
* Returns currency mark (%s is $amount placemark)
*
* @param Array $params
* @return string
*/
function CurrencyMask($params)
{
$iso = $this->GetISO( $params['currency'] );
return $this->AddCurrencySymbol('%s', $iso);
}
function CheckoutErrorNew($params)
{
$errors = $this->Application->RecallVar('checkout_errors');
if ( !$errors ) {
return '';
}
// $this->Application->RemoveVar('checkout_errors');
$errors = unserialize($errors);
$reflection = new ReflectionClass('OrderCheckoutErrorType');
$error_types = $reflection->getConstants();
$reflection = new ReflectionClass('OrderCheckoutError');
$error_codes = $reflection->getConstants();
$ret = Array ();
foreach ($errors as $error_type => $error_code) {
$error_type = explode(':', $error_type);
$error_explained = '<strong>' . array_search($error_type[0], $error_types) . '</strong>';
if ( $error_type[0] == OrderCheckoutErrorType::PRODUCT ) {
$error_explained .= ' (ProductId = <strong>' . $error_type[1] . '</strong>; OptionsSalt: <strong>' . $error_type[2] . '</strong>; BackOrderFlag: ' . $error_type[3] . '; Field: <strong>' . $error_type[4] . '</strong>)';
}
$error_explained .= ' - <strong>' . array_search($error_code, $error_codes) . '</strong>';
$ret[] = $error_explained;
}
return implode('<br/>', $ret);
}
function GetFormAction($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object OrdersItem */
$gw_data = $object->getGatewayData( isset($params['payment_type_id']) ? $params['payment_type_id'] : null );
$this->Application->registerClass( $gw_data['ClassName'], GW_CLASS_PATH.'/'.$gw_data['ClassFile'] );
$gateway_object = $this->Application->recallObject( $gw_data['ClassName'] );
/* @var $gateway_object kGWBase */
return $gateway_object->getFormAction($gw_data['gw_params']);
}
function GetFormHiddenFields($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object OrdersItem */
$gw_data = $object->getGatewayData( isset($params['payment_type_id']) ? $params['payment_type_id'] : null );
$this->Application->registerClass( $gw_data['ClassName'], GW_CLASS_PATH.'/'.$gw_data['ClassFile'] );
$gateway_object = $this->Application->recallObject( $gw_data['ClassName'] );
/* @var $gateway_object kGWBase */
$tpl = '<input type="hidden" name="%s" value="%s" />'."\n";
$hidden_fields = $gateway_object->getHiddenFields($object->GetFieldValues(), $params, $gw_data['gw_params']);
if ( !is_array($hidden_fields) ) {
return $hidden_fields;
}
$ret = '';
foreach ($hidden_fields as $hidden_name => $hidden_value) {
$ret .= sprintf($tpl, $hidden_name, $hidden_value);
}
return $ret;
}
function NeedsPlaceButton($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object OrdersItem */
$gw_data = $object->getGatewayData( isset($params['payment_type_id']) ? $params['payment_type_id'] : null );
$this->Application->registerClass( $gw_data['ClassName'], GW_CLASS_PATH.'/'.$gw_data['ClassFile'] );
$gateway_object = $this->Application->recallObject( $gw_data['ClassName'] );
/* @var $gateway_object kGWBase */
return $gateway_object->NeedPlaceButton($object->GetFieldValues(), $params, $gw_data['gw_params']);
}
function HasGatewayError($params)
{
return $this->Application->RecallVar('gw_error');
}
function ShowGatewayError($params)
{
$ret = $this->Application->RecallVar('gw_error');
$this->Application->RemoveVar('gw_error');
return $ret;
}
function ShippingType($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$shipping_info = unserialize($object->GetDBField('ShippingInfo'));
if ( count($shipping_info) > 1 ) {
return $this->Application->Phrase('lu_MultipleShippingTypes');
}
if ( $shipping_info ) {
$shipping_info = array_shift($shipping_info);
return $shipping_info['ShippingName'];
}
return '';
}
function DiscountHelpLink($params)
{
$params['pass'] = 'all,orditems';
$params['m_cat_id'] = 0;
$m_tag_processor = $this->Application->recallObject('m_TagProcessor');
return $m_tag_processor->Link($params);
}
function DiscountField($params)
{
$orditems = $this->Application->recallObject( 'orditems' );
$item_data = $orditems->GetDBField('ItemData');
if(!$item_data) return '';
$item_data = unserialize($item_data);
$discount_prefix = ($item_data['DiscountType'] == 'coupon') ? 'coup' : 'd';
$discount = $this->Application->recallObject($discount_prefix, null, Array('skip_autoload' => true));
if(!$discount->isLoaded())
{
$discount->Load($item_data['DiscountId']);
}
return $discount->GetField( $this->SelectParam($params, 'field,name') );
}
function HasDiscount($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
return (float)$object->GetDBField('DiscountTotal') ? 1 : 0;
}
/**
* Allows to check if required product types are present in order
*
* @param Array $params
*/
function HasProductType($params)
{
$product_types = Array('tangible' => 1, 'subscription' => 2, 'service' => 3, 'downloadable' => 4, 'package' => 5, 'gift' => 6);
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$sql = 'SELECT COUNT(*)
FROM '.TABLE_PREFIX.'OrderItems oi
LEFT JOIN '.TABLE_PREFIX.'Products p ON p.ProductId = oi.ProductId
WHERE (oi.OrderId = '.$object->GetID().') AND (p.Type = '.$product_types[ $params['type'] ].')';
return $this->Conn->GetOne($sql);
}
function PrintSerializedFields($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$field = $this->SelectParam($params, 'field');
if (!$field) $field = $this->Application->GetVar('field');
$data = unserialize($object->GetDBField($field));
$o = '';
$block_params['name'] = $params['render_as'];
foreach ($data as $field => $value) {
$block_params['field'] = $field;
$block_params['value'] = $value;
$o .= $this->Application->ParseBlock($block_params);
}
return $o;
}
function OrderProductEmail($params)
{
$order = $this->Application->recallObject('ord');
$orditems = $this->Application->recallObject('orditems');
$sql = 'SELECT ResourceId
FROM '.TABLE_PREFIX.'Products
WHERE ProductId = '.$orditems->GetDBField('ProductId');
$resource_id = $this->Conn->GetOne($sql);
$ml_formatter = $this->Application->recallObject('kMultiLanguage');
$custom_fields = $this->Application->getUnitOption('p', 'CustomFields');
$custom_name = $ml_formatter->LangFieldName('cust_'.array_search($params['msg_custom_field'], $custom_fields));
$sql = 'SELECT '.$custom_name.'
FROM '.$this->Application->getUnitOption('p-cdata', 'TableName').'
WHERE ResourceId = '.$resource_id;
$message_template = $this->Conn->GetOne($sql);
if (!$message_template || trim($message_template) == '') {
// message template missing
return ;
}
$from_name = strip_tags($this->Application->ConfigValue('Site_Name'));
$from_email = $this->Application->ConfigValue('DefaultEmailSender');
$to_name = $order->GetDBField('BillingTo');
$to_email = $order->GetDBField('BillingEmail');
if (!$to_email) {
// billing email is empty, then use user's email
$sql = 'SELECT Email
FROM '.$this->Application->getUnitOption('u', 'TableName').'
WHERE PortalUserId = '.$order->GetDBField('PortalUserId');
$to_email = $this->Conn->GetOne($sql);
}
$esender = $application->recallObject('EmailSender.-product');
/* @var $esender kEmailSendingHelper */
$esender->SetFrom($from_email, $from_name);
$esender->AddTo($to_email, $to_name);
$email_events_eh = $this->Application->recallObject('emailevents_EventHandler');
/* @var $email_events_eh EmailEventsEventsHandler */
list ($message_headers, $message_body) = $email_events_eh->ParseMessageBody($message_template, Array());
if (!trim($message_body)) {
// message body missing
return false;
}
foreach ($message_headers as $header_name => $header_value) {
$esender->SetEncodedHeader($header_name, $header_value);
}
$esender->SetHTML($message_body);
$esender->Deliver();
}
/**
* Prints order totals
*
* @param Array $params
* @return string
* @access protected
*/
protected function PrintTotals($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object OrdersItem */
if ( isset($params['element_order']) ) {
// TODO: implement
}
else {
// default element order
$element_order = Array (
'products' => 1, 'return' => 4, 'sub_total' => 5, 'discount' => 6,
'vat' => 7, 'shipping' => 8, 'processing' => 9,
);
// show shipping & processing costs before tax, when they are taxable
if ( $object->GetDBField('ShippingTaxable') ) {
$element_order['shipping'] = 2;
}
if ( $object->GetDBField('ProcessingTaxable') ) {
$element_order['processing'] = 3;
}
}
$totals = Array ();
if ( abs($object->GetDBField('SubTotal') - $object->GetDBField('AmountWithoutVAT')) > 0.01 ) {
$totals[] = 'products';
}
if ( $this->OrderHasTangibleItems($params) ) {
$totals[] = 'shipping';
}
if ( $object->GetDBField('ProcessingFee') > 0 ) {
$totals[] = 'processing';
}
if ( $object->GetDBField('ReturnTotal') > 0 ) {
$totals[] = 'return';
}
if ( $this->HasDiscount($params) ) {
$totals[] = 'discount';
}
$totals[] = 'sub_total';
if ( $object->GetDBField('VAT') > 0 ) {
$totals[] = 'vat';
}
$o = '';
asort($element_order, SORT_NUMERIC);
$block_params = $this->prepareTagParams($params);
foreach ($element_order as $type => $order) {
$element = getArrayValue($params, $type . '_render_as');
if ( !in_array($type, $totals) || !$element ) {
continue;
}
$block_params['name'] = $element;
$o .= $this->Application->ParseBlock($block_params);
}
return $o;
}
function ShowDefaultAddress($params)
{
$address_type = ucfirst($params['type']);
if ($this->Application->GetVar('check_'.strtolower($address_type).'_address')) {
// form type doesn't match check type, e.g. shipping check on billing form
return '';
}
// for required field highlighting on form when no submit made
$this->Application->SetVar('check_'.strtolower($address_type).'_address', 'true');
/*if ((strtolower($address_type) == 'billing') && $this->UsingCreditCard($params)) {
$this->Application->SetVar('check_credit_card', 'true');
}*/
$this->Application->HandleEvent(new kEvent('ord:SetStepRequiredFields'));
$user_id = $this->Application->RecallVar('user_id');
$sql = 'SELECT AddressId
FROM '.TABLE_PREFIX.'Addresses
WHERE PortalUserId = '.$user_id.' AND LastUsedAs'.$address_type.' = 1';
$address_id = $this->Conn->GetOne($sql);
if (!$address_id) {
return '';
}
$addr_list = $this->Application->recallObject('addr', 'addr_List', Array('per_page'=>-1, 'skip_counting'=>true) );
$addr_list->Query();
- $object =& $this->getObject();
+ $object = $this->getObject();
if (!$addr_list->CheckAddress($object->GetFieldValues(), $address_type)) {
$addr_list->CopyAddress($address_id, $address_type);
}
}
function IsProfileAddress($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$address_type = ucfirst($params['type']);
return $object->IsProfileAddress($address_type);
}
function HasPayPalSubscription($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$sql = 'SELECT COUNT(*)
FROM '.TABLE_PREFIX.'OrderItems oi
LEFT JOIN '.TABLE_PREFIX.'Products p ON p.ProductId = oi.ProductId
WHERE (oi.OrderId = '.$object->GetID().') AND (p.PayPalRecurring = 1)';
return $this->Conn->GetOne($sql);
}
function GetPayPalSubscriptionForm($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$gw_data = $object->getGatewayData($params['payment_type_id']);
$this->Application->registerClass( $gw_data['ClassName'], GW_CLASS_PATH.'/'.$gw_data['ClassFile'] );
$gateway_object = $this->Application->recallObject( $gw_data['ClassName'] );
$sql = 'SELECT oi.*
FROM '.TABLE_PREFIX.'OrderItems oi
LEFT JOIN '.TABLE_PREFIX.'Products p ON p.ProductId = oi.ProductId
WHERE (oi.OrderId = '.$object->GetID().') AND (p.PayPalRecurring = 1)';
$order_item = $this->Conn->GetRow($sql);
$order_item_data = unserialize($order_item['ItemData']);
$cycle = ceil($order_item_data['Duration'] / 86400);
$cycle_units = 'D';
$item_data = $object->GetFieldValues();
$item_data['item_name'] = $order_item['ProductName'];
$item_data['item_number'] = $order_item['OrderItemId'];
$item_data['custom'] = $order_item['OrderId'];
$item_data['a1'] = '';
$item_data['p1'] = '';
$item_data['t1'] = '';
$item_data['a2'] = '';
$item_data['p2'] = '';
$item_data['t2'] = '';
$item_data['a3'] = $order_item['Price']; //rate
$item_data['p3'] = $cycle; //cycle
$item_data['t3'] = $cycle_units; //cycle units D (days), W (weeks), M (months), Y (years)
$item_data['src'] = '1'; // Recurring payments. If set to 1, the payment will recur unless your customer cancels the subscription before the end of the billing cycle.
$item_data['sra'] = '1'; // Reattempt on failure. If set to 1, and the payment fails, the payment will be reattempted two more times. After the third failure, the subscription will be cancelled.
$item_data['srt'] = ''; // Recurring Times. This is the number of payments which will occur at the regular rate.
$hidden_fields = $gateway_object->getSubscriptionFields($item_data, $params, $gw_data['gw_params']);
$ret = '';
if (!is_array($hidden_fields)) {
return $hidden_fields;
}
$tpl = '<input type="hidden" name="%s" value="%s" />'."\n";
foreach($hidden_fields as $hidden_name => $hidden_value)
{
$ret .= sprintf($tpl, $hidden_name, $hidden_value);
}
return $ret;
}
function UserHasPendingOrders($params)
{
$sql = 'SELECT OrderId FROM '.$this->Application->getUnitOption($this->Prefix, 'TableName').'
WHERE PortalUserId = '.$this->Application->RecallVar('user_id').'
AND Status = '.ORDER_STATUS_PENDING;
return $this->Conn->GetOne($sql) ? 1 : 0;
}
function AllowAddAddress($params)
{
$user = $this->Application->recallObject('u.current');
if ($user->GetDBField('cust_shipping_addr_block')) return false;
$address_list = $this->Application->recallObject('addr','addr_List', Array('per_page'=>-1, 'skip_counting'=>true) );
$address_list->Query();
$max = $this->Application->ConfigValue('MaxAddresses');
return $max <= 0 ? true : $address_list->GetRecordsCount() < $max;
}
/**
* Creates link for removing coupon or gift certificate
*
* @param Array $params
* @return string
*/
function RemoveCouponLink($params)
{
$type = strtolower($params['type']);
$url_params = Array (
'pass' => 'm,ord',
'ord_event' => ($type == 'coupon') ? 'OnRemoveCoupon' : 'OnRemoveGiftCertificate',
'm_cat_id' => 0,
);
return $this->Application->HREF('', '', $url_params);
}
/**
* Calculates total weight of items in shopping cart
*
* @param Array $params
* @return float
*/
function TotalOrderWeight($params)
{
- $object =& $this->getObject();
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$sql = 'SELECT SUM( IF(oi.Weight IS NULL, 0, oi.Weight * oi.Quantity) )
FROM '.TABLE_PREFIX.'OrderItems oi
WHERE oi.OrderId = '.$object->GetID();
$total_weight = $this->Conn->GetOne($sql);
if ($total_weight == '') {
// zero weight -> return text about it
return $this->Application->Phrase('lu_NotAvailable');
}
return $this->_formatWeight($total_weight);
}
function _formatWeight($weight)
{
$regional = $this->Application->recallObject('lang.current');
/* @var $regional kDBItem */
switch ( $regional->GetDBField('UnitSystem') ) {
case 1:
// metric system -> add kg sign
$weight .= ' ' . $this->Application->Phrase('lu_kg');
break;
case 2:
// uk system -> convert to pounds
list ($pounds, $ounces) = kUtil::Kg2Pounds($weight);
$weight = $pounds . ' ' . $this->Application->Phrase('lu_pounds') . ' ' . $ounces . ' ' . $this->Application->Phrase('lu_ounces');
break;
}
return $weight;
}
function InitCatalogTab($params)
{
$tab_params['mode'] = $this->Application->GetVar('tm'); // single/multi selection possible
$tab_params['special'] = $this->Application->GetVar('ts'); // use special for this tab
$tab_params['dependant'] = $this->Application->GetVar('td'); // is grid dependant on categories grid
// set default params (same as in catalog)
if ($tab_params['mode'] === false) $tab_params['mode'] = 'multi';
if ($tab_params['special'] === false) $tab_params['special'] = '';
if ($tab_params['dependant'] === false) $tab_params['dependant'] = 'yes';
// pass params to block with tab content
$params['name'] = $params['render_as'];
$params['prefix'] = trim($this->Prefix.'.'.($tab_params['special'] ? $tab_params['special'] : $this->Special), '.');
$params['cat_prefix'] = trim('c.'.($tab_params['special'] ? $tab_params['special'] : $this->Special), '.');
$params['tab_mode'] = $tab_params['mode'];
$params['grid_name'] = ($tab_params['mode'] == 'multi') ? $params['default_grid'] : $params['radio_grid'];
$params['tab_dependant'] = $tab_params['dependant'];
$params['show_category'] = $tab_params['special'] == 'showall' ? 1 : 0; // this is advanced view -> show category name
// use $pass_params to be able to pass 'tab_init' parameter from m_ModuleInclude tag
return $this->Application->ParseBlock($params, 1);
}
/**
* Checks if required payment method is available
*
* @param Array $params
* @return bool
*/
function HasPaymentGateway($params)
{
static $payment_types = Array ();
$gw_name = $params['name'];
if (!array_key_exists($gw_name, $payment_types)) {
$sql = 'SELECT pt.PaymentTypeId, pt.PortalGroups
FROM '.TABLE_PREFIX.'PaymentTypes pt
LEFT JOIN '.TABLE_PREFIX.'Gateways g ON pt.GatewayId = g.GatewayId
WHERE (g.Name = '.$this->Conn->qstr($params['name']).') AND (pt.Status = '.STATUS_ACTIVE.')';
$payment_types[$gw_name] = $this->Conn->GetRow($sql);
}
if (!$payment_types[$gw_name]) {
return false;
}
$pt_groups = explode(',', substr($payment_types[$gw_name]['PortalGroups'], 1, -1));
$user_groups = explode(',', $this->Application->RecallVar('UserGroups'));
return array_intersect($user_groups, $pt_groups) ? $payment_types[$gw_name]['PaymentTypeId'] : false;
}
function DisplayPaymentGateway($params)
{
$payment_type_id = $this->HasPaymentGateway($params);
if (!$payment_type_id) {
return '';
}
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object OrdersItem */
$gw_data = $object->getGatewayData($payment_type_id);
$block_params = $gw_data['gw_params'];
$block_params['name'] = $params['render_as'];
$block_params['payment_type_id'] = $payment_type_id;
return $this->Application->ParseBlock($block_params);
}
/**
* Checks, that USPS returned valid label
*
* @param Array $params
* @return bool
*/
function USPSLabelFound($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$full_path = USPS_LABEL_FOLDER . $object->GetDBField( $params['field'] ) . '.pdf';
return file_exists($full_path) && is_file($full_path);
}
/**
* Prints SQE errors from session
*
* @param Array $params
* @return string
*/
function PrintSQEErrors($params)
{
$sqe_errors = $this->Application->RecallVar('sqe_errors');
if (!$sqe_errors) {
return '';
}
$o = '';
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['render_as'];
$sqe_errors = unserialize($sqe_errors);
foreach ($sqe_errors as $order_number => $error_description) {
$block_params['order_number'] = $order_number;
$block_params['error_description'] = $error_description;
$o .= $this->Application->ParseBlock($block_params);
}
$this->Application->RemoveVar('sqe_errors');
return $o;
}
/**
* Creates a continue shopping link
*
* @param Array $params
* @return string
* @access protected
*/
protected function ContinueShoppingLink($params)
{
$order_helper = $this->Application->recallObject('OrderHelper');
/* @var $order_helper OrderHelper */
if ( isset($params['template']) ) {
$template = $params['template'];
unset($params['template']);
}
else {
$template = '';
}
return $this->Application->HREF($order_helper->getContinueShoppingTemplate($template), '', $params);
}
/**
* Checks that billing address and shipping address are the same
*
* @param Array $params
* @return string
* @access protected
*/
protected function AddressesTheSame($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$address_fields = Array ('To', 'Company', 'Address1', 'Address2', 'City', 'Country', 'State', 'Zip');
foreach ($address_fields as $address_field) {
if ( $object->GetDBField('Shipping' . $address_field) != $object->GetDBField('Billing' . $address_field) ) {
return false;
}
}
return true;
}
}
\ No newline at end of file
Index: branches/5.2.x/units/currencies/currencies_tag_processor.php
===================================================================
--- branches/5.2.x/units/currencies/currencies_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/currencies/currencies_tag_processor.php (revision 15156)
@@ -1,99 +1,99 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class CurrenciesTagProcessor extends kDBTagProcessor {
function DisableUnusedWarning($params)
{
$saved_ids = $this->Application->RecallVar('saved_curr_ids'); // when saving currency(-ies)
$check_all = $this->Application->RecallVar('check_unused_currencies'); // when saving payment type
$ret = '';
if($saved_ids || $check_all)
{
$sql = 'SELECT DISTINCT CurrencyId FROM '.$this->Application->getUnitOption('ptc', 'TableName');
$used_ids = $this->Conn->GetCol($sql);
if($check_all)
{
$sql = 'SELECT DISTINCT CurrencyId FROM '.$this->Application->getUnitOption('curr', 'TableName');
$all_ids = $this->Conn->GetCol($sql);
$unused_ids = implode(',', array_diff($all_ids, $used_ids) );
$this->Application->RemoveVar('check_unused_currencies');
}
else
{
$saved_ids = explode(',', $saved_ids);
$unused_ids = implode(',', array_diff($saved_ids, $used_ids) );
$this->Application->RemoveVar('saved_curr_ids');
}
if ( $unused_ids ) {
$this->Application->SetVar('unused_ids', $unused_ids);
$sql = 'SELECT ISO
FROM '.$this->Application->getUnitOption($this->Prefix, 'TableName').'
WHERE CurrencyId IN('.$unused_ids.') AND Status = 1';
$params['unused_iso'] = implode(', ', $this->Conn->GetCol($sql));
if ( $params['unused_iso'] ) {
$params['unused_ids'] = $unused_ids;
$params['name'] = $params['block'];
$ret = $this->Application->ParseBlock($params);
}
}
}
return $ret;
}
function ListCurrencies($params)
{
return $this->PrintList2($params);
}
function CurrencyLink($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$params['pass'] = 'm,curr';
$params['curr_event'] = 'OnChangeCurrency';
$params['curr_iso'] = $object->GetDBField('ISO');
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
function SelectedCurrency($params)
{
$object = $this->Application->recallObject($this->getPrefixSpecial());
return $object->GetDBField('ISO') == $this->Application->RecallVar('curr_iso');
}
function PrimaryCurrencyISO($params)
{
$sql = 'SELECT ISO
FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . '
WHERE IsPrimary = 1';
return $this->Conn->GetOne($sql);
}
function PrimaryCurrencyName($params)
{
$sql = 'SELECT Name
FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . '
WHERE IsPrimary = 1';
return $this->Application->Phrase( $this->Conn->GetOne($sql) );
}
}
\ No newline at end of file
Index: branches/5.2.x/units/products/products_tag_processor.php
===================================================================
--- branches/5.2.x/units/products/products_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/products/products_tag_processor.php (revision 15156)
@@ -1,856 +1,856 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class ProductsTagProcessor extends kCatDBTagProcessor {
function Rating($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$rating = round($object->GetDBField('CachedRating') );
$o = '';
for ($i = 0; $i < $rating; $i++) {
$o .= $this->Application->ParseBlock( Array('name' => $this->SelectParam($params, 'star_on_render_as,block_star_on')) );
}
for ($i = 0; $i < 5 - $rating; $i++) {
$o .= $this->Application->ParseBlock( Array('name' => $this->SelectParam($params, 'star_off_render_as,block_star_off')) );
}
return $o;
}
function NewMark($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$o = '';
if($object->GetDBField('IsNew'))
{
$o .= $this->Application->ParseBlock( Array('name' => $this->SelectParam($params, 'render_as,block')) );
}
return $o;
}
function HotMark($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$o = '';
if($object->GetDBField('IsHot'))
{
$o .= $this->Application->ParseBlock( Array('name' => $this->SelectParam($params, 'render_as,block')) );
}
return $o;
}
function TopSellerMark($params)
{
return $this->HotMark($params);
}
function PopMark($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$o = '';
if($object->GetDBField('IsPop'))
{
$o .= $this->Application->ParseBlock( Array('name' => $this->SelectParam($params, 'render_as,block')) );
}
return $o;
}
function EdPickMark($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$o = '';
if($object->GetDBField('EditorsPick'))
{
$o .= $this->Application->ParseBlock( Array('name' => $this->SelectParam($params, 'render_as,block')) );
}
return $o;
}
/**
* Parses block only if item is favorite
*
* @param Array $params
* @return string
* @deprecated used only in default,onlinestore
*/
function FavoriteMark($params)
{
if ($this->IsFavorite($params)) {
return $this->Application->ParseBlock( Array( 'name' => $this->SelectParam($params, 'render_as,block') ) );
}
return '';
}
function CurrentCategory($params)
{
$sql = "SELECT Name
FROM " . TABLE_PREFIX . "Categories
WHERE CategoryId=" . $this->Application->GetVar("m_cat_id");
return $this->Conn->GetOne($sql);
}
function RateForm($params)
{
$params['name'] = $this->SelectParam($params, 'render_as,block');
$labels = explode(',', $params['labels']);
$o = '';
$star_block = $this->SelectParam($params, 'star_render_as,star_block');
for($i = 5; $i >= 0; $i--)
{
$params['rating'] = $i;
$params['label'] = $this->Application->Phrase($labels[5 - $i]);
$params['stars'] = '';
for($j = $i; $j > 0; $j--)
{
$params['stars'] .= $this->Application->ParseBlock(Array('name' => $star_block));
}
$o .= $this->Application->ParseBlock($params);
}
return $o;
}
/**
* Parses block for changing favorite status
*
* @param Array $params
* @return string
* @deprecated used only in default,onlinestore
*/
function FavoriteToggle($params)
{
$block_params = Array ();
$block_names = $this->IsFavorite($params) ? 'remove_favorite_render_as,block_remove_favorite' : 'add_favorite_render_as,block_add_favorite';
$block_params['name'] = $this->SelectParam($params, $block_names);
$params['template'] = $params[$this->IsFavorite($params) ? 'template_on_remove' : 'template_on_add'];
$remove_params = Array (
'remove_favorite_render_as', 'block_remove_favorite', 'add_to_wish_list_render_as', 'block_add_to_wish_list',
'add_favorite_render_as', 'block_add_favorite', 'remove_from_wish_list_render_as', 'block_remove_from_wish_list',
'template_on_remove', 'template_on_add'
);
foreach ($params as $param_name => $param_value) {
if (in_array($param_name, $remove_params)) {
unset($params[$param_name]);
}
}
$block_params['wish_list_toggle_link'] = $this->FavoriteToggleLink($params);
return $this->Application->ParseBlock($block_params);
}
function WishListToggleLink($params)
{
$params['block_add_favorite'] = $this->SelectParam($params, 'add_to_wish_list_render_as,block_add_to_wish_list');
$params['block_remove_favorite'] = $this->SelectParam($params, 'remove_from_wish_list_render_as,block_remove_from_wish_list');
return $this->FavoriteToggle($params);
}
function AddReviewLink($params)
{
$o = $this->Application->ParseBlock( Array('name' => $this->SelectParam($params, 'render_as,block')) );
return $o;
}
function ListProducts($params)
{
return $this->PrintList2($params);
}
function ListRelatedProducts($params)
{
// $related = &$this->Application->recallObject('rel');
return $this->PrintList2($params);
}
function BuildListSpecial($params)
{
if ($this->Special != '') return $this->Special;
if ( isset($params['parent_cat_id']) ) {
$parent_cat_id = $params['parent_cat_id'];
}
else {
$parent_cat_id = $this->Application->GetVar('c_id');
if (!$parent_cat_id) {
$parent_cat_id = $this->Application->GetVar('m_cat_id');
}
}
if ( isset($params['manufacturer']) ) {
$manufacturer = $params['manufacturer'];
}
else {
$manufacturer = $this->Application->GetVar('manuf_id');
}
$recursive = isset($params['recursive']);
$list_unique_key = $this->getUniqueListKey($params).$recursive;
if ($list_unique_key == '') {
return parent::BuildListSpecial($params);
}
return crc32($parent_cat_id.$list_unique_key.$manufacturer);
}
function ProductList($params)
{
if($params['shortlist'])
{
$params['per_page'] = $this->Application->ConfigValue('Comm_Perpage_Products_Short');
}
$object = $this->Application->recallObject( $this->getPrefixSpecial() , $this->Prefix.'_List', $params );
switch($params['ListType'])
{
case 'favorites':
return $this->PrintList($params);
break;
case 'search':
default:
if(isset($params['block']))
{
return $this->PrintList($params);
}
else
{
$params['block'] = $params['block_main'];
$params['row_start_block'] = $params['block_row_start'];
$params['row_end_block'] = $params['block_row_end'];
return $this->PrintList2($params);
}
}
}
/**
* Adds product to recently viewed list (only in case, when not already there)
*
* @param Array $params
*/
function AddToRecent($params)
{
$recent_products = $this->Application->RecallVar('recent_products');
if (!$recent_products) {
$recent_products = Array();
}
else {
$recent_products = unserialize($recent_products);
}
$product_id = $this->Application->GetVar('p_id');
if (!in_array($product_id, $recent_products)) {
array_push($recent_products, $product_id);
$this->Application->StoreVar('recent_products', serialize($recent_products));
}
}
function SearchMoreLink($params)
{
$object =& $this->GetList($params);
$o = '';
if($object->GetPerPage() < $this->SearchResultsCount())
{
$o = $this->Application->ParseBlock( Array('name' => $params['block']) );
}
return $o;
}
function AddToCartLink($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
if ($object->GetDBField('HasRequiredOptions')) {
$t = $params['product_template'];
if (!$t) {
$theme = $this->Application->recallObject('theme.current');
if ($theme->GetDBField('Name') == 'onlinestore') {
$t = 'in-commerce/product/details';
}
elseif ($theme->GetDBField('Name') == 'default') {
$t = 'in-commerce/product';
}
}
$link_params = Array('m_cat_id' => $object->GetDBField('CategoryId'), 'pass' => 'm,p');
}
else {
$t = $params['template'];
$link_params = Array('m_cat_id' => $object->GetDBField('CategoryId'), 'pass' => 'm,p,ord', 'ord_event' => 'OnAddToCart');
}
$this->Application->SetVar('p_id', $this->Application->GetVar($this->getPrefixSpecial().'_id'));
return $this->Application->HREF($t, '', $link_params);
}
function SearchResultsCount($params)
{
$search_results_table = TABLE_PREFIX.'ses_'.$this->Application->GetSID().'_'.TABLE_PREFIX.'Search';
$sql = ' SELECT COUNT(ResourceId)
FROM '.$search_results_table.'
WHERE ItemType=11';
return $this->Conn->GetOne($sql);
}
function DetailsLink($params)
{
$this->Application->SetVar( $this->Prefix.'_id', $this->Application->GetVar($this->getPrefixSpecial().'_id') );
$ret = $this->Application->HREF('in-commerce/details', '', Array('pass' => 'all,p'));
return $ret;
}
function ProductLink($params)
{
return $this->ItemLink($params, 'product');
}
function ProductFileLink($params)
{
// 'p_id'=>'0', ??
$params = array_merge($params, Array('pass'=>'all,m,p,file.downl'));
$product_id = getArrayValue($params,'product_id');
if (!$product_id) {
$product_id = $this->Application->GetVar($this->Prefix.'_id');
}
$params['p_id'] = $product_id;
$product = $this->Application->recallObject($this->getPrefixSpecial());
$params['m_cat_id'] = $product->GetDBField('CategoryId');
$main_processor = $this->Application->recallObject('m_TagProcessor');
return $main_processor->T($params);
}
function GetMarkedVal($params)
{
$list =& $this->GetList($params);
return $this->Application->RecallVar($list->getPrefixSpecial().$params['name']);
}
function SortingOptions($params)
{
$list =& $this->GetList($params);
$sorting_field_selected = $this->Application->RecallVar($list->getPrefixSpecial() . $params['sorting_select_name']);
if ( !$sorting_field_selected ) {
$sorting_field_selected = $this->Application->ConfigValue('product_OrderProductsBy');
}
$sql = 'SELECT ValueList
FROM ' . TABLE_PREFIX . 'SystemSettings
WHERE VariableName = "product_OrderProductsBy"';
$field_list_plain = $this->Conn->GetOne($sql);
$field_list = explode(',', $field_list_plain);
$o = '';
$option_params = $this->prepareTagParams($params);
foreach ($field_list as $field) {
list($fieldname, $fieldlabel) = explode('=', $field);
$option_params['fieldname'] = $fieldname;
$option_params['fieldlabel'] = $this->Application->Phrase($fieldlabel);
$option_params['name'] = $params['block_options'];
$option_params['selected'] = $fieldname == $sorting_field_selected ? 'selected' : '';
$o .= $this->Application->ParseBlock($option_params);
}
return $o;
}
function SortingDirectionOptions($params)
{
$list =& $this->GetList($params);
$sorting_dir_selected = $this->Application->RecallVar($list->getPrefixSpecial() . $params['sorting_select_name']);
if ( !$sorting_dir_selected ) {
$sorting_dir_selected = $this->Application->ConfigValue('product_OrderProductsByDir');
}
$o = '';
$field_list = array ('asc' => 'lu_Ascending', 'desc' => 'lu_Descending');
$option_params = $this->prepareTagParams($params);
foreach ($field_list as $fieldname => $fieldlabel) {
$option_params['fieldname'] = $fieldname;
$option_params['fieldlabel'] = $this->Application->Phrase($fieldlabel);
$option_params['name'] = $params['block_options'];
$option_params['selected'] = $fieldname == $sorting_dir_selected ? 'selected' : '';
$o .= $this->Application->ParseBlock($option_params);
}
return $o;
}
function ErrorMessage($params)
{
if( $this->Application->GetVar('keywords_too_short') )
{
$ret = $this->Application->ParseBlock(Array('name' => $this->SelectParam($params, 'keywords_too_short_render_as,block_keywords_too_short')));
}
elseif( $this->Application->GetVar('adv_search_error') )
{
$ret = $this->Application->ParseBlock(Array('name' => $this->SelectParam($params, 'adv_search_error_render_as,block_adv_search_error')));
}
else
{
$ret = $this->Application->ParseBlock(Array('name' => $this->SelectParam($params, 'no_found_render_as,block_no_found')));
}
return $ret;
}
function ListReviews($params)
{
$review_tag_processor = $this->Application->recallObject('rev.product_TagProcessor');
return $review_tag_processor->PrintList($params);
}
function ReviewCount($params)
{
$review_tag_processor = $this->Application->recallObject('rev.product_TagProcessor');
return $review_tag_processor->TotalRecords($params);
}
function InitList($params){
$passed_manuf_id = $this->Application->GetVar('manuf_id');
if ($passed_manuf_id && !isset($params['manufacturer'])){
$params['manufacturer'] = $passed_manuf_id;
}
parent::InitList($params);
}
/**
* Builds link to manufacturer page
*
* @param Array $params
* @return string
*/
function ManufacturerLink($params)
{
if ( array_key_exists('manufacturer_id', $params) ) {
// use direct manufacturer from tag
$params['manuf_id'] = $params['manufacturer_id'];
unset($params['manufacturer_id']);
}
else {
// use product's manufacturer
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$item_manufacturer_id = $object->GetDBField('ManufacturerId');
if ($item_manufacturer_id){
$params['manuf_id'] = $item_manufacturer_id;
}
}
$params['pass'] = 'm,manuf';
$params['m_cat_id'] = 0;
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
function AlreadyReviewed($params)
{
$rev_tag_processor = $this->Application->recallObject('rev_TagProcessor');
return $rev_tag_processor->AlreadyReviewed($params);
}
function PrepareSearchResults($params)
{
$names_mapping = $this->Application->GetVar('NamesToSpecialMapping', Array ());
if($this->Application->GetVar('search_type') == 'advanced' || !getArrayValue($names_mapping, $this->Prefix, 'search_results'))
{
$params = Array('list_name' => 'search_results',
'types' => 'search',
'parent_cat_id' => 'any',
'recursive' => 'true',
'per_page' => 'short_list'
);
$this->InitList($params);
}
return '';
}
function Available($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
if ( !$object->GetDBField('InventoryStatus') ) {
return true;
}
$backordering = $this->Application->ConfigValue('Comm_Enable_Backordering');
if ( $object->GetDBField('InventoryStatus') == 2 ) {
$poc_table = $this->Application->getUnitOption('poc', 'TableName');
$sql = 'SELECT SUM(IF(QtyInStock > ' . $object->GetDBField('QtyInStockMin') . ', 1, 0))
FROM ' . $poc_table . '
WHERE (ProductId = ' . $object->GetID() . ') AND (Availability = 1)';
$stock_available = $this->Conn->GetOne($sql) > 0; // at least one option combination present
}
else {
$stock_available = $object->GetDBField('QtyInStock') > $object->GetDBField('QtyInStockMin');
}
$prod_backordering = $object->GetDBField('BackOrder');
if ( $stock_available ) {
return true;
}
// stock is NOT available:
if ( !$backordering || $prod_backordering == 0 ) {
// if backordering is generaly disabled or disabled for product (Never)
return false;
}
// backordering enabled; (auto or always mode)
return true;
}
function IsSubscription($params)
{
$object = &$this->Application->recallObject($this->getPrefixSpecial());
return ($object->GetDBField('Type') == 2);
}
function IsTangible($params)
{
$object = &$this->Application->recallObject($this->getPrefixSpecial());
return ($object->GetDBField('Type') == 1);
}
function HasFiles($params)
{
$sql = 'SELECT COUNT(FileId) FROM '.$this->Application->getUnitOption('file', 'TableName').'
WHERE ProductId = '.$this->Application->GetVar('p_id').' AND Status = 1';
return $this->Conn->GetOne($sql) ? 1 : 0;
}
function UniqueFileName($params)
{
$file_object = $this->Application->recallObject('file.downl');
return ($file_object->GetDBField('Name') &&
$file_object->GetDBField('Name') != $file_object->GetDBField('FilePath'))
? 1 : 0;
}
function FileDownload($params)
{
$file_id = $this->Application->GetVar('file.downl_id');
$product_id = $file_id ? $this->Conn->GetOne('SELECT ProductId
FROM '.$this->Application->getUnitOption('file', 'TableName').'
WHERE FileId = '.$file_id) :
$this->Application->GetVar($this->getPrefixSpecial().'_id');
$download_helper_class = $this->Application->getUnitOption($this->Prefix, 'DownloadHelperClass');
if (!$download_helper_class) {
$download_helper_class = 'DownloadHelper';
}
$download_helper = $this->Application->recallObject($download_helper_class);
if (!$download_helper->CheckAccess($file_id, $product_id)) {
$this->Application->ApplicationDie('File Access permission check failed!');
}
$file_info = $download_helper->SendFile($file_id, $product_id);
$download_helper->LogDownload($product_id, $file_info);
define('DBG_SKIP_REPORTING', 1);
$this->Application->ApplicationDie();
}
function PictureLink($params)
{
if (getArrayValue($params, 'picture_list')) {
$params['img_id'] = $this->Application->GetVar('img_id');
$params['pass'] = 'all,p,img';
unset($params['picture_list']);
}
else {
$params['pass'] = 'all,p';
}
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
function ShouldListOptions($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$req_filter = '';
if (getArrayValue($params, 'required_only')) {
$req_filter = ' AND Required = 1';
}
$query = 'SELECT COUNT(*) FROM '.TABLE_PREFIX.'ProductOptions WHERE ProductId = '.$object->GetID().$req_filter;
$res = $this->Conn->GetOne($query);
return $res > 0;
}
function CountOptions($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$query = 'SELECT COUNT(*) FROM '.TABLE_PREFIX.'ProductOptions WHERE ProductId = '.$object->GetID();
$res = $this->Conn->GetOne($query);
$max = $this->SelectParam($params, 'greater');
if (!$max) $max = 0;
return $res > $max;
}
function OptionsUpdateMode($params)
{
return $this->Application->GetVar('orditems_id') !== false;
}
function OptionsHaveError($params)
{
return $this->Application->GetVar('opt_error') > 0;
}
function OptionsError($params)
{
switch ($this->Application->GetVar('opt_error')) {
case 1:
return $this->Application->Phrase($params['required']);
case 2:
return $this->Application->Phrase($params['not_available']);
}
}
function ListShippingTypes($params)
{
$quote_engine_collector = $this->Application->recallObject('ShippingQuoteCollector');
/* @var $quote_engine_collector ShippingQuoteCollector */
$types = $quote_engine_collector->GetAvailableShippingTypes();
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$selected = $object->GetDBField('ShippingLimitation');
$selected = explode('|', substr($selected, 1, -1));
$o = '';
foreach ($types as $a_type)
{
$is_selected = in_array($a_type['_Id'], $selected);
$continue = $params['mode'] == 'selected' ? !$is_selected : $is_selected;
if ($continue) continue;
$block_params = $a_type;
$block_params['name'] = $params['render_as'];
$o .= $this->Application->ParseBlock($block_params);
}
return $o;
}
function PageLink($params)
{
$manufacturer_id = $this->Application->GetVar('manuf_id');
if ($manufacturer_id) {
$params['pass'] = 'm,'.$this->getPrefixSpecial().',manuf';
}
return parent::PageLink($params);
}
/**
* Calculate savings based on price & market price relationship
*
* @param Array $params
* @return int
*/
function Savings($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$price = $object->GetDBField('Price');
$msrp = $object->GetDBField('MSRP');
$value = 0;
if (isset($params['type']) && ($params['type'] == 'percent')) {
if ($msrp > 0) {
return 100 - round($price * 100 / $msrp);
}
}
else {
if ($msrp > $price) {
$value = $msrp - $price;
}
}
if (isset($params['currency'])) {
$lang = $this->Application->recallObject('lang.current');
/* @var $lang LanguagesItem */
$iso = $this->GetISO($params['currency']);
$value = $this->ConvertCurrency($value, $iso);
$value = $lang->formatNumber( sprintf('%.2f', $value) );
$value = $this->AddCurrencySymbol($value, $iso);
}
return $value;
}
/**
* Hides permission tab, when it's not allowed by configuration settings
*
* @param Array $params
*/
function ModifyUnitConfig($params)
{
$edit_tab_presets = $this->Application->getUnitOption($this->Prefix, 'EditTabPresets');
$edit_tab_preset = $edit_tab_presets['Default'];
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$product_type = $object->GetDBField('Type');
if ($product_type != PRODUCT_TYPE_TANGIBLE) {
unset($edit_tab_preset['inventory']);
}
if ($product_type == PRODUCT_TYPE_SUBSCRIPTION) {
unset($edit_tab_preset['options']);
}
else {
unset($edit_tab_preset['access_and_pricing']);
}
if ($product_type != PRODUCT_TYPE_TANGIBLE && $product_type != PRODUCT_TYPE_PACKAGE) {
unset($edit_tab_preset['pricing']);
}
else {
unset($edit_tab_preset['pricing2']);
}
if ($product_type != PRODUCT_TYPE_DOWNLOADABLE) {
unset($edit_tab_preset['files_and_pricing']);
}
if ($product_type != PRODUCT_TYPE_PACKAGE) {
unset($edit_tab_preset['package_content']);
}
$edit_tab_presets['Default'] = $edit_tab_preset;
$this->Application->setUnitOption($this->Prefix, 'EditTabPresets', $edit_tab_presets);
}
/**
* Checks, that current product is in compare products list
*
* @param Array $params
* @return string
* @access protected
*/
protected function InCompare($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$products = $this->Application->GetVarDirect('compare_products', 'Cookie');
$products = $products ? explode('|', $products) : Array ();
return in_array($object->GetID(), $products);
}
/**
* Checks, that one more product can be added to comparison list
*
* @param Array $params
* @return string
* @access protected
*/
protected function ComparePossible($params)
{
$products = $this->Application->GetVarDirect('compare_products', 'Cookie');
$products = $products ? explode('|', $products) : Array ();
return count($products) < $this->Application->ConfigValue('MaxCompareProducts');
}
/**
* Checks if given field is filled for at least one product in comparison page
*
* @param Array $params
* @return string
* @access protected
*/
protected function HasCompareField($params)
{
$object =& $this->GetList($params);
$object->GoFirst();
$field = $this->SelectParam($params, 'name,field');
while ( !$object->EOL() ) {
if ( $object->GetField($field) ) {
// don't use GetCol, since it fails to process ML fields
return true;
}
$object->GoNext();
}
return false;
}
/**
* Builds link to product compare page
*
* @param Array $params
* @return string
* @access protected
*/
protected function CompareLink($params)
{
$params['continue'] = urlencode($this->Application->HREF('__default__', '', Array ('pass_category' => 1)));
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
/**
* Builds link to continue website browsing from compare products page
*
* @param Array $params
* @return string
* @access protected
*/
protected function ContinueLink($params)
{
$url = $this->Application->GetVar('continue');
if ( isset($params['redirect']) && $params['redirect'] ) {
$this->Application->Redirect('external:' . $url);
}
return $url;
}
}
\ No newline at end of file
Index: branches/5.2.x/units/coupon_items/coupon_items_tag_processor.php
===================================================================
--- branches/5.2.x/units/coupon_items/coupon_items_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/coupon_items/coupon_items_tag_processor.php (revision 15156)
@@ -1,48 +1,48 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class CouponItemsTagProcessor extends kDBTagProcessor {
function IsEntireOrder($params)
{
$table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
if ($this->Application->IsTempMode($this->Prefix)) {
$table_name = $this->Application->GetTempName($table_name, 'prefix:' . $this->Prefix);
}
$sql = 'SELECT COUNT(*)
FROM ' . $table_name . '
WHERE (ItemType = 0) AND (CouponId = ' . $this->Application->GetVar('coup_id') . ')';
return $this->Conn->GetOne($sql);
}
function ItemIcon($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBList */
if ($object->GetDBField('ItemType') == 2) {
$cat_object = $this->Application->recallObject('c');
$cat_object->Load( $object->GetDBField('CategoryId') );
$cat_tag_processor = $this->Application->recallObject('c_TagProcessor');
return $cat_tag_processor->ItemIcon();
}
return parent::ItemIcon($params);
}
}
\ No newline at end of file
Index: branches/5.2.x/units/affiliates/affiliates_tag_processor.php
===================================================================
--- branches/5.2.x/units/affiliates/affiliates_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/affiliates/affiliates_tag_processor.php (revision 15156)
@@ -1,176 +1,176 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class AffiliatesTagProcessor extends kDBTagProcessor {
/**
* Returns link to be placed on other sites
*
* @param Array $params
* @return string
*/
function GetAffiliateLink($params)
{
- $object =& $this->getObject($params);
+ $object = $this->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=(.*?)&amp;(.*)/', '\\1/index.php?\\3', $link);
}
/**
* Returns link to be placed on other sites (for current user)
*
* @param Array $params
* @return string
*/
function GetUserAffiliateLink($params)
{
$params['skip_autoload'] = true;
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$object->Load(array('PortalUserId' => $this->Application->RecallVar('user_id')));
$params['index_file'] = 'index.php';
$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)
$params['__SSL__'] = 0;
$params['__NO_SID__'] = 1;
$link = $this->Application->ProcessParsedTag('m', 'Link', $params);
// remove env manually
return preg_replace('/(.*)\/index.php\?env=(.*?)&amp;(.*)/', '\\1/index.php?\\3', $link);
}
/**
* [Aggregated Tag] Returns true if user is affiliate
*
* @param Array $params
* @return bool
* @access protected
*/
protected function User_IsAffiliate($params)
{
$object = $this->Application->recallObject($this->Prefix . '.user');
/* @var $object kDBItem */
return $object->isLoaded();
}
/**
* [Aggregated Tag] Checks, that affiliate record for current user exists and is active
*
* @param $params
* @return bool
* @access protected
*/
protected function User_AffiliateIsActive($params)
{
$object = $this->Application->recallObject($this->Prefix . '.user');
/* @var $object kDBItem */
return $object->isLoaded() && ($object->GetDBField('Status') == STATUS_ACTIVE);
}
/**
* Returns url for editing user from current record
*
* @param Array $params
* @return string
*/
function UserLink($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$user_id = $object->GetDBField('PortalUserId');
if ( !$user_id ) {
return '';
}
$url_params = Array (
'm_opener' => 'd',
'u_mode' => 't',
'u_event' => 'OnEdit',
'u_id' => $user_id,
'pass' => 'all,u'
);
return $this->Application->HREF($params['edit_template'], '', $url_params);
}
function CurrentUserAffiliateField($params)
{
return $this->Application->ProcessParsedTag($this->Prefix . '.user', 'Field', $params);
}
function IsAffiliateOrRegisterAsAffiliateAllowed($params)
{
$object = $this->Application->recallObject($this->Prefix . '.user');
/* @var $object kDBItem */
return $this->Application->ConfigValue('Comm_RegisterAsAffiliate') || $object->isLoaded() ? 1 : 0;
}
/**
* [AGGREGATED TAG] Checks if affiliate registration is allowed
*
* @param Array $params
* @return int
*/
function AllowAffiliateRegistration($params)
{
return $this->Application->ConfigValue('Comm_RegisterAsAffiliate') ? 1 : 0;
}
function Main_RequireAffiliate($params)
{
$t = $params['registration_template'];
if ( !$this->User_IsAffiliate($params) ) {
$redirect_params = Array ('next_template' => $this->Application->GetVar('t'));
$this->Application->Redirect($t, $redirect_params);
}
}
/**
* Calls OnNew event from template, when no other event submitted
*
* @param Array $params
*/
function PresetFormFields($params)
{
$prefix = $this->getPrefixSpecial();
if ( !$this->Application->GetVar($prefix . '_event') && !$this->Application->GetVar('u.register_event') ) {
$this->Application->HandleEvent(new kEvent($prefix . ':OnNew'));
}
}
}
\ No newline at end of file
Index: branches/5.2.x/units/order_items/order_items_tag_processor.php
===================================================================
--- branches/5.2.x/units/order_items/order_items_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/order_items/order_items_tag_processor.php (revision 15156)
@@ -1,300 +1,300 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class OrderItemsTagProcessor extends kDBTagProcessor
{
function PrintGrid($params)
{
$order = $this->Application->recallObject('ord');
/* @var $order kDBList */
if ( $order->GetDBField('Status') != ORDER_STATUS_INCOMPLETE ) {
$params['grid'] = $params['NotEditable'];
}
else {
$params['grid'] = $params['Editable'];
}
return $this->Application->ProcessParsedTag('m', 'ParseBlock', $params);
}
function IsTangible($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
return $object->GetDBField('Type') == PRODUCT_TYPE_TANGIBLE;
}
function HasQty($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
return in_array($object->GetDBField('Type'), Array (PRODUCT_TYPE_TANGIBLE, 6));
}
function HasDiscount($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
return (float)$object->GetDBField('ItemDiscount') ? 1 : 0;
}
function HasOptions($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$item_data = @unserialize($object->GetDBField('ItemData'));
return isset($item_data['Options']);
}
function PrintOptions($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$item_data = @unserialize($object->GetDBField('ItemData'));
$render_as = $this->SelectParam($params, 'render_as');
$block_params['name'] = $render_as;
$opt_helper = $this->Application->recallObject('kProductOptionsHelper');
/* @var $opt_helper kProductOptionsHelper */
$o = '';
$options = $item_data['Options'];
foreach ($options as $opt => $val) {
if ( !is_array($val) ) {
$val = kUtil::unhtmlentities($val);
}
$key_data = $opt_helper->ConvertKey($opt, $object->GetDBField('ProductId'));
$parsed = $opt_helper->ExplodeOptionValues($key_data);
if ( $parsed ) {
$values = $parsed['Values'];
$prices = $parsed['Prices'];
$price_types = $parsed['PriceTypes'];
}
else {
$values = array ();
$prices = array ();
$price_types = array ();
}
$key = $key_data['Name'];
/*if (is_array($val)) {
$val = join(',', $val);
}*/
$lang = $this->Application->recallObject('lang.current');
/* @var $lang LanguagesItem */
if ( $render_as ) {
$block_params['option'] = $key;
if ( is_array($val) ) {
$block_params['value'] = $val;
$block_params['type'] = $key_data['OptionType'];
$block_params['price'] = $prices;
$block_params['price_type'] = $price_types;
}
else {
$price_type = array_key_exists($val, $price_types) ? $price_types[$val] : '';
$price = array_key_exists($val, $prices) ? $prices[$val] : '';
if ( $price_type == '$' ) {
$iso = $this->GetISO($params['currency']);
$value = $this->AddCurrencySymbol($lang->formatNumber($this->ConvertCurrency($price, $iso), 2), $iso, true); // true to force sign
$block_params['price'] = $value;
$block_params['price_type'] = '';
$block_params['sign'] = ''; // sign is included in the formatted value
}
else {
$block_params['price'] = $price;
$block_params['price_type'] = $price_type;
$block_params['sign'] = $price >= 0 ? '+' : '-';
}
$block_params['value'] = htmlspecialchars($val);
$block_params['type'] = $key_data['OptionType'];
}
$o .= $this->Application->ParseBlock($block_params, 1);
}
else {
$o .= $key . ': ' . $val . '<br>';
}
}
return $o;
}
function ProductsInStock($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
if (!$object->GetDBField('InventoryStatus')) {
// unlimited count available
return false;
}
if ($object->GetDBField('InventoryStatus') == 2) {
$poc_table = $this->Application->getUnitOption('poc', 'TableName');
$sql = 'SELECT QtyInStock
FROM '.$poc_table.'
WHERE (ProductId = '.$object->GetDBField('ProductId').') AND (Availability = 1) AND (CombinationCRC = '.$object->GetDBField('OptionsSalt').')';
$ret = $this->Conn->GetOne($sql);
}
else {
$ret = $object->GetDBField('QtyInStock');
}
return $ret;
}
function PrintOptionValues($params)
{
$block_params['name'] = $params['render_as'];
$values = $this->Application->Parser->GetParam('value');
/* @var $values Array */
$prices = $this->Application->Parser->GetParam('price');
$price_types = $this->Application->Parser->GetParam('price_type');
$o = '';
$i = 0;
foreach ($values as $val) {
$i++;
$val = kUtil::unhtmlentities($val);
$block_params['value'] = htmlspecialchars($val);
if ($price_types[$val] == '$') {
$iso = $this->GetISO($params['currency']);
$value = $this->AddCurrencySymbol(sprintf("%.2f", $this->ConvertCurrency($prices[$val], $iso)), $iso, true); // true to force sign
$block_params['price'] = $value;
$block_params['price_type'] = '';
$block_params['sign'] = ''; // sign is included in the formatted value
}
else {
$block_params['price'] = $prices[$val];
$block_params['price_type'] = $price_types[$val];
$block_params['sign'] = $prices[$val] >= 0 ? '+' : '-';
}
$block_params['is_last'] = $i == count($values);
$o.= $this->Application->ParseBlock($block_params, 1);
}
return $o;
}
/*function ConvertKey($key, &$object)
{
static $mapping = null;
if (is_null($mapping) || !isset($mapping[$object->GetDBField('ProductId')])) {
$table = TABLE_PREFIX.'ProductOptions';
$sql = 'SELECT * FROM '.$table.' WHERE ProductId = '.$object->GetDBField('ProductId');
$mapping[$object->GetDBField('ProductId')] = $this->Conn->Query($sql, 'ProductOptionId');
}
return $mapping[$object->GetDBField('ProductId')][$key];
}*/
function PrintList($params)
{
$list =& $this->GetList($params);
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
$list->Query();
$o = '';
$list->GoFirst();
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['pass_params'] = 'true';
$product_object = $this->Application->recallObject('p', 'p', Array ('skip_autoload' => true));
/* @var $product_object kCatDBItem */
$i = 0;
$product_id = $product_object->GetID();
$product_id_get = $this->Application->GetVar('p_id');
while (!$list->EOL()) {
// load product used in orderitem
$this->Application->SetVar($this->getPrefixSpecial() . '_id', $list->GetDBField($id_field)); // for edit/delete links using GET
$this->Application->SetVar('p_id', $list->GetDBField('ProductId'));
$product_object->Load($list->GetDBField('ProductId')); // correct product load
$this->Application->SetVar('m_cat_id', $product_object->GetDBField('CategoryId'));
$block_params['is_last'] = ($i == $list->GetSelectedCount() - 1);
$o .= $this->Application->ParseBlock($block_params, 1);
$list->GoNext();
$i++;
}
// restore IDs used in cycle
$this->Application->SetVar('p_id', $product_id_get);
$this->Application->DeleteVar($this->getPrefixSpecial() . '_id');
if ( $product_id ) {
$product_object->Load($product_id);
}
return $o;
}
function DisplayOptionsPricing($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
if ( $object->GetDBField('OptionsSelectionMode') == 1 ) {
return false;
}
$item_data = unserialize($object->GetDBField('ItemData'));
if ( !is_array($item_data) ) {
return false;
}
$options = getArrayValue($item_data, 'Options');
$helper = $this->Application->recallObject('kProductOptionsHelper');
/* @var $helper kProductOptionsHelper */
$crc = $helper->OptionsSalt($options, true);
$sql = 'SELECT COUNT(*)
FROM ' . TABLE_PREFIX . 'ProductOptionCombinations
WHERE CombinationCRC = ' . $crc . ' AND ProductId = ' . $object->GetDBField('ProductId') . ' AND (Price != 0 OR (PriceType = 1 AND Price = 0))';
return $this->Conn->GetOne($sql) == 0; // no overriding combinations found
}
function RowIndex($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
return $object->GetDBField('ProductId') . ':' . $object->GetDBField('OptionsSalt') . ':' . $object->GetDBField('BackOrderFlag');
}
function FreePromoShippingAvailable($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$order_helper = $this->Application->recallObject('OrderHelper');
/* @var $order_helper OrderHelper */
return $order_helper->eligibleForFreePromoShipping($object);
}
}
\ No newline at end of file
Index: branches/5.2.x/units/addresses/addresses_tag_processor.php
===================================================================
--- branches/5.2.x/units/addresses/addresses_tag_processor.php (revision 15155)
+++ branches/5.2.x/units/addresses/addresses_tag_processor.php (revision 15156)
@@ -1,98 +1,98 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class AddressesTagProcessor extends kDBTagProcessor {
function ListAddresses($params)
{
$ret = $this->PrintList2($params);
if ( !$ret ) {
$block_params = array ('name' => $params['empty_myaddresses_render_as']);
$ret = $this->Application->ParseBlock($block_params);
}
return $ret;
}
/**
* Print location using only filled in fields
*
* @param Array $params
* @return string
* @access protected
*/
protected function PrintLocation($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
$ret = '';
$fields = Array ('City', 'State', 'Zip', 'Country');
foreach ($fields as $field) {
$value = $object->GetField($field);
if ( $field == 'Country' && $value ) {
$ret .= '<br/>';
}
if ( $value ) {
$ret .= $value . ', ';
}
}
return rtrim($ret, ', ');
}
function EditLink($params)
{
$tag_processor = $this->Application->recallTagProcessor('m');
$params['pass'] = 'm,addr';
return $tag_processor->Link($params);
}
function DeleteLink($params)
{
$params['addr_event'] = 'OnDelete';
return $this->EditLink($params);
}
function NewLink($params)
{
$params['addr_event'] = 'OnNew';
return $this->EditLink($params);
}
function IsProfileAddress($params)
{
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
/* @var $object kDBItem */
return $object->GetDBField('IsProfileAddress');
}
function BuildListSpecial($params)
{
if ( $this->Special != '' ) {
return $this->Special;
}
$list_unique_key = $this->getUniqueListKey($params);
if ( $list_unique_key == '' ) {
return parent::BuildListSpecial($params);
}
return crc32($list_unique_key);
}
}
\ No newline at end of file
Index: branches/5.2.x/units/gift_certificates/gift_certificates_tp.php
===================================================================
--- branches/5.2.x/units/gift_certificates/gift_certificates_tp.php (revision 15155)
+++ branches/5.2.x/units/gift_certificates/gift_certificates_tp.php (revision 15156)
@@ -1,47 +1,47 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class GiftCertificateTagProcessor extends kDBTagProcessor {
function HasOrder($params)
{
if ($this->IsNewItem($params)) {
return 0;
}
- $object =& $this->getObject($params);
+ $object = $this->getObject($params);
$sql = 'SELECT COUNT(OrderId)
FROM '.TABLE_PREFIX.'Orders
WHERE GiftCertificateId = '.$object->GetID();
return $this->Conn->GetOne($sql);
}
/**
* Print link for gift certificate (admin only)
*
* @param Array $params
*/
function PrintLink($params)
{
$params[$this->getPrefixSpecial().'_id'] = $this->Application->RecallVar('print_certificate_id');
$this->Application->RemoveVar('print_certificate_id');
$main_processor = $this->Application->recallTagProcessor('m');
/* @var $main_processor kMainTagProcessor */
return $main_processor->Link($params);
}
}
\ No newline at end of file

Event Timeline