Index: install/install_toolkit.php
===================================================================
--- install/install_toolkit.php (revision 13956)
+++ install/install_toolkit.php (working copy)
@@ -712,7 +712,7 @@
'NamedParentPath' => 'Content/' . $name,
);
- $category_fields['ParentId'] = $this->Application->findModule('Name', 'Core', 'RootCat');
+ $category_fields['ParentId'] = $this->Application->getBaseCategory();
if (isset($category_template)) {
$category_fields['Template'] = $category_template;
Index: kernel/application.php
===================================================================
--- kernel/application.php (revision 13936)
+++ kernel/application.php (working copy)
@@ -1039,7 +1039,7 @@
$perm_helper =& $this->recallObject('PermissionsHelper');
/* @var $perm_helper kPermissionsHelper */
- if ($perm_helper->CheckUserPermission($user, 'CATEGORY.MODIFY', 0, $this->ModuleInfo['Core']['RootCat'])) {
+ if ($perm_helper->CheckUserPermission($user, 'CATEGORY.MODIFY', 0, $this->getBaseCategory())) {
// user can edit cms blocks
$editing_mode = $this->GetVar('editing_mode');
define('EDITING_MODE', $editing_mode ? $editing_mode : EDITING_MODE_BROWSE);
@@ -3232,4 +3232,18 @@
return false;
}
+ /**
+ * Base category of all categories
+ * Usually replaced category, with ID = 0 in category-related operations.
+ *
+ * @return int
+ */
+ function getBaseCategory()
+ {
+ // same, what $this->findModule('Name', 'Core', 'RootCat') does
+ // don't cache while IS_INSTALL, because of kInstallToolkit::createModuleCategory and upgrade
+
+ return $this->ModuleInfo['Core']['RootCat'];
+ }
+
}
\ No newline at end of file
Index: kernel/db/cat_event_handler.php
===================================================================
--- kernel/db/cat_event_handler.php (revision 13936)
+++ kernel/db/cat_event_handler.php (working copy)
@@ -572,7 +572,7 @@
if ("$parent_cat_id" == '0') {
// replace "0" category with "Content" category id (this way template
- $parent_cat_id = $this->Application->findModule('Name', 'Core', 'RootCat');
+ $parent_cat_id = $this->Application->getBaseCategory();
}
if ((string)$parent_cat_id != 'any') {
@@ -2047,7 +2047,7 @@
*/
function OnResetSettings(&$event)
{
- $this->Application->StoreVar('ImportCategory', $this->Application->findModule('Name', 'Core', 'RootCat'));
+ $this->Application->StoreVar('ImportCategory', $this->Application->getBaseCategory());
}
function OnCancelAction(&$event)
Index: units/admin/admin_tag_processor.php
===================================================================
--- units/admin/admin_tag_processor.php (revision 13936)
+++ units/admin/admin_tag_processor.php (working copy)
@@ -463,7 +463,7 @@
}
$params['t'] = 'catalog/item_selector/item_selector_'.$mode;
- $params['m_cat_id'] = $this->Application->findModule('Name', 'Core', 'RootCat');
+ $params['m_cat_id'] = $this->Application->getBaseCategory();
$default_params = Array('no_amp' => 1, 'pass' => 'all,'.$params['prefix']);
unset($params['prefix']);
@@ -766,7 +766,7 @@
if (isset($params['m_opener']) && $params['m_opener'] == 'r') {
// front-end link for highlighting purposes
$vars['t'] = 'index';
- $vars['m_cat_id'] = $this->Application->findModule('Name', 'Core', 'RootCat');
+ $vars['m_cat_id'] = $this->Application->getBaseCategory();
}
unset($recursion_templates[ array_search('index', $recursion_templates)]);
Index: units/categories/categories_event_handler.php
===================================================================
--- units/categories/categories_event_handler.php (revision 13984)
+++ units/categories/categories_event_handler.php (working copy)
@@ -214,7 +214,7 @@
function OnEdit(&$event)
{
$category_id = $this->Application->GetVar($event->getPrefixSpecial() . '_id');
- $home_category = $this->Application->findModule('Name', 'Core', 'RootCat');
+ $home_category = $this->Application->getBaseCategory();
$this->Application->StoreVar('IsRootCategory_'.$this->Application->GetVar('m_wid'), ($category_id === '0') || ($category_id == $home_category));
@@ -291,7 +291,7 @@
if ("$parent_cat_id" == '0') {
// replace "0" category with "Content" category id (this way template
- $parent_cat_id = $this->Application->findModule('Name', 'Core', 'RootCat');
+ $parent_cat_id = $this->Application->getBaseCategory();
}
if ("$parent_cat_id" != 'any') {
@@ -758,7 +758,7 @@
// 2. preset template
$category_id = $this->Application->GetVar('m_cat_id');
- $root_category = $this->Application->findModule('Name', 'Core', 'RootCat');
+ $root_category = $this->Application->getBaseCategory();
if ($category_id == $root_category) {
$object->SetDBField('Template', $this->_getDefaultDesign());
}
@@ -1589,7 +1589,7 @@
$this->_saveTitleField($object, 'Title');
$this->_saveTitleField($object, 'MenuTitle');
- $root_category = $this->Application->findModule('Name', 'Core', 'RootCat');
+ $root_category = $this->Application->getBaseCategory();
if (($object->GetDBField('ParentId') == $root_category) && ($object->GetDBField('Template') == CATEGORY_TEMPLATE_INHERIT)) {
$object->SetError('Template', 'no_inherit');
@@ -1672,7 +1672,7 @@
$theme_id = $this->_getCurrentThemeId();
}
- $root_category = $this->Application->findModule('Name', 'Core', 'RootCat');
+ $root_category = $this->Application->getBaseCategory();
$page_category = $this->Application->GetVar('m_cat_id');
if (!$page_category) {
$page_category = $root_category;
@@ -1869,7 +1869,7 @@
$settings = $site_config_helper->getSettings();
- $root_category = $this->Application->findModule('Name', 'Core', 'RootCat');
+ $root_category = $this->Application->getBaseCategory();
// set root category
$section_ajustments = $this->Application->getUnitOption($event->Prefix, 'SectionAdjustments');
Index: units/categories/categories_tag_processor.php
===================================================================
--- units/categories/categories_tag_processor.php (revision 13951)
+++ units/categories/categories_tag_processor.php (working copy)
@@ -603,13 +603,7 @@
*/
function HomeCategory($params)
{
- static $root_category = null;
-
- if (!isset($root_category)) {
- $root_category = $this->Application->findModule('Name', 'Core', 'RootCat');
- }
-
- return $root_category;
+ return $this->Application->getBaseCategory();
}
/**
@@ -620,7 +614,7 @@
*/
function ModuleRootCategory($params)
{
- return $this->Application->GetVar('m_cat_id') == $this->HomeCategory($params);
+ return $this->Application->GetVar('m_cat_id') == $this->Application->getBaseCategory();
}
function CatalogItemCount($params)
Index: units/content/content_eh.php
===================================================================
--- units/content/content_eh.php (revision 13936)
+++ units/content/content_eh.php (working copy)
@@ -29,7 +29,7 @@
$user_id = $this->Application->RecallVar('user_id');
// user can change top category
- $top_category = $this->Application->findModule('Name', 'Core', 'RootCat');
+ $top_category = $this->Application->getBaseCategory();
$perm_status = $perm_helper->CheckUserPermission($user_id, 'CATEGORY.MODIFY', 0, $top_category);
return $perm_helper->finalizePermissionCheck($event, $perm_status);
Index: units/helpers/cat_dbitem_export_helper.php
===================================================================
--- units/helpers/cat_dbitem_export_helper.php (revision 13936)
+++ units/helpers/cat_dbitem_export_helper.php (working copy)
@@ -522,7 +522,7 @@
WHERE CategoryId = ' . (int)$this->Application->GetVar('m_cat_id');
$parent_path = $this->Conn->GetOne($sql);
$parent_path = explode('|', substr($parent_path, 1, -1));
- if ($parent_path && $parent_path[0] == $this->Application->findModule('Name', 'Core', 'RootCat')) {
+ if ($parent_path && $parent_path[0] == $this->Application->getBaseCategory()) {
array_shift($parent_path);
}
Index: units/helpers/category_helper.php
===================================================================
--- units/helpers/category_helper.php (revision 13955)
+++ units/helpers/category_helper.php (working copy)
@@ -243,7 +243,7 @@
*/
function getHomeCategoryPath($params, $current_category)
{
- $block_params['cat_id'] = $this->Application->findModule('Name', 'Core', 'RootCat'); // 0;
+ $block_params['cat_id'] = $this->Application->getBaseCategory();
$block_params['no_editing'] = 1;
$block_params['current'] = $current_category == $block_params['cat_id'] ? 1 : 0;
$block_params['separator'] = $params['separator'];
@@ -305,7 +305,7 @@
$category_data = $this->Conn->GetRow($sql);
$cached_path = Array ();
- $skip_category = $this->Application->findModule('Name', 'Core', 'RootCat');
+ $skip_category = $this->Application->getBaseCategory();
if ($category_data) {
$category_names = explode('&|&', $category_data[$navbar_field]);
@@ -457,7 +457,7 @@
$language_count = $ml_helper->getLanguageCount();
- $root_category = $this->Application->findModule('Name', 'Core', 'RootCat');
+ $root_category = $this->Application->getBaseCategory();
$data = $this->_getChildren($root_category, $language_count);
if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
@@ -552,7 +552,7 @@
$data = $this->_getStructureTree();
$theme_id = (int)$themes_helper->getCurrentThemeId();
- $root_category = $this->Application->findModule('Name', 'Core', 'RootCat');
+ $root_category = $this->Application->getBaseCategory();
$this->_primaryLanguageId = $this->Application->GetDefaultLanguageId();
$this->_structureTree = $this->_printChildren($data, $root_category, $this->Application->GetVar('m_lang'), $theme_id);
Index: units/helpers/menu_helper.php
===================================================================
--- units/helpers/menu_helper.php (revision 13951)
+++ units/helpers/menu_helper.php (working copy)
@@ -114,7 +114,7 @@
static $root_path = null;
if (!$root_cat) {
- $root_cat = $this->Application->ModuleInfo['Core']['RootCat'];
+ $root_cat = $this->Application->getBaseCategory();
$cache_key = 'parent_paths[%CIDSerial:' . $root_cat . '%]';
$root_path = $this->Application->getCache($cache_key);
@@ -176,7 +176,7 @@
$cat = $this_category->GetDBField('ParentId');
}
elseif ($cat == 0) {
- $cat = $this->Application->ModuleInfo['Core']['RootCat'];
+ $cat = $this->Application->getBaseCategory();
}
return $cat;
Index: units/helpers/permissions_helper.php
===================================================================
--- units/helpers/permissions_helper.php (revision 13936)
+++ units/helpers/permissions_helper.php (working copy)
@@ -539,13 +539,16 @@
return $name == 'SYSTEM_ACCESS.READONLY' ? 0 : 1;
}
+ if (!isset($cat_id)) {
+ $cat_id = $this->Application->GetVar('m_cat_id');
+ }
+
if ($type == 1) {
// "system" permission are always checked per "Home" category (ID = 0)
$cat_id = 0;
}
-
- if (!isset($cat_id)) {
- $cat_id = $this->Application->GetVar('m_cat_id');
+ elseif ("$cat_id" === "0") {
+ $cat_id = $this->Application->getBaseCategory();
}
// perm cache is build only based on records in db, that's why if permission is not explicitly denied, then
@@ -612,7 +615,7 @@
$cat_hierarchy = $this->Conn->GetOne($sql);
if ($cat_hierarchy === false) {
// category was deleted, but refrence to it stays in other tables -> data integrity is broken
- $cat_hierarchy = '|' . $this->Application->findModule('Name', 'Core', 'RootCat') . '|';
+ $cat_hierarchy = '|' . $this->Application->getBaseCategory() . '|';
}
}