Index: branches/unlabeled/unlabeled-1.43.2/admin/install/install_lib.php =================================================================== diff -u -r5732 -r6015 --- branches/unlabeled/unlabeled-1.43.2/admin/install/install_lib.php (.../install_lib.php) (revision 5732) +++ branches/unlabeled/unlabeled-1.43.2/admin/install/install_lib.php (.../install_lib.php) (revision 6015) @@ -36,7 +36,7 @@ } else { - return ($a_extension == 'php') ? 1 : -1; + return ($a_extension == 'php') ? 1 : -1; // this makes .php extension go AFTER .sql in the sorting } } else @@ -949,13 +949,13 @@ // 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).' + SET CategoryTemplate = '.$inst_ado->qstr($category_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).' + SET CachedCategoryTemplate = '.$inst_ado->qstr($category_template).' WHERE ParentPath LIKE "|'.$module_root.'|%'; $inst_ado->Execute($sql); } @@ -1043,4 +1043,25 @@ $ml_helper =& $application->recallObject('kMultiLanguageHelper'); $ml_helper->createFields($prefix.'-cdata', true); } + + function moveItemTemplatesToCustom($module_name, $prefix) + { + $application =& kApplication::Instance(); + $root_parent_path = $application->Conn->GetOne( + 'SELECT ParentPath FROM '.TABLE_PREFIX.'Category + WHERE CategoryId = '.$application->ModuleInfo[$module_name]['RootCat']); + $item_t_customfield = $application->Conn->GetOne('SELECT CustomFieldId FROM '.TABLE_PREFIX.'CustomField WHERE FieldName = \''.$prefix.'_ItemTemplate\''); + $item_t_customfield = 'l1_cust_'.$item_t_customfield; + + $current_item_tpls = $application->Conn->Query( + 'SELECT ResourceId, ItemTemplate FROM '.TABLE_PREFIX.'Category + WHERE ParentPath LIKE "'.$root_parent_path.'%"'); + + foreach ($current_item_tpls as $a_cat) { + $query = 'UPDATE '.TABLE_PREFIX.'CategoryCustomData + SET '.$item_t_customfield.' = '.$application->Conn->qstr($a_cat['ItemTemplate']).' + WHERE ResourceId = '.$a_cat['ResourceId']; + } + + } ?>