Index: branches/5.2.x/install/install_schema.sql =================================================================== diff -u -N -r15376 -r15560 --- branches/5.2.x/install/install_schema.sql (.../install_schema.sql) (revision 15376) +++ branches/5.2.x/install/install_schema.sql (.../install_schema.sql) (revision 15560) @@ -663,7 +663,7 @@ CREATE TABLE Affiliates ( AffiliateId int(11) NOT NULL AUTO_INCREMENT, - PortalUserId int(10) unsigned NOT NULL DEFAULT '0', + PortalUserId int(10) DEFAULT NULL, AffiliatePlanId int(10) unsigned NOT NULL DEFAULT '0', AccumulatedAmount decimal(10,2) NOT NULL DEFAULT '0.00', AmountToPay decimal(10,2) NOT NULL DEFAULT '0.00', @@ -677,8 +677,8 @@ Comments text, CreatedOn int(11) DEFAULT NULL, PRIMARY KEY (AffiliateId), - UNIQUE KEY PortalUserId (PortalUserId), UNIQUE KEY AffiliateCode (AffiliateCode), + UNIQUE KEY PortalUserId (PortalUserId), KEY LastOrderDate (LastOrderDate), KEY AffiliatePlanId (AffiliatePlanId), KEY `Status` (`Status`), Index: branches/5.2.x/install/upgrades.sql =================================================================== diff -u -N -r15468 -r15560 --- branches/5.2.x/install/upgrades.sql (.../upgrades.sql) (revision 15468) +++ branches/5.2.x/install/upgrades.sql (.../upgrades.sql) (revision 15560) @@ -282,3 +282,7 @@ INSERT INTO Permissions VALUES(DEFAULT, 'in-commerce:general.add', 11, 1, 1, 0); INSERT INTO Permissions VALUES(DEFAULT, 'in-commerce:output.add', 11, 1, 1, 0); INSERT INTO Permissions VALUES(DEFAULT, 'in-commerce:contacts.add', 11, 1, 1, 0); + +# ===== v 5.2.1-B1 ===== +ALTER TABLE Affiliates CHANGE PortalUserId PortalUserId INT(10) NULL DEFAULT NULL; +UPDATE Affiliates SET PortalUserId = NULL WHERE PortalUserId = 0; Index: branches/5.2.x/units/products/products_config.php =================================================================== diff -u -N -r15468 -r15560 --- branches/5.2.x/units/products/products_config.php (.../products_config.php) (revision 15468) +++ branches/5.2.x/units/products/products_config.php (.../products_config.php) (revision 15560) @@ -1,6 +1,6 @@ 'int', 'formatter' => 'kLEFTFormatter', 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'), - 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users - WHERE `%s` = \'%s\'', - 'left_key_field' => 'PortalUserId', - 'left_title_field' => 'Username', + 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE %s', + 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD, 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'sample_value' => 'Guest', 'required' => 1, 'default' => NULL, ), @@ -548,13 +546,13 @@ 'ProcessingData' => Array ('type' => 'string', 'default' => null), 'ShippingLimitation' => Array ('type' => 'string', 'default' => NULL), - 'AssignedCoupon' => - Array ('type' => 'int', 'not_null' => 1, 'default' => 0, - 'formatter' => 'kLEFTFormatter', - 'options' => Array (0 => 'None'), - 'left_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'ProductsCoupons WHERE `%s` = \'%s\'', - 'left_key_field' => 'CouponId', - 'left_title_field' => 'Name'), + 'AssignedCoupon' => Array ( + 'type' => 'int', + 'formatter' => 'kLEFTFormatter', 'options' => Array (0 => 'None'), + 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'ProductsCoupons WHERE %s', + 'left_key_field' => 'CouponId', 'left_title_field' => 'Name', + 'not_null' => 1, 'default' => 0, + ), 'MinQtyFreePromoShipping' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), 'MetaKeywords' => Array ('type' => 'string', 'default' => null), 'MetaDescription' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => null), Index: branches/5.2.x/units/affiliate_payments/affiliate_payments_config.php =================================================================== diff -u -N -r15009 -r15560 --- branches/5.2.x/units/affiliate_payments/affiliate_payments_config.php (.../affiliate_payments_config.php) (revision 15009) +++ branches/5.2.x/units/affiliate_payments/affiliate_payments_config.php (.../affiliate_payments_config.php) (revision 15560) @@ -1,6 +1,6 @@ 'af.PortalUserId', ), 'log' => Array( - 'Username' => 'au.Username', + 'Username' => 'IF(au.Username = "", au.Email, 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.'Users pu ON pu.PortalUserId = af.PortalUserId WHERE `%s` = \'%s\'','left_key_field'=>'AffiliateId','left_title_field'=>'Username','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.'Users u ON u.PortalUserId = af.PortalUserId WHERE %s','left_key_field'=>'af.AffiliateId','left_title_field'=>'IF(u.Email = "", u.Username, u.Email)','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 -r15376 -r15560 --- branches/5.2.x/units/orders/orders_config.php (.../orders_config.php) (revision 15376) +++ branches/5.2.x/units/orders/orders_config.php (.../orders_config.php) (revision 15560) @@ -1,6 +1,6 @@ Array ( '' => Array ( - '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)', + '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",IF(u.Username = "", u.Email, 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)-IF(VATIncluded=1,VAT,0))', 'TotalAmount' => 'SubTotal+ShippingCost+IF(VATIncluded=1,0,VAT)+ProcessingFee+InsuranceFee-GiftCertificateDiscount', 'CouponCode' => 'pc.Code', 'CouponName' => 'pc.Name', - 'AffiliateUser' => 'IF( LENGTH(au.Username),au.Username,\'!la_None!\')', + 'AffiliateUser' => 'IF(au.PortalUserId IS NULL, "!la_None!", IF(au.Username = "", au.Email, au.Username))', 'AffiliatePortalUserId' => 'af.PortalUserId', 'GiftCertificateCode' => 'gc.Code', 'GiftCertificateRecipient' => 'gc.Recipient', @@ -320,7 +320,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.'Users WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Username', '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.'Users WHERE %s', 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD, '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), @@ -456,7 +456,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.'Users pu ON pu.PortalUserId = af.PortalUserId WHERE `%s` = \'%s\'', 'left_key_field' => 'AffiliateId', 'left_title_field' => 'Username', '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.'Users u ON u.PortalUserId = af.PortalUserId WHERE %s', 'left_key_field' => 'AffiliateId', 'left_title_field' => 'IF(u.Email = "", u.Username, u.Email)', '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 -r15030 -r15560 --- branches/5.2.x/units/affiliates/affiliates_config.php (.../affiliates_config.php) (revision 15030) +++ branches/5.2.x/units/affiliates/affiliates_config.php (.../affiliates_config.php) (revision 15560) @@ -1,6 +1,6 @@ Array( '' => Array ( 'UserId' => 'u.PortalUserId', - 'UserName' => 'IF( LENGTH(u.Username), u.Username, \'\')', + 'UserName' => 'IF(u.Username = "", u.Email, u.Username)', 'PlanName' => 'ap.Name', ), ), @@ -196,7 +196,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.'Users WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Username', 'required' => 1, 'not_null' => 1, 'default' => 0, ), + 'PortalUserId' => Array('type' => 'int', 'unique'=>Array(), '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.'Users WHERE %s', 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD, 'required' => 1, 'default' => null), '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/coupons/coupons_config.php =================================================================== diff -u -N -r15009 -r15560 --- branches/5.2.x/units/coupons/coupons_config.php (.../coupons_config.php) (revision 15009) +++ branches/5.2.x/units/coupons/coupons_config.php (.../coupons_config.php) (revision 15560) @@ -1,6 +1,6 @@ Array ('type' => 'double', 'default' => null), 'LastUsedBy' => Array ( - 'type' => 'int', 'formatter' => 'kLEFTFormatter', + '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 . 'Users - WHERE `%s` = \'%s\'','left_key_field'=>'PortalUserId', - 'left_title_field' => 'Username', 'required' => 0, 'default' => null, + 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE %s', + 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD, + 'required' => 0, 'default' => null, ), 'LastUsedOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => NULL), 'NumberOfUses' => Array ('type' => 'int', 'default' => 1), Index: branches/5.2.x/install/upgrades.php =================================================================== diff -u -N -r15547 -r15560 --- branches/5.2.x/install/upgrades.php (.../upgrades.php) (revision 15547) +++ branches/5.2.x/install/upgrades.php (.../upgrades.php) (revision 15560) @@ -1,6 +1,6 @@ Array ('Core' => '5.2.0-B3'), '5.2.0-RC1' => Array ('Core' => '5.2.0-RC1'), '5.2.0' => Array ('Core' => '5.2.0'), + '5.2.1-B1' => Array ('Core' => '5.2.1-B1'), ); }