Index: branches/5.1.x/core/units/modules/modules_event_handler.php =================================================================== diff -u -N -r13189 -r13581 --- branches/5.1.x/core/units/modules/modules_event_handler.php (.../modules_event_handler.php) (revision 13189) +++ branches/5.1.x/core/units/modules/modules_event_handler.php (.../modules_event_handler.php) (revision 13581) @@ -1,6 +1,6 @@ _getNewModules(); - if (!$new_modules || $this->Application->RecallVar('user_id') != -1) { + if (!$new_modules || $this->Application->RecallVar('user_id') != USER_ROOT) { return ; } Index: branches/5.1.x/core/kernel/db/cat_tag_processor.php =================================================================== diff -u -N -r13545 -r13581 --- branches/5.1.x/core/kernel/db/cat_tag_processor.php (.../cat_tag_processor.php) (revision 13545) +++ branches/5.1.x/core/kernel/db/cat_tag_processor.php (.../cat_tag_processor.php) (revision 13581) @@ -1,6 +1,6 @@ Application->RecallVar('user_id') == -1) { + if ($this->Application->RecallVar('user_id') == USER_ROOT) { $categories = true; } else { Index: branches/5.1.x/core/units/structure/structure_config.php =================================================================== diff -u -N -r13545 -r13581 --- branches/5.1.x/core/units/structure/structure_config.php (.../structure_config.php) (revision 13545) +++ branches/5.1.x/core/units/structure/structure_config.php (.../structure_config.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/kernel/startup.php =================================================================== diff -u -N -r13545 -r13581 --- branches/5.1.x/core/kernel/startup.php (.../startup.php) (revision 13545) +++ branches/5.1.x/core/kernel/startup.php (.../startup.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/units/users/users_event_handler.php =================================================================== diff -u -N -r13559 -r13581 --- branches/5.1.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 13559) +++ branches/5.1.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/units/mailing_lists/mailing_lists_config.php =================================================================== diff -u -N -r13159 -r13581 --- branches/5.1.x/core/units/mailing_lists/mailing_lists_config.php (.../mailing_lists_config.php) (revision 13159) +++ branches/5.1.x/core/units/mailing_lists/mailing_lists_config.php (.../mailing_lists_config.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/units/languages/languages_event_handler.php =================================================================== diff -u -N -r13569 -r13581 --- branches/5.1.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 13569) +++ branches/5.1.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 13581) @@ -1,6 +1,6 @@ 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 { Index: branches/5.1.x/core/units/modules/modules_tag_processor.php =================================================================== diff -u -N -r13189 -r13581 --- branches/5.1.x/core/units/modules/modules_tag_processor.php (.../modules_tag_processor.php) (revision 13189) +++ branches/5.1.x/core/units/modules/modules_tag_processor.php (.../modules_tag_processor.php) (revision 13581) @@ -1,6 +1,6 @@ Application->RecallVar('user_id') == -1; + return $this->Application->RecallVar('user_id') == USER_ROOT; } function AlreadyInstalled($params) Index: branches/5.1.x/core/units/visits/visits_config.php =================================================================== diff -u -N -r13159 -r13581 --- branches/5.1.x/core/units/visits/visits_config.php (.../visits_config.php) (revision 13159) +++ branches/5.1.x/core/units/visits/visits_config.php (.../visits_config.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/units/categories/categories_config.php =================================================================== diff -u -N -r13545 -r13581 --- branches/5.1.x/core/units/categories/categories_config.php (.../categories_config.php) (revision 13545) +++ branches/5.1.x/core/units/categories/categories_config.php (.../categories_config.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/units/users/users_tag_processor.php =================================================================== diff -u -N -r13086 -r13581 --- branches/5.1.x/core/units/users/users_tag_processor.php (.../users_tag_processor.php) (revision 13086) +++ branches/5.1.x/core/units/users/users_tag_processor.php (.../users_tag_processor.php) (revision 13581) @@ -1,6 +1,6 @@ getObject($params); - return $object->GetID() != -1 ? $object->GetDBField('Login') : 'root'; + return $object->GetID() != USER_ROOT ? $object->GetDBField('Login') : 'root'; } function CookieUsername($params) Index: branches/5.1.x/core/kernel/event_handler.php =================================================================== diff -u -N -r13086 -r13581 --- branches/5.1.x/core/kernel/event_handler.php (.../event_handler.php) (revision 13086) +++ branches/5.1.x/core/kernel/event_handler.php (.../event_handler.php) (revision 13581) @@ -1,6 +1,6 @@ Application->recallObject('PermissionsHelper'); + /* @var $perm_helper kPermissionsHelper */ return $perm_helper->CheckEventPermission($event, $this->permMapping); } Index: branches/5.1.x/core/units/helpers/permissions_helper.php =================================================================== diff -u -N -r13461 -r13581 --- branches/5.1.x/core/units/helpers/permissions_helper.php (.../permissions_helper.php) (revision 13461) +++ branches/5.1.x/core/units/helpers/permissions_helper.php (.../permissions_helper.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/kernel/event_manager.php =================================================================== diff -u -N -r13545 -r13581 --- branches/5.1.x/core/kernel/event_manager.php (.../event_manager.php) (revision 13545) +++ branches/5.1.x/core/kernel/event_manager.php (.../event_manager.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/units/logs/session_logs/session_logs_config.php =================================================================== diff -u -N -r13161 -r13581 --- branches/5.1.x/core/units/logs/session_logs/session_logs_config.php (.../session_logs_config.php) (revision 13161) +++ branches/5.1.x/core/units/logs/session_logs/session_logs_config.php (.../session_logs_config.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/kernel/session/inp_session.php =================================================================== diff -u -N -r13086 -r13581 --- branches/5.1.x/core/kernel/session/inp_session.php (.../inp_session.php) (revision 13086) +++ branches/5.1.x/core/kernel/session/inp_session.php (.../inp_session.php) (revision 13581) @@ -1,6 +1,6 @@ $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: branches/5.1.x/core/kernel/utility/temp_handler.php =================================================================== diff -u -N -r13168 -r13581 --- branches/5.1.x/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 13168) +++ branches/5.1.x/core/kernel/utility/temp_handler.php (.../temp_handler.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/units/categories/categories_event_handler.php =================================================================== diff -u -N -r13545 -r13581 --- branches/5.1.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 13545) +++ branches/5.1.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/units/reviews/reviews_config.php =================================================================== diff -u -N -r13545 -r13581 --- branches/5.1.x/core/units/reviews/reviews_config.php (.../reviews_config.php) (revision 13545) +++ branches/5.1.x/core/units/reviews/reviews_config.php (.../reviews_config.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/units/helpers/user_helper.php =================================================================== diff -u -N -r13471 -r13581 --- branches/5.1.x/core/units/helpers/user_helper.php (.../user_helper.php) (revision 13471) +++ branches/5.1.x/core/units/helpers/user_helper.php (.../user_helper.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/kernel/constants.php =================================================================== diff -u -N -r13559 -r13581 --- branches/5.1.x/core/kernel/constants.php (.../constants.php) (revision 13559) +++ branches/5.1.x/core/kernel/constants.php (.../constants.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/units/helpers/spam_helper.php =================================================================== diff -u -N -r13435 -r13581 --- branches/5.1.x/core/units/helpers/spam_helper.php (.../spam_helper.php) (revision 13435) +++ branches/5.1.x/core/units/helpers/spam_helper.php (.../spam_helper.php) (revision 13581) @@ -1,6 +1,6 @@ Application->RecallVar('user_id'); if ($user_id == 0) { - $user_id = -2; + $user_id = USER_GUEST; } $keys = Array ( Index: branches/5.1.x/core/install.php =================================================================== diff -u -N -r13569 -r13581 --- branches/5.1.x/core/install.php (.../install.php) (revision 13569) +++ branches/5.1.x/core/install.php (.../install.php) (revision 13581) @@ -1,6 +1,6 @@ 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); @@ -563,7 +563,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, ); Index: branches/5.1.x/core/units/visits/visits_tag_processor.php =================================================================== diff -u -N -r13086 -r13581 --- branches/5.1.x/core/units/visits/visits_tag_processor.php (.../visits_tag_processor.php) (revision 13086) +++ branches/5.1.x/core/units/visits/visits_tag_processor.php (.../visits_tag_processor.php) (revision 13581) @@ -1,6 +1,6 @@ Application->recallObject( $this->getPrefixSpecial(), $this->Prefix, $params ); return !in_array( $object->GetDBField( $params['user_field'] ) , $virtual_users ); } Index: branches/5.1.x/core/units/categories/categories_tag_processor.php =================================================================== diff -u -N -r13545 -r13581 --- branches/5.1.x/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 13545) +++ branches/5.1.x/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 13581) @@ -1,6 +1,6 @@ Application->RecallVar('user_id') == -1) { + if ($this->Application->RecallVar('user_id') == USER_ROOT) { $categories = true; } else { Index: branches/5.1.x/core/kernel/db/cat_event_handler.php =================================================================== diff -u -N -r13545 -r13581 --- branches/5.1.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 13545) +++ branches/5.1.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/units/files/files_config.php =================================================================== diff -u -N -r13545 -r13581 --- branches/5.1.x/core/units/files/files_config.php (.../files_config.php) (revision 13545) +++ branches/5.1.x/core/units/files/files_config.php (.../files_config.php) (revision 13581) @@ -1,6 +1,6 @@ 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: branches/5.1.x/core/kernel/db/db_event_handler.php =================================================================== diff -u -N -r13569 -r13581 --- branches/5.1.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 13569) +++ branches/5.1.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 13581) @@ -1,6 +1,6 @@ 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; }