Index: core/kernel/application.php =================================================================== --- core/kernel/application.php +++ core/kernel/application.php @@ -1032,21 +1032,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: core/kernel/processors/main_processor.php =================================================================== --- core/kernel/processors/main_processor.php +++ 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: core/units/categories/categories_config.php =================================================================== --- core/units/categories/categories_config.php +++ 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: core/units/categories/categories_event_handler.php =================================================================== --- core/units/categories/categories_event_handler.php +++ 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