Index: admin_templates/catalog/catalog.tpl =================================================================== --- admin_templates/catalog/catalog.tpl (revision 12775) +++ admin_templates/catalog/catalog.tpl (working copy) @@ -221,7 +221,7 @@ var $edit_url = ''; var $category_id = get_hidden_field('m_cat_id'); var $redirect_url = $edit_url.replace('#CATEGORY_ID#', $category_id); - $redirect_url = $redirect_url.replace('#TEMPLATE#', $category_id > 0 ? 'categories/categories_edit' : 'categories/categories_edit_permissions'); + $redirect_url = $redirect_url.replace('#TEMPLATE#', $category_id == 0 || $category_id == ? 'categories/categories_edit_permissions' : 'categories/categories_edit'); direct_edit('c', $redirect_url); break; Index: install.php =================================================================== --- install.php (revision 12808) +++ install.php (working copy) @@ -566,8 +566,17 @@ $this->toolkit->RunSQL('/core/install/install_data.sql'); // create category using sql, because Application is not available here + $table_name = $this->toolkit->getSystemConfig('Database', 'TablePrefix') . 'IdGenerator'; + $this->Conn->Query('UPDATE ' . $table_name . ' SET lastid = lastid + 1'); + $resource_id = $this->Conn->GetOne('SELECT lastid FROM ' . $table_name); + if ($resource_id === false) { + $this->Conn->Query('INSERT INTO '.$table_name.' (lastid) VALUES (2)'); + $resource_id = 2; + } + $fields_hash = Array ( 'l1_Name' => 'Content', 'Filename' => 'Content', 'AutomaticFilename' => 0, + 'CreatedById' => -1, 'CreatedOn' => time(), 'ResourceId' => $resource_id - 1, 'l1_Description' => 'Content', 'Status' => 4, ); Index: install/upgrades.php =================================================================== --- install/upgrades.php (revision 12808) +++ install/upgrades.php (working copy) @@ -1203,6 +1203,18 @@ */ function Upgrade_5_0_2_B2($mode) { + if ($mode == 'before') { + $fields_hash = Array ( + 'CreatedById' => -1, // root + 'CreatedOn' => time(), + 'ResourceId' => $this->Application->NextResourceId(), + ); + + $category_id = $this->Application->findModule('Name', 'Core', 'RootCat'); + + $this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'Category', 'CategoryId = ' . $category_id); + } + if ($mode == 'after') { // scan theme to fill Theme.TemplateAliases and ThemeFiles.TemplateAlias fields $this->_toolkit->rebuildThemes(); @@ -1278,7 +1290,6 @@ $this->Conn->Query($sql); } } - } } } \ No newline at end of file Index: units/categories/categories_event_handler.php =================================================================== --- units/categories/categories_event_handler.php (revision 12808) +++ units/categories/categories_event_handler.php (working copy) @@ -202,9 +202,11 @@ */ function OnEdit(&$event) { - $category_id = $this->Application->GetVar($event->getPrefixSpecial().'_id'); - $this->Application->StoreVar('IsRootCategory_'.$this->Application->GetVar('m_wid'), $category_id === '0'); + $category_id = $this->Application->GetVar($event->getPrefixSpecial() . '_id'); + $home_category = $this->Application->findModule('Name', 'Core', 'RootCat'); + $this->Application->StoreVar('IsRootCategory_'.$this->Application->GetVar('m_wid'), ($category_id === '0') || ($category_id == $home_category)); + parent::OnEdit($event); }