Index: branches/5.1.x/units/orders/orders_config.php =================================================================== diff -u -N -r13549 -r13578 --- branches/5.1.x/units/orders/orders_config.php (.../orders_config.php) (revision 13549) +++ branches/5.1.x/units/orders/orders_config.php (.../orders_config.php) (revision 13578) @@ -1,6 +1,6 @@ Array ( '' => Array ( - 'CustomerName' => 'IF( ISNULL(u.Login), IF (%1$s.PortalUserId = -1, \'root\', IF (%1$s.PortalUserId = -2, \'Guest\', \'n/a\')), CONCAT(u.FirstName,\' \',u.LastName) )', + '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)', 'OrderNumber' => 'CONCAT(LPAD(Number,6,"0"),\'-\',LPAD(SubNumber,3,"0") )', 'SubtotalWithoutDiscount' => '(SubTotal + DiscountTotal)', @@ -314,7 +314,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 (-1=> 'root',-2=> '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' => 'Login', '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), @@ -355,14 +355,14 @@ 'PaymentType' => Array ( 'type' => 'int', 'formatter' => 'kOptionsFormatter', - 'options_sql' => 'SELECT %s - FROM ' . TABLE_PREFIX . 'PaymentTypes - WHERE Status = 1 + 'options_sql' => 'SELECT %s + FROM ' . TABLE_PREFIX . 'PaymentTypes + WHERE Status = 1 ORDER BY Priority DESC, Name ASC', 'option_key_field' => 'PaymentTypeId', 'option_title_field' => 'Description', 'not_null' => 1, 'default' => 0 ), - + 'PaymentAccount' => Array ('type' => 'string', 'not_null' => 1, 'cardtype_field' => 'PaymentCardType', 'default' => '', 'filter_type' => 'like'), 'PaymentNameOnCard' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''), 'PaymentCCExpDate' => Array ('type' => 'string', 'formatter' => 'kCCDateFormatter', 'month_field' => 'PaymentCCExpMonth', 'year_field' => 'PaymentCCExpYear', 'not_null' => 1, 'default' => ''), @@ -377,7 +377,7 @@ 'formatter' => 'kOptionsFormatter', 'options' => Array (), 'option_key_field' => 'DestAbbr', - 'option_title_field' => 'Translation', + 'option_title_field' => 'Translation', ), 'ShippingAddress1' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''), 'ShippingAddress2' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''), @@ -400,8 +400,8 @@ 'ShippingType' => Array ( 'type' => 'int', 'formatter' => 'kOptionsFormatter', - 'options_sql' => 'SELECT %s - FROM ' . TABLE_PREFIX . 'ShippingType + 'options_sql' => 'SELECT %s + FROM ' . TABLE_PREFIX . 'ShippingType WHERE Status = 1', 'option_key_field' => 'ShippingID', 'option_title_field' => 'Name', @@ -491,17 +491,17 @@ 'LineEndings' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'Windows', 2 => 'UNIX'), 'default' => 1), 'LineEndingsInside' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'CRLF', 2 => 'LF'), 'default' => 2), 'IncludeFieldTitles' => Array ( - 'type' => 'int', - 'formatter' => 'kOptionsFormatter', + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'la_No', 1 => 'la_Yes'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 1, ), 'ExportColumns' => Array ('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array ()), 'AvailableColumns' => Array ('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array ()), 'ExportPresets' => Array ('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array ()), 'ExportSavePreset' => Array ( - 'type' => 'int', - 'formatter' => 'kOptionsFormatter', + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'la_No', 1 => 'la_Yes'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0, ), Index: branches/5.1.x/units/affiliates/affiliates_config.php =================================================================== diff -u -N -r13156 -r13578 --- branches/5.1.x/units/affiliates/affiliates_config.php (.../affiliates_config.php) (revision 13156) +++ branches/5.1.x/units/affiliates/affiliates_config.php (.../affiliates_config.php) (revision 13578) @@ -1,6 +1,6 @@ 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(-1 => 'root', -2 => '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' => 'Login', '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.1.x/units/orders/orders_event_handler.php =================================================================== diff -u -N -r13566 -r13578 --- branches/5.1.x/units/orders/orders_event_handler.php (.../orders_event_handler.php) (revision 13566) +++ branches/5.1.x/units/orders/orders_event_handler.php (.../orders_event_handler.php) (revision 13578) @@ -1,6 +1,6 @@ Application->RecallVar('user_id'); if (!$user_id) { - $user_id = -2; // Guest + $user_id = USER_GUEST; } $object->SetDBField('PortalUserId', $user_id); @@ -1243,7 +1243,10 @@ $ses_user = $this->Application->RecallVar('user_id'); if ($order->GetDBField('PortalUserId') != $ses_user) { - if ($ses_user == 0) $ses_user = -2; //Guest + if ($ses_user == 0) { + $ses_user = USER_GUEST; + } + $order->SetDBField('PortalUserId', $ses_user); // since CheckUser is called in OnBeforeItemUpdate, we don't need to call udpate here, just set the field } Index: branches/5.1.x/units/products/products_event_handler.php =================================================================== diff -u -N -r13549 -r13578 --- branches/5.1.x/units/products/products_event_handler.php (.../products_event_handler.php) (revision 13549) +++ branches/5.1.x/units/products/products_event_handler.php (.../products_event_handler.php) (revision 13578) @@ -1,6 +1,6 @@ redirect = $this->Application->GetVar('success_template'); $object =& $event->getObject(); - $user_id = ($this->Application->RecallVar('user_id') == 0) ? -2 : $this->Application->RecallVar('user_id'); + $user_id = $this->Application->RecallVar('user_id'); $sql = ' SELECT * FROM '.TABLE_PREFIX.'SpamControl WHERE ItemResourceId='.$object->GetDBField('ResourceId').' Index: branches/5.1.x/units/coupons/coupons_config.php =================================================================== diff -u -N -r13156 -r13578 --- branches/5.1.x/units/coupons/coupons_config.php (.../coupons_config.php) (revision 13156) +++ branches/5.1.x/units/coupons/coupons_config.php (.../coupons_config.php) (revision 13578) @@ -1,6 +1,6 @@ Array ( 'type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), - 'options' => Array (-1 => 'root', -2 => 'Guest'), + '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' => 0, 'default' => null, Index: branches/5.1.x/install.php =================================================================== diff -u -N -r13195 -r13578 --- branches/5.1.x/install.php (.../install.php) (revision 13195) +++ branches/5.1.x/install.php (.../install.php) (revision 13578) @@ -1,6 +1,6 @@ Init(); - if ($application->RecallVar('user_id') != -1) { + if ($application->RecallVar('user_id') != USER_ROOT) { die('restricted access!'); } Index: branches/5.1.x/units/orders/orders_tag_processor.php =================================================================== diff -u -N -r13549 -r13578 --- branches/5.1.x/units/orders/orders_tag_processor.php (.../orders_tag_processor.php) (revision 13549) +++ branches/5.1.x/units/orders/orders_tag_processor.php (.../orders_tag_processor.php) (revision 13578) @@ -1,6 +1,6 @@ getObject($params); return !in_array( $object->GetDBField( $params['user_field'] ) , $virtual_users ); } Index: branches/5.1.x/units/gateways/gw_classes/authorizenet.php =================================================================== diff -u -N -r13465 -r13578 --- branches/5.1.x/units/gateways/gw_classes/authorizenet.php (.../authorizenet.php) (revision 13465) +++ branches/5.1.x/units/gateways/gw_classes/authorizenet.php (.../authorizenet.php) (revision 13578) @@ -1,6 +1,6 @@ Application->isAdmin)) return false; + if( ($item_data['PortalUserId'] != $gw_responce['customer_id']) && ($gw_repsponce['customer_id'] != USER_GUEST && !$this->Application->isAdmin)) return false; if( ( strtolower($gw_responce['transaction_type']) == 'auth_only') ) {