Index: branches/unlabeled/unlabeled-1.6.2/admin/category/permcacheupdate.php =================================================================== diff -u -N -r4382 -r4416 --- branches/unlabeled/unlabeled-1.6.2/admin/category/permcacheupdate.php (.../permcacheupdate.php) (revision 4382) +++ branches/unlabeled/unlabeled-1.6.2/admin/category/permcacheupdate.php (.../permcacheupdate.php) (revision 4416) @@ -135,6 +135,8 @@ var $doneCats; var $table; + var $root_prefixes = Array(); + /** * Kernel Application * @@ -153,6 +155,10 @@ $this->Application =& kApplication::Instance(); $this->Conn =& $this->Application->GetADODBConnection(); + foreach ($this->Application->ModuleInfo as $module_name => $module_info) { + $this->root_prefixes[ $module_info['RootCat'] ] = $module_info['Var']; + } + $this->conn =& GetADODBConnection(); $this->iteration = 0; $this->table=$GLOBALS['objSession']->GetEditTable('permCacheUpdate'); @@ -285,9 +291,11 @@ function QueryTitle(&$data) { + $category_id = $data['current_id']; + $sql = 'SELECT Name, Filename, CategoryTemplate, ItemTemplate FROM '.GetTablePrefix().'Category - WHERE CategoryId = '.$data['current_id']; + WHERE CategoryId = '.$category_id; $rs = $this->conn->Execute($sql); @@ -296,10 +304,28 @@ $data['title'][] = $rs->fields['Name']; $data['named_path'][] = $rs->fields['Filename']; + // it is one of the modules root category + $root_prefix = isset($this->root_prefixes[$category_id]) ? $this->root_prefixes[$category_id] : false; + if ($root_prefix) { + $fields_hash = Array(); + if (!$rs->fields['CategoryTemplate']) { + $rs->fields['CategoryTemplate'] = $this->Application->ConfigValue($root_prefix.'_CategoryTemplate'); + $fields_hash['CategoryTemplate'] = $rs->fields['CategoryTemplate']; + } + + if (!$rs->fields['ItemTemplate']) { + $rs->fields['ItemTemplate'] = $this->Application->ConfigValue($root_prefix.'_ItemTemplate'); + $fields_hash['ItemTemplate'] = $rs->fields['ItemTemplate']; + } + + $this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Category', 'CategoryId = '.$category_id); + } + // if explicitly set, then use it; use parent template otherwise if ($rs->fields['CategoryTemplate']) { $data['category_template'] = $rs->fields['CategoryTemplate']; } + if ($rs->fields['ItemTemplate']) { $data['item_template'] = $rs->fields['ItemTemplate']; }