Index: units/visits/visits_tag_processor.php =================================================================== --- units/visits/visits_tag_processor.php (revision 13557) +++ units/visits/visits_tag_processor.php (working copy) @@ -18,7 +18,7 @@ function UserFound($params) { - $virtual_users = Array(-1,-2, 0); + $virtual_users = Array(USER_ROOT, USER_GUEST, 0); $object =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix, $params ); return !in_array( $object->GetDBField( $params['user_field'] ) , $virtual_users ); } Index: units/visits/visits_config.php =================================================================== --- units/visits/visits_config.php (revision 13557) +++ units/visits/visits_config.php (working copy) @@ -85,10 +85,10 @@ 'CalculatedFields' => Array ( '' => Array ( - 'UserName' => 'IF( ISNULL(u.Login), IF (%1$s.PortalUserId = -1, \'root\', IF (%1$s.PortalUserId = -2, \'Guest\', \'n/a\')), u.Login)', + 'UserName' => 'IF( ISNULL(u.Login), IF (%1$s.PortalUserId = ' . USER_ROOT . ', \'root\', IF (%1$s.PortalUserId = ' . USER_GUEST . ', \'Guest\', \'n/a\')), u.Login)', ), 'incommerce' => Array ( - 'UserName' => 'IF( ISNULL(u.Login), IF (%1$s.PortalUserId = -1, \'root\', IF (%1$s.PortalUserId = -2, \'Guest\', \'n/a\')), u.Login)', + 'UserName' => 'IF( ISNULL(u.Login), IF (%1$s.PortalUserId = ' . USER_ROOT . ', \'root\', IF (%1$s.PortalUserId = ' . USER_GUEST . ', \'Guest\', \'n/a\')), u.Login)', 'AffiliateUser' => 'IF( LENGTH(au.Login),au.Login,\'!la_None!\')', 'AffiliatePortalUserId' => 'af.PortalUserId', 'OrderTotalAmount' => 'IF(ord.Status = 4, ord.SubTotal+ord.ShippingCost+ord.VAT, 0)', @@ -134,7 +134,7 @@ 'Referer' => Array ('type' => 'string','not_null' => '1','default' => ''), 'IPAddress' => Array ('type' => 'string','not_null' => '1','default' => ''), '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), - 'PortalUserId' => Array ('type' => 'int','not_null' => '1','default' => -2), + 'PortalUserId' => Array ('type' => 'int','not_null' => '1','default' => USER_GUEST), ), 'VirtualFields' => Array ( Index: units/users/users_tag_processor.php =================================================================== --- units/users/users_tag_processor.php (revision 13557) +++ units/users/users_tag_processor.php (working copy) @@ -211,7 +211,7 @@ function LoginName($params) { $object =& $this->getObject($params); - return $object->GetID() != -1 ? $object->GetDBField('Login') : 'root'; + return $object->GetID() != USER_ROOT ? $object->GetDBField('Login') : 'root'; } function CookieUsername($params) Index: units/users/users_event_handler.php =================================================================== --- units/users/users_event_handler.php (revision 13559) +++ units/users/users_event_handler.php (working copy) @@ -108,7 +108,7 @@ $user_id = $this->Application->RecallVar('user_id'); $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); - if ($event->Name == 'OnCreate' && $user_id == -2) { + if ($event->Name == 'OnCreate' && $user_id == USER_GUEST) { // "Guest" can create new users return true; } @@ -226,7 +226,7 @@ $object->SetError('ValidateLogin', 'no_permission', 'lu_no_permissions'); } else { - $object->SetID(-2); + $object->SetID(USER_GUEST); $object->SetError('ValidateLogin', 'invalid_password', 'la_invalid_password'); } @@ -1122,7 +1122,7 @@ if (!$items_info) return ; list ($id, $field_values) = each($items_info); $user_id = $this->Application->RecallVar('user_id'); - if ($id == $user_id && ($user_id > 0 || $user_id == -1)) { + if ($id == $user_id && ($user_id > 0 || $user_id == USER_ROOT)) { $user_dummy =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('skip_autoload' => true)); /* @var $user_dummy kDBItem */ @@ -1135,7 +1135,7 @@ } } - if ($user_id == -1) { + if ($user_id == USER_ROOT) { $object =& $event->getObject( Array('skip_autoload' => true) ); /* @var $object UsersItem */ @@ -1251,7 +1251,7 @@ return true; } - $virtual_users = Array (-1, -2); // root, Guest + $virtual_users = Array (USER_ROOT, USER_GUEST); return ($object->GetDBField('Status') == STATUS_ACTIVE) || in_array($object->GetID(), $virtual_users); } Index: units/structure/structure_config.php =================================================================== --- units/structure/structure_config.php (revision 13557) +++ units/structure/structure_config.php (working copy) @@ -138,7 +138,7 @@ 'MetaKeywords' => Array('type' => 'string', 'default' => null), 'CachedDescendantCatsQty' => Array('type' => 'int', 'default' => 0), 'CachedNavbar' => Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'default' => null), - 'CreatedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', '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', 'not_null' => 1,'default' => 0), + 'CreatedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', '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', 'not_null' => 1,'default' => 0), 'ResourceId' => Array('type' => 'int', 'default' => null), 'ParentPath' => Array('type' => 'string', 'default' => null), 'TreeLeft' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), @@ -149,7 +149,7 @@ 'NewItem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2), 'PopItem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2), 'Modified' => Array('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'), - 'ModifiedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', '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', 'not_null' => 1,'default' => 0), + 'ModifiedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', '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', 'not_null' => 1,'default' => 0), 'CachedTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''), Index: units/reviews/reviews_config.php =================================================================== --- units/reviews/reviews_config.php (revision 13557) +++ units/reviews/reviews_config.php (working copy) @@ -69,17 +69,17 @@ 'CalculatedFields' => Array ( '' => Array ( - 'ReviewedBy' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = -1, \'root\', IF (%1$s.CreatedById = -2, \'Guest\', \'n/a\')), pu.Login )', + 'ReviewedBy' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = ' . USER_ROOT . ', \'root\', IF (%1$s.CreatedById = ' . USER_GUEST . ', \'Guest\', \'n/a\')), pu.Login )', ), 'products' => Array ( - 'ReviewedBy' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = -1, \'root\', IF (%1$s.CreatedById = -2, \'Guest\', \'n/a\')), pu.Login )', + 'ReviewedBy' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = ' . USER_ROOT . ', \'root\', IF (%1$s.CreatedById = ' . USER_GUEST . ', \'Guest\', \'n/a\')), pu.Login )', 'ItemName' => 'pr.l1_Name', 'ProductId' => 'pr.ProductId', ), 'product' => Array ( - 'ReviewedBy' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = -1, \'root\', IF (%1$s.CreatedById = -2, \'Guest\', \'n/a\')), pu.Login )', + 'ReviewedBy' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = ' . USER_ROOT . ', \'root\', IF (%1$s.CreatedById = ' . USER_GUEST . ', \'Guest\', \'n/a\')), pu.Login )', 'ItemName' => 'pr.l1_Name', 'ProductId' => 'pr.ProductId', ), @@ -146,12 +146,12 @@ 'CreatedById' => Array ( 'type' => 'int', 'formatter' => 'kLEFTFormatter', - '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' => 1, 'not_null' => 1, 'default' => -1, + 'required' => 1, 'not_null' => 1, 'default' => USER_ROOT, 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), ), 'ItemType' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), Index: units/modules/modules_tag_processor.php =================================================================== --- units/modules/modules_tag_processor.php (revision 13557) +++ units/modules/modules_tag_processor.php (working copy) @@ -23,7 +23,7 @@ function _hasPrivileges() { - return $this->Application->RecallVar('user_id') == -1; + return $this->Application->RecallVar('user_id') == USER_ROOT; } function AlreadyInstalled($params) Index: units/modules/modules_event_handler.php =================================================================== --- units/modules/modules_event_handler.php (revision 13557) +++ units/modules/modules_event_handler.php (working copy) @@ -117,7 +117,7 @@ parent::OnAfterListQuery($event); $new_modules = $this->_getNewModules(); - if (!$new_modules || $this->Application->RecallVar('user_id') != -1) { + if (!$new_modules || $this->Application->RecallVar('user_id') != USER_ROOT) { return ; } Index: units/mailing_lists/mailing_lists_config.php =================================================================== --- units/mailing_lists/mailing_lists_config.php (revision 13557) +++ units/mailing_lists/mailing_lists_config.php (working copy) @@ -97,9 +97,9 @@ 'PortalUserId' => Array( 'type' => 'int', 'formatter' => 'kLEFTFormatter', - 'options' => Array (-1 => 'root'), + 'options' => Array (USER_ROOT => 'root'), '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, + 'required' => 1, 'not_null' => 1, 'default' => USER_ROOT, ), 'To' => Array ('type' => 'string', 'required' => 1, 'default' => NULL), Index: units/logs/session_logs/session_logs_config.php =================================================================== --- units/logs/session_logs/session_logs_config.php (revision 13557) +++ units/logs/session_logs/session_logs_config.php (working copy) @@ -75,7 +75,7 @@ 'CalculatedFields' => Array( '' => Array( - 'UserLogin' => 'IF(%1$s.PortalUserId=-1, \'root\', u.Login)', + 'UserLogin' => 'IF(%1$s.PortalUserId = ' . USER_ROOT . ', \'root\', u.Login)', 'UserFirstName' => 'u.FirstName', 'UserLastName' => 'u.LastName', 'UserEmail' => 'u.Email', Index: units/logs/change_logs/change_logs_config.php =================================================================== --- units/logs/change_logs/change_logs_config.php (revision 13557) +++ units/logs/change_logs/change_logs_config.php (working copy) @@ -89,7 +89,7 @@ 'CalculatedFields' => Array ( '' => Array ( - 'UserLogin' => 'IF(%1$s.PortalUserId = -1, \'root\', u.Login)', + 'UserLogin' => 'IF(%1$s.PortalUserId = ' . USER_ROOT . ', \'root\', u.Login)', 'UserFirstName' => 'u.FirstName', 'UserLastName' => 'u.LastName', 'UserEmail' => 'u.Email', Index: units/languages/languages_event_handler.php =================================================================== --- units/languages/languages_event_handler.php (revision 13559) +++ units/languages/languages_event_handler.php (working copy) @@ -305,7 +305,7 @@ $this->Application->Session->SetField('Language', $language_id); // remember last user language in administrative console - if ($this->Application->RecallVar('user_id') == -1) { + if ($this->Application->RecallVar('user_id') == USER_ROOT) { $this->Application->StorePersistentVar('AdminLanguage', $language_id); } else { @@ -504,10 +504,10 @@ 'l' . $object->GetID() . '_Body' => NULL, ); $this->Conn->doUpdate($fields_hash, $this->Application->getUnitOption('emailevents', 'TableName'), 1); - + // clean Phrases table $fields_hash = Array ( - 'l' . $object->GetID() . '_Translation' => NULL, + 'l' . $object->GetID() . '_Translation' => NULL, ); $this->Conn->doUpdate($fields_hash, $this->Application->getUnitOption('phrases', 'TableName'), 1); } Index: units/helpers/user_helper.php =================================================================== --- units/helpers/user_helper.php (revision 13557) +++ units/helpers/user_helper.php (working copy) @@ -66,7 +66,7 @@ } if (!$dry_run) { - $user_id = -1; + $user_id = USER_ROOT; $object->Load($user_id); $object->SetDBField('Login', 'root'); $this->Application->StoreVar('user_id', $user_id); @@ -178,7 +178,7 @@ $this->Application->HandleEvent($dummy, 'session-log:OnEndSession'); - $user_id = -2; + $user_id = USER_GUEST; $this->Application->SetVar('u.current_id', $user_id); $object =& $this->Application->recallObject('u.current', null, Array('skip_autoload' => true)); $object->Load($user_id); @@ -263,7 +263,7 @@ return ; } - $is_root = $this->Application->RecallVar('user_id') == -1; + $is_root = $this->Application->RecallVar('user_id') == USER_ROOT; $object =& $this->getUserObject(); Index: units/helpers/spam_helper.php =================================================================== --- units/helpers/spam_helper.php (revision 13557) +++ units/helpers/spam_helper.php (working copy) @@ -93,7 +93,7 @@ $user_id = $this->Application->RecallVar('user_id'); if ($user_id == 0) { - $user_id = -2; + $user_id = USER_GUEST; } $keys = Array ( Index: units/helpers/permissions_helper.php =================================================================== --- units/helpers/permissions_helper.php (revision 13557) +++ units/helpers/permissions_helper.php (working copy) @@ -188,7 +188,7 @@ } $event->setEventParam('raise_warnings', $raise_warnings); - $owner_id = -1; // owner is root if not detected + $owner_id = USER_ROOT; // owner is root if not detected if (!$id) { // item being created -> check by current (before editing started, saved in OnPreCreate event) category permissions // note: category in session is placed on catalog data import start @@ -522,7 +522,7 @@ function CheckUserPermission($user_id, $name, $type = 1, $cat_id = null) { - if ($user_id == -1) { + if ($user_id == USER_ROOT) { // "root" is allowed anywhere return $name == 'SYSTEM_ACCESS.READONLY' ? 0 : 1; } Index: units/files/files_config.php =================================================================== --- units/files/files_config.php (revision 13557) +++ units/files/files_config.php (working copy) @@ -90,7 +90,7 @@ 'not_null' => 1, 'default' => 1, ), 'CreatedOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'), - 'CreatedById' => Array ('type' => 'int', 'not_null' => 1, 'default' => -1), + 'CreatedById' => Array ('type' => 'int', 'not_null' => 1, 'default' => USER_ROOT), 'MimeType' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''), ), Index: units/categories/categories_tag_processor.php =================================================================== --- units/categories/categories_tag_processor.php (revision 13557) +++ units/categories/categories_tag_processor.php (working copy) @@ -1942,7 +1942,7 @@ */ function AllowedCategoriesJSON($params) { - if ($this->Application->RecallVar('user_id') == -1) { + if ($this->Application->RecallVar('user_id') == USER_ROOT) { $categories = true; } else { Index: units/categories/categories_event_handler.php =================================================================== --- units/categories/categories_event_handler.php (revision 13557) +++ units/categories/categories_event_handler.php (working copy) @@ -309,7 +309,7 @@ } $object->addFilter('perm_filter', 'PermId = 1'); // check for CATEGORY.VIEW permission - if ($this->Application->RecallVar('user_id') != -1) { + if ($this->Application->RecallVar('user_id') != USER_ROOT) { // apply permission filters to all users except "root" $groups = explode(',',$this->Application->RecallVar('UserGroups')); foreach ($groups as $group) { Index: units/categories/categories_config.php =================================================================== --- units/categories/categories_config.php (revision 13557) +++ units/categories/categories_config.php (working copy) @@ -338,7 +338,7 @@ 'MetaKeywords' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => null), 'CachedDescendantCatsQty' => Array ('type' => 'int', 'default' => 0), 'CachedNavbar' => Array ('type' => 'string', 'formatter' => 'kMultiLanguage', 'default' => null), - 'CreatedById' => 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', 'not_null' => 1,'default' => 0), + 'CreatedById' => 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', 'not_null' => 1,'default' => 0), 'ResourceId' => Array ('type' => 'int', 'default' => null), 'ParentPath' => Array ('type' => 'string', 'default' => null), 'TreeLeft' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), @@ -349,7 +349,7 @@ 'NewItem' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2), 'PopItem' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2), 'Modified' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'), - 'ModifiedById' => 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', 'not_null' => 1,'default' => 0), + 'ModifiedById' => 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', 'not_null' => 1,'default' => 0), 'CachedTemplate' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''), Index: kernel/utility/temp_handler.php =================================================================== --- kernel/utility/temp_handler.php (revision 13557) +++ kernel/utility/temp_handler.php (working copy) @@ -949,8 +949,8 @@ if ($sids) { // detect who is it $sql = 'SELECT - CONCAT(IF (s.PortalUserId = -1, \'root\', - IF (s.PortalUserId = -2, \'Guest\', + CONCAT(IF (s.PortalUserId = ' . USER_ROOT . ', \'root\', + IF (s.PortalUserId = ' . USER_GUEST . ', \'Guest\', CONCAT(FirstName, \' \', LastName, \' (\', Login, \')\') ) ), \' IP: \', s.IpAddress, \'\') FROM ' . TABLE_PREFIX . 'UserSession AS s Index: kernel/startup.php =================================================================== --- kernel/startup.php (revision 13557) +++ kernel/startup.php (working copy) @@ -167,6 +167,6 @@ include_once(KERNEL_PATH . '/utility/adodb-time.inc.php'); } - // global constants - define ('KG_TO_POUND', 2.20462262); - define ('POUND_TO_KG', 0.45359237); \ No newline at end of file + // system users + define('USER_ROOT', -1); + define('USER_GUEST', -2); \ No newline at end of file Index: kernel/session/session.php =================================================================== --- kernel/session/session.php (revision 13557) +++ kernel/session/session.php (working copy) @@ -353,7 +353,7 @@ function LoadPersistentVars(&$session) { $user_id = $session->RecallVar('user_id'); - if ($user_id != -2) { + if ($user_id != USER_GUEST) { // root & normal users $sql = 'SELECT VariableValue, VariableName FROM '.TABLE_PREFIX.'PersistantSessionData @@ -375,7 +375,7 @@ function StorePersistentVar(&$session, $var_name, $var_value) { $user_id = $session->RecallVar('user_id'); - if ($user_id == -2 || $user_id === false) { + if ($user_id == USER_GUEST || $user_id === false) { // -2 (when not logged in), false (when after u:OnLogout event) $session->StoreVar($var_name, $var_value); return ; @@ -414,7 +414,7 @@ */ function RecallPersistentVar(&$session, $var_name, $default = false) { - if ($session->RecallVar('user_id') == -2) { + if ($session->RecallVar('user_id') == USER_GUEST) { if ($default == ALLOW_DEFAULT_SETTINGS) { $default = null; } @@ -427,7 +427,7 @@ elseif ($default == ALLOW_DEFAULT_SETTINGS) { $default_user_id = $this->Application->ConfigValue('DefaultSettingsUserId'); if (!$default_user_id) { - $default_user_id = -1; + $default_user_id = USER_ROOT; } $sql = 'SELECT VariableValue, VariableName FROM '.TABLE_PREFIX.'PersistantSessionData @@ -450,7 +450,7 @@ $user_id = $session->RecallVar('user_id'); - if ($user_id != -2) { + if ($user_id != USER_GUEST) { $sql = 'DELETE FROM '.TABLE_PREFIX.'PersistantSessionData WHERE PortalUserId = '.$user_id.' AND VariableName = '.$this->Conn->qstr($var_name); $this->Conn->Query($sql); @@ -1398,7 +1398,7 @@ $user_id = $this->RecallVar('user_id'); $ret = $user_id > 0; - if (($this->RecallVar('admin') == 1 || defined('ADMIN')) && ($user_id == -1)) { + if (($this->RecallVar('admin') == 1 || defined('ADMIN')) && ($user_id == USER_ROOT)) { $ret = true; } return $ret; Index: kernel/session/inp_session.php =================================================================== --- kernel/session/inp_session.php (revision 13557) +++ kernel/session/inp_session.php (working copy) @@ -114,7 +114,7 @@ function StoreSession(&$session, $additional_fields = Array()) { $fields_hash = Array ( - 'PortalUserId' => $this->Application->isAdmin ? 0 : -2, // Guest + 'PortalUserId' => $this->Application->isAdmin ? 0 : USER_GUEST, 'Language' => $this->Application->GetDefaultLanguageId(true), 'Theme' => $this->Application->GetDefaultThemeId(), 'IpAddress' => $_SERVER['REMOTE_ADDR'], // getenv('REMOTE_ADDR') won't work on IIS, so use $_SERVER instead Index: kernel/event_manager.php =================================================================== --- kernel/event_manager.php (revision 13557) +++ kernel/event_manager.php (working copy) @@ -412,7 +412,7 @@ } $event->setEventParam('top_prefix', $this->Application->GetTopmostPrefix($event->Prefix, true)); - if (($this->Application->RecallVar('user_id') == -1) || $event_handler->CheckPermission($event)) { + if (($this->Application->RecallVar('user_id') == USER_ROOT) || $event_handler->CheckPermission($event)) { $this->HandleEvent($event); } @@ -744,7 +744,7 @@ $events_source = $agents[$event_type]; $user_id = $this->Application->RecallVar('user_id'); - $this->Application->StoreVar('user_id', -1, true); // to prevent permission checking inside events, true for optional storage + $this->Application->StoreVar('user_id', USER_ROOT, true); // to prevent permission checking inside events, true for optional storage foreach ($events_source as $short_name => $event_data) { $next_run = $event_data['NextRunOn']; Index: kernel/event_handler.php =================================================================== --- kernel/event_handler.php (revision 13557) +++ kernel/event_handler.php (working copy) @@ -187,6 +187,7 @@ function CheckPermission(&$event) { $perm_helper =& $this->Application->recallObject('PermissionsHelper'); + /* @var $perm_helper kPermissionsHelper */ return $perm_helper->CheckEventPermission($event, $this->permMapping); } Index: kernel/db/db_event_handler.php =================================================================== --- kernel/db/db_event_handler.php (revision 13557) +++ kernel/db/db_event_handler.php (working copy) @@ -533,14 +533,14 @@ $user_id = $this->Application->RecallVar('user_id'); $event->setEventParam('top_prefix', $this->Application->GetTopmostPrefix($event->Prefix, true)); $status_checked = false; - if ($user_id == -1 || $this->CheckPermission($event)) { + if ($user_id == USER_ROOT || $this->CheckPermission($event)) { // don't autoload item, when user doesn't have view permission $this->LoadItem($event); $status_checked = true; $editing_mode = defined('EDITING_MODE') ? EDITING_MODE : false; - if ($user_id != -1 && !$this->Application->isAdmin && !($editing_mode || $this->checkItemStatus($event))) { + if ($user_id != USER_ROOT && !$this->Application->isAdmin && !($editing_mode || $this->checkItemStatus($event))) { // non-root user AND on front-end AND (not editing mode || incorrect status) $perm_status = false; } @@ -2647,7 +2647,7 @@ $admin_ses =& $this->Application->recallObject('Session.admin'); /* @var $admin_ses Session */ - if ($admin_ses->RecallVar('user_id') == -1) { + if ($admin_ses->RecallVar('user_id') == USER_ROOT) { return true; } Index: kernel/db/cat_tag_processor.php =================================================================== --- kernel/db/cat_tag_processor.php (revision 13557) +++ kernel/db/cat_tag_processor.php (working copy) @@ -890,7 +890,7 @@ */ function AllowedCategoriesJSON($params) { - if ($this->Application->RecallVar('user_id') == -1) { + if ($this->Application->RecallVar('user_id') == USER_ROOT) { $categories = true; } else { Index: kernel/db/cat_event_handler.php =================================================================== --- kernel/db/cat_event_handler.php (revision 13557) +++ kernel/db/cat_event_handler.php (working copy) @@ -608,7 +608,7 @@ } // add permission filter - if ($this->Application->RecallVar('user_id') == -1) { + if ($this->Application->RecallVar('user_id') == USER_ROOT) { // for "root" CATEGORY.VIEW permission is checked for items lists too $view_perm = 1; } Index: kernel/constants.php =================================================================== --- kernel/constants.php (revision 13559) +++ kernel/constants.php (working copy) @@ -166,4 +166,7 @@ // site domains define('SITE_DOMAIN_REDIRECT_CURRENT', 1); - define('SITE_DOMAIN_REDIRECT_EXTERNAL', 2); \ No newline at end of file + define('SITE_DOMAIN_REDIRECT_EXTERNAL', 2); + + define ('KG_TO_POUND', 2.20462262); + define ('POUND_TO_KG', 0.45359237); Index: kernel/application.php =================================================================== --- kernel/application.php (revision 13559) +++ kernel/application.php (working copy) @@ -2212,8 +2212,8 @@ $session =& $this->recallObject('Session'); $user_id = $session->GetField('PortalUserId'); - if (!$user_id && $user_id != -1) { - $user_id = -2; + if (!$user_id && $user_id != USER_ROOT) { + $user_id = USER_GUEST; } $this->SetVar('u.current_id', $user_id); @@ -2223,7 +2223,7 @@ $this->SetVar('u_id', $user_id); } - $this->StoreVar('user_id', $user_id, $user_id == -2); // storing Guest user_id (-2) is optional + $this->StoreVar('user_id', $user_id, $user_id == USER_GUEST); // storing Guest user_id (-2) is optional $this->isAdminUser = $this->isAdmin && $this->LoggedIn(); @@ -2233,12 +2233,12 @@ $user->SetError('ValidateLogin', 'session_expired', 'la_text_sess_expired'); } - if (($user_id != -2) && constOn('DBG_REQUREST_LOG') ) { + if (($user_id != USER_GUEST) && constOn('DBG_REQUREST_LOG') ) { $http_query =& $this->recallObject('HTTPQuery'); $http_query->writeRequestLog(DBG_REQUREST_LOG); } - if ($user_id != -2) { + if ($user_id != USER_GUEST) { // normal users + root $this->LoadPersistentVars(); } @@ -3081,11 +3081,11 @@ function getUserGroups($user_id) { switch ($user_id) { - case -1: + case USER_ROOT: $user_groups = $this->ConfigValue('User_LoggedInGroup'); break; - case -2: + case USER_GUEST: $user_groups = $this->ConfigValue('User_LoggedInGroup') . ',' . $this->ConfigValue('User_GuestGroup'); break; Index: install.php =================================================================== --- install.php (revision 13557) +++ install.php (working copy) @@ -354,7 +354,7 @@ } if ($this->errorMessage == '') { - $user_id = -1; + $user_id = USER_ROOT; $session =& $this->Application->recallObject('Session'); $session->SetField('PortalUserId', $user_id); $this->Application->SetVar('u.current_id', $user_id); @@ -573,7 +573,7 @@ $fields_hash = Array ( 'l1_Name' => 'Content', 'Filename' => 'Content', 'AutomaticFilename' => 0, - 'CreatedById' => -1, 'CreatedOn' => time(), 'ResourceId' => $resource_id - 1, + 'CreatedById' => USER_ROOT, 'CreatedOn' => time(), 'ResourceId' => $resource_id - 1, 'l1_Description' => 'Content', 'Status' => 4, );