Index: branches/5.2.x/units/downloads/download_helper.php =================================================================== diff -u -N -r14655 -r14723 --- branches/5.2.x/units/downloads/download_helper.php (.../download_helper.php) (revision 14655) +++ branches/5.2.x/units/downloads/download_helper.php (.../download_helper.php) (revision 14723) @@ -1,6 +1,6 @@ Application->recallObject( 'p' ); $down_object->SetDBField('PortalUserId', $this->Application->RecallVar('user_id')); - $down_object->SetDBField('Username', $user_object->GetDBField('Login')); + $down_object->SetDBField('Username', $user_object->GetDBField('Username')); $down_object->SetDBField('ProductId', $product_id); $down_object->SetDBField('ProductName', $product_object->GetField('Name')); $down_object->SetDBField('FileId', $file_info['FileId']); Index: branches/5.2.x/units/products/products_config.php =================================================================== diff -u -N -r14717 -r14723 --- branches/5.2.x/units/products/products_config.php (.../products_config.php) (revision 14717) +++ branches/5.2.x/units/products/products_config.php (.../products_config.php) (revision 14723) @@ -1,6 +1,6 @@ 'SELECT %s FROM ' . TABLE_PREFIX . 'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', - 'left_title_field' => 'Login', + 'left_title_field' => 'Username', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'sample_value' => 'Guest', 'required' => 1, 'default' => NULL, ), Index: branches/5.2.x/units/affiliate_payments/affiliate_payments_config.php =================================================================== diff -u -N -r14717 -r14723 --- branches/5.2.x/units/affiliate_payments/affiliate_payments_config.php (.../affiliate_payments_config.php) (revision 14717) +++ branches/5.2.x/units/affiliate_payments/affiliate_payments_config.php (.../affiliate_payments_config.php) (revision 14723) @@ -1,6 +1,6 @@ 'af.PortalUserId', ), 'log' => Array( - 'Username' => 'au.Login', + 'Username' => 'au.Username', 'PortalUserId' => 'af.PortalUserId', ), ), @@ -106,7 +106,7 @@ 'Fields' => Array( 'AffiliatePaymentId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0), - 'AffiliateId' => Array('type'=>'int','formatter'=>'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array(0 => 'lu_None'), 'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'Affiliates af LEFT JOIN '.TABLE_PREFIX.'PortalUser pu ON pu.PortalUserId = af.PortalUserId WHERE `%s` = \'%s\'','left_key_field'=>'AffiliateId','left_title_field'=>'Login','not_null'=>1,'default'=>0), + 'AffiliateId' => Array('type'=>'int','formatter'=>'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array(0 => 'lu_None'), 'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'Affiliates af LEFT JOIN '.TABLE_PREFIX.'PortalUser pu ON pu.PortalUserId = af.PortalUserId WHERE `%s` = \'%s\'','left_key_field'=>'AffiliateId','left_title_field'=>'Username','not_null'=>1,'default'=>0), 'PaymentDate' => Array('type' => 'int', 'formatter'=>'kDateFormatter', 'default' => '#NOW#'), 'Amount' => Array('type' => 'double', 'formatter'=>'kFormatter', 'format'=>'%.02f', 'not_null' => '1', 'required'=>1, 'default' => '0.00'), 'Comment' => Array('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => NULL), Index: branches/5.2.x/units/orders/orders_config.php =================================================================== diff -u -N -r14717 -r14723 --- branches/5.2.x/units/orders/orders_config.php (.../orders_config.php) (revision 14717) +++ branches/5.2.x/units/orders/orders_config.php (.../orders_config.php) (revision 14723) @@ -1,6 +1,6 @@ Array ( '' => Array ( - 'CustomerName' => 'IF( ISNULL(u.Login), IF (%1$s.PortalUserId = ' . USER_ROOT . ', \'root\', IF (%1$s.PortalUserId = ' . USER_GUEST . ', \'Guest\', \'n/a\')), CONCAT(u.FirstName,\' \',u.LastName) )', - 'Username' => 'IF( ISNULL(u.Login),\'root\',u.Login)', + 'CustomerName' => 'IF( ISNULL(u.Username), IF (%1$s.PortalUserId = ' . USER_ROOT . ', \'root\', IF (%1$s.PortalUserId = ' . USER_GUEST . ', \'Guest\', \'n/a\')), CONCAT(u.FirstName,\' \',u.LastName) )', + 'Username' => 'IF( ISNULL(u.Username),\'root\',u.Username)', 'OrderNumber' => 'CONCAT(LPAD(Number,6,"0"),\'-\',LPAD(SubNumber,3,"0") )', 'SubtotalWithoutDiscount' => '(SubTotal + DiscountTotal)', 'SubtotalWithDiscount' => '(SubTotal)', 'AmountWithoutVAT' => '(SubTotal+IF(ShippingTaxable=1, ShippingCost, 0)+IF(ProcessingTaxable=1, ProcessingFee, 0))', 'TotalAmount' => 'SubTotal+ShippingCost+VAT+ProcessingFee+InsuranceFee-GiftCertificateDiscount', 'CouponCode' => 'pc.Code', 'CouponName' => 'pc.Name', - 'AffiliateUser' => 'IF( LENGTH(au.Login),au.Login,\'!la_None!\')', + 'AffiliateUser' => 'IF( LENGTH(au.Username),au.Username,\'!la_None!\')', 'AffiliatePortalUserId' => 'af.PortalUserId', 'GiftCertificateCode' => 'gc.Code', 'GiftCertificateRecipient' => 'gc.Recipient', @@ -308,7 +308,7 @@ 'not_null' => 1, 'default' => 0, ), 'OrderDate' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'required' => 1, 'default' => '#NOW#'), - 'PortalUserId' =>Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' =>Array (USER_ROOT => 'root', USER_GUEST => 'Guest'), 'left_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'required' =>1, 'not_null' =>1, 'default' =>-1), + 'PortalUserId' =>Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' =>Array (USER_ROOT => 'root', USER_GUEST => 'Guest'), 'left_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Username', 'required' =>1, 'not_null' =>1, 'default' =>-1), 'OrderIP' => Array ('type' => 'string', 'not_null' => 1, 'default' => '', 'filter_type' => 'like'), 'UserComment' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => NULL), 'AdminComment' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => NULL), @@ -437,7 +437,7 @@ ), 'GWResult1' => Array ('type' => 'string', 'formatter' => 'kSerializedFormatter', 'default' => NULL), 'GWResult2' => Array ('type' => 'string', 'formatter' => 'kSerializedFormatter', 'default' => NULL), - 'AffiliateId' => Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array (0 => 'lu_None'), 'left_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Affiliates af LEFT JOIN '.TABLE_PREFIX.'PortalUser pu ON pu.PortalUserId = af.PortalUserId WHERE `%s` = \'%s\'', 'left_key_field' => 'AffiliateId', 'left_title_field' => 'Login', 'not_null' =>1, 'default' =>0), + 'AffiliateId' => Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array (0 => 'lu_None'), 'left_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Affiliates af LEFT JOIN '.TABLE_PREFIX.'PortalUser pu ON pu.PortalUserId = af.PortalUserId WHERE `%s` = \'%s\'', 'left_key_field' => 'AffiliateId', 'left_title_field' => 'Username', 'not_null' =>1, 'default' =>0), 'VisitId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), 'AffiliateCommission' => Array ('type' => 'double', 'formatter' => 'kFormatter', 'format' => '%.02f', 'not_null' => 1, 'default' => '0.0000'), 'ProcessingFee' => Array ('type' => 'double', 'formatter' => 'kFormatter', 'format' => '%.02f', 'not_null' => '0', 'default' => '0.0000'), Index: branches/5.2.x/units/affiliates/affiliates_config.php =================================================================== diff -u -N -r14594 -r14723 --- branches/5.2.x/units/affiliates/affiliates_config.php (.../affiliates_config.php) (revision 14594) +++ branches/5.2.x/units/affiliates/affiliates_config.php (.../affiliates_config.php) (revision 14723) @@ -1,6 +1,6 @@ Array( '' => Array ( 'UserId' => 'u.PortalUserId', - 'UserName' => 'IF( LENGTH(u.Login), u.Login, \'\')', + 'UserName' => 'IF( LENGTH(u.Username), u.Username, \'\')', 'PlanName' => 'ap.Name', ), ), @@ -179,7 +179,7 @@ 'Fields' => Array( 'AffiliateId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0), - 'PortalUserId' => Array('type' => 'int', 'unique'=>Array('PortalUserId'), 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!', 'unique' => '!la_affiliate_already_exists!'), 'options' => Array(USER_ROOT => 'root', USER_GUEST => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'required' => 1, 'not_null' => 1, 'default' => 0, ), + 'PortalUserId' => Array('type' => 'int', 'unique'=>Array('PortalUserId'), 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!', 'unique' => '!la_affiliate_already_exists!'), 'options' => Array(USER_ROOT => 'root', USER_GUEST => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Username', 'required' => 1, 'not_null' => 1, 'default' => 0, ), 'AffiliatePlanId' => Array('type' => 'int', 'formatter'=>'kOptionsFormatter', 'options_sql'=>'SELECT Name, AffiliatePlanId FROM '.TABLE_PREFIX.'AffiliatePlans WHERE Enabled = 1 ORDER BY Name', 'option_key_field'=>'AffiliatePlanId', 'option_title_field'=>'Name', 'not_null' => 1, 'default' => 0), 'AccumulatedAmount' => Array('type' => 'double', 'formatter'=>'kFormatter', 'format'=>'%.02f', 'not_null' => '1','default' => '0.00'), 'AmountToPay' => Array('type' => 'double', 'formatter'=>'kFormatter', 'format'=>'%.02f', 'not_null' => '1','default' => '0.00'), Index: branches/5.2.x/units/reports/reports_event_handler.php =================================================================== diff -u -N -r14717 -r14723 --- branches/5.2.x/units/reports/reports_event_handler.php (.../reports_event_handler.php) (revision 14717) +++ branches/5.2.x/units/reports/reports_event_handler.php (.../reports_event_handler.php) (revision 14723) @@ -1,6 +1,6 @@ 'u.Login', + 'Login' => 'u.Username', 'FirstName' => 'u.FirstName', 'LastName' => 'u.LastName', ); Index: branches/5.2.x/units/coupons/coupons_config.php =================================================================== diff -u -N -r14717 -r14723 --- branches/5.2.x/units/coupons/coupons_config.php (.../coupons_config.php) (revision 14717) +++ branches/5.2.x/units/coupons/coupons_config.php (.../coupons_config.php) (revision 14723) @@ -1,6 +1,6 @@ Array (USER_ROOT => 'root', USER_GUEST => 'Guest'), 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'PortalUser WHERE `%s` = \'%s\'','left_key_field'=>'PortalUserId', - 'left_title_field' => 'Login', 'required' => 0, 'default' => null, + 'left_title_field' => 'Username', 'required' => 0, 'default' => null, ), 'LastUsedOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => NULL), 'NumberOfUses' => Array ('type' => 'int', 'default' => 1), Index: branches/5.2.x/units/orders/orders_tag_processor.php =================================================================== diff -u -N -r14702 -r14723 --- branches/5.2.x/units/orders/orders_tag_processor.php (.../orders_tag_processor.php) (revision 14702) +++ branches/5.2.x/units/orders/orders_tag_processor.php (.../orders_tag_processor.php) (revision 14723) @@ -1,6 +1,6 @@ Application->recallObject('u', null, Array ('skip_autoload' => true)); - /* @var $user kDBItem */ + 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_prefix = $params['type'] == 'billing' ? 'Billing' : 'Shipping'; + $names = explode(' ', $order->GetDBField($order_prefix . 'To'), 2); + + if ( !$user->GetDBField('FirstName') ) { + $user->SetDBField('FirstName', getArrayValue($names, 0)); + } + + if ( !$user->GetDBField('LastName') ) { + $user->SetDBField('LastName', getArrayValue($names, 1)); + } + $order_fields = Array ( - 'To', 'Company', 'Phone', 'Fax', 'Email', 'Address1', - 'Address2', 'City', 'State', 'Zip', 'Country' + 'Company', 'Phone', 'Fax', 'Email', 'Address1' => 'Street', + 'Address2' => 'Street2', 'City', 'State', 'Zip', 'Country' ); - $names = explode(' ', $order->GetDBField($order_prefix.'To'), 2); - if (!$user->GetDBField('FirstName')) $user->SetDBField('FirstName', getArrayValue($names, 0) ); - if (!$user->GetDBField('LastName')) $user->SetDBField('LastName', getArrayValue($names, 1) ); - if (!$user->GetDBField('Company')) $user->SetDBField('Company', $order->GetDBField($order_prefix.'Company') ); - if (!$user->GetDBField('Phone')) $user->SetDBField('Phone', $order->GetDBField($order_prefix.'Phone') ); - if (!$user->GetDBField('Fax')) $user->SetDBField('Fax', $order->GetDBField($order_prefix.'Fax') ); - if (!$user->GetDBField('Email')) $user->SetDBField('Email', $order->GetDBField($order_prefix.'Email') ); - if (!$user->GetDBField('Street')) $user->SetDBField('Street', $order->GetDBField($order_prefix.'Address1') ); - if (!$user->GetDBField('Street2')) $user->SetDBField('Street2', $order->GetDBField($order_prefix.'Address2') ); - if (!$user->GetDBField('City')) $user->SetDBField('City', $order->GetDBField($order_prefix.'City') ); - if (!$user->GetDBField('State')) $user->SetDBField('State', $order->GetDBField($order_prefix.'State') ); - if (!$user->GetDBField('Zip')) $user->SetDBField('Zip', $order->GetDBField($order_prefix.'Zip') ); - if (!$user->GetDBField('Country')) $user->SetDBField('Country', $order->GetDBField($order_prefix.'Country') ); + foreach ($order_fields as $src_field => $dst_field) { + if ( is_numeric($src_field) ) { + $src_field = $dst_field; + } + if ( !$user->GetDBField($dst_field) ) { + $user->SetDBField($dst_field, $order->GetDBField($order_prefix . $src_field)); + } + } + $cs_helper =& $this->Application->recallObject('CountryStatesHelper'); /* @var $cs_helper kCountryStatesHelper */