Index: branches/5.2.x/core/kernel/application.php
===================================================================
--- branches/5.2.x/core/kernel/application.php
+++ branches/5.2.x/core/kernel/application.php
@@ -1033,21 +1033,7 @@
 				kUtil::safeDefine('DBG_SKIP_REPORTING', 1); // safeDefine, because debugger also defines it
 			}
 		}
-		elseif ( $this->GetVar('admin') ) {
-			/** @var Session $admin_session */
-			$admin_session = $this->recallObject('Session.admin');
 
-			// store Admin Console User's ID to Front-End's session for cross-session permission checks
-			$this->StoreVar('admin_user_id', (int)$admin_session->RecallVar('user_id'));
-
-			if ( $this->CheckAdminPermission('CATEGORY.MODIFY', 0, $this->getBaseCategory()) ) {
-				// user can edit cms blocks (when viewing front-end through admin's frame)
-				$editing_mode = $this->GetVar('editing_mode');
-				define('EDITING_MODE', $editing_mode ? $editing_mode : EDITING_MODE_BROWSE);
-			}
-		}
-
-		kUtil::safeDefine('EDITING_MODE', ''); // user can't edit anything
 		$this->Phrases->setPhraseEditing();
 
 		$this->EventManager->ProcessRequest();
Index: branches/5.2.x/core/kernel/processors/main_processor.php
===================================================================
--- branches/5.2.x/core/kernel/processors/main_processor.php
+++ branches/5.2.x/core/kernel/processors/main_processor.php
@@ -1010,8 +1010,8 @@
 			}
 		}
 
-		if ( EDITING_MODE ) {
-			// match SSL mode on front-end to one in administrative console, when browse modes are used
+		if ( defined('EDITING_MODE') && EDITING_MODE ) {
+			// Match SSL mode on front-end to one in administrative console, when browse modes are used.
 			$require = $this->Application->ConfigValue('Require_AdminSSL');
 		}
 
Index: branches/5.2.x/core/units/categories/categories_config.php
===================================================================
--- branches/5.2.x/core/units/categories/categories_config.php
+++ branches/5.2.x/core/units/categories/categories_config.php
@@ -73,6 +73,17 @@
 			'DoSpecial' => '*',
 			'DoEvent' => 'OnCloneSubItem',
 		),
+
+		array(
+			'Mode' => hAFTER,
+			'Conditional' => false,
+			'HookToPrefix' => 'adm',
+			'HookToSpecial' => '',
+			'HookToEvent' => array('OnStartup'),
+			'DoPrefix' => '',
+			'DoSpecial' => '',
+			'DoEvent' => 'OnAfterStartupHook',
+		),
 	),
 
 	'AutoLoad' => true,
Index: branches/5.2.x/core/units/categories/categories_event_handler.php
===================================================================
--- branches/5.2.x/core/units/categories/categories_event_handler.php
+++ branches/5.2.x/core/units/categories/categories_event_handler.php
@@ -221,6 +221,40 @@
 		}
 
 		/**
+		 * Creates "EDITING_MODE" constant.
+		 *
+		 * @param kEvent $event Event.
+		 *
+		 * @return void
+		 */
+		protected function OnAfterStartupHook(kEvent $event)
+		{
+			if ( !$this->Application->GetVar('admin') ) {
+				// User can't edit anything.
+				kUtil::safeDefine('EDITING_MODE', '');
+
+				return;
+			}
+
+			/** @var Session $admin_session */
+			$admin_session = $this->Application->recallObject('Session.admin');
+
+			// Store Admin Console User's ID to Front-End's session for cross-session permission checks.
+			$this->Application->StoreVar('admin_user_id', (int)$admin_session->RecallVar('user_id'));
+
+			$base_category = $this->Application->getBaseCategory();
+
+			if ( $this->Application->CheckAdminPermission('CATEGORY.MODIFY', 0, $base_category) ) {
+				// User can edit cms blocks (when viewing front-end through admin's frame).
+				$editing_mode = $this->Application->GetVar('editing_mode');
+				define('EDITING_MODE', $editing_mode ? $editing_mode : EDITING_MODE_BROWSE);
+			}
+
+			// User can't edit anything.
+			kUtil::safeDefine('EDITING_MODE', '');
+		}
+
+		/**
 		 * Set's mark, that root category is edited
 		 *
 		 * @param kEvent $event