Index: trunk/admin/install/install_lib.php =================================================================== diff -u -r3407 -r4133 --- trunk/admin/install/install_lib.php (.../install_lib.php) (revision 3407) +++ trunk/admin/install/install_lib.php (.../install_lib.php) (revision 4133) @@ -895,7 +895,7 @@ } /** - * Perform operations required for each module separate install (from admin) + * [INSTALL] Perform operations required for each module separate install (from admin) * * @param string $module_name * @param bool $has_theme @@ -924,4 +924,35 @@ $app->Redirect('', Array('pass' => 'all', 'admin' => 1, 'Refresh' => 1), '', 'modules/mod_status.php'); } + + /** + * [UPGRADE] Initializes [cached] category/item templates with default values for each module + * + * @param string $module + * @param string $category_template + * @param string $item_template + */ + function updateItemCategoryTemplate($module, $category_template, $item_template) + { + $table_prefix = GetTablePrefix(); + $inst_ado =& inst_GetADODBConnection(); + + // get module root category by module name + $sql = 'SELECT RootCat + FROM '.$table_prefix.'Modules + WHERE Name = '.$inst_ado->qstr($module); + $module_root = $inst_ado->GetOne($sql); + + // set category & item template to module root category + $sql = 'UPDATE '.$table_prefix.'Category + SET CategoryTemplate = '.$inst_ado->qstr($category_template).', ItemTemplate = '.$inst_ado->qstr($item_template).' + WHERE CategoryId = '.$module_root; + $inst_ado->Execute($sql); + + // set cached category & item templates to all sub-categories of module root category + $sql = 'UPDATE '.$table_prefix.'Category + SET CachedCategoryTemplate = '.$inst_ado->qstr($category_template).', CachedItemTemplate = '.$inst_ado->qstr($item_template).' + WHERE ParentPath LIKE "|'.$module_root.'|%'; + $inst_ado->Execute($sql); + } ?>