Index: branches/unlabeled/unlabeled-1.22.2/core/units/categories/categories_event_handler.php
===================================================================
diff -u -r5715 -r6015
--- branches/unlabeled/unlabeled-1.22.2/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 5715)
+++ branches/unlabeled/unlabeled-1.22.2/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 6015)
@@ -268,7 +268,7 @@
$live_object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('live_table' => true, 'skip_autoload' => true));
$live_object->Load($id);
- $cached_fields = Array('Name', 'Filename', 'CategoryTemplate', 'ItemTemplate');
+ $cached_fields = Array('Name', 'Filename', 'CategoryTemplate');
foreach ($cached_fields as $cached_field) {
if ($live_object->GetDBField($cached_field) != $temp_object->GetDBField($cached_field)) {
Index: branches/unlabeled/unlabeled-1.2.2/kernel/admin_templates/categories/categories_edit.tpl
===================================================================
diff -u -r5551 -r6015
--- branches/unlabeled/unlabeled-1.2.2/kernel/admin_templates/categories/categories_edit.tpl (.../categories_edit.tpl) (revision 5551)
+++ branches/unlabeled/unlabeled-1.2.2/kernel/admin_templates/categories/categories_edit.tpl (.../categories_edit.tpl) (revision 6015)
@@ -6,7 +6,7 @@
-
+
@@ -24,9 +24,9 @@
submit_event('c','OnCancel');
}
) );
-
+
a_toolbar.AddButton( new ToolBarSeparator('sep1') );
-
+
a_toolbar.AddButton( new ToolBarButton('prev', '', function() {
go_to_id('c', '');
}
@@ -35,21 +35,21 @@
go_to_id('c', '');
}
) );
-
+
a_toolbar.Render();
-
+
a_toolbar.HideButton('prev');
a_toolbar.HideButton('next');
a_toolbar.HideButton('sep1');
-
+
a_toolbar.DisableButton('next');
a_toolbar.DisableButton('prev');
-
+
@@ -58,15 +58,14 @@
-
+
-
-
+
@@ -75,8 +74,8 @@
-
-
+
+
Index: branches/unlabeled/unlabeled-1.6.2/core/units/categories/cache_updater.php
===================================================================
diff -u -r5887 -r6015
--- branches/unlabeled/unlabeled-1.6.2/core/units/categories/cache_updater.php (.../cache_updater.php) (revision 5887)
+++ branches/unlabeled/unlabeled-1.6.2/core/units/categories/cache_updater.php (.../cache_updater.php) (revision 6015)
@@ -286,7 +286,6 @@
'ParentPath' => '|'.implode('|', $data['parent_path']).'|',
'NamedParentPath' => implode('/', $data['named_path'] ),
'CachedCategoryTemplate' => $data['category_template'],
- 'CachedItemTemplate' => $data['item_template'],
);
$i = 1;
@@ -325,22 +324,13 @@
$fields_hash['CategoryTemplate'] = $record['CategoryTemplate'];
}
- if (!$record['ItemTemplate']) {
- $record['ItemTemplate'] = $this->Application->ConfigValue($root_prefix.'_ItemTemplate');
- $fields_hash['ItemTemplate'] = $record['ItemTemplate'];
- }
-
$this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Category', 'CategoryId = '.$category_id);
}
// if explicitly set, then use it; use parent template otherwise
if ($record['CategoryTemplate']) {
$data['category_template'] = $record['CategoryTemplate'];
}
-
- if ($record['ItemTemplate']) {
- $data['item_template'] = $record['ItemTemplate'];
- }
}
}
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'];
+ }
+
+ }
?>
Index: branches/unlabeled/unlabeled-1.61.2/admin/install/inportal_schema.sql
===================================================================
diff -u -r5634 -r6015
--- branches/unlabeled/unlabeled-1.61.2/admin/install/inportal_schema.sql (.../inportal_schema.sql) (revision 5634)
+++ branches/unlabeled/unlabeled-1.61.2/admin/install/inportal_schema.sql (.../inportal_schema.sql) (revision 6015)
@@ -55,9 +55,7 @@
Modified int(11) NOT NULL default '0',
ModifiedById int(11) NOT NULL default '0',
CategoryTemplate varchar(255) NOT NULL default '',
- ItemTemplate varchar(255) NOT NULL default '',
CachedCategoryTemplate varchar(255) NOT NULL default '',
- CachedItemTemplate varchar(255) NOT NULL default '',
PRIMARY KEY (CategoryId),
UNIQUE KEY ResourceId (ResourceId),
KEY ParentId (ParentId),
@@ -85,8 +83,7 @@
`PrimaryCat` tinyint(4) NOT NULL default '0',
`ItemPrefix` varchar(50) NOT NULL default '',
`Filename` varchar(255) NOT NULL default '',
- KEY `CategoryId` (`CategoryId`),
- KEY `ItemResourceId` (`ItemResourceId`),
+ UNIQUE KEY `CategoryId` (`CategoryId`,`ItemResourceId`),
KEY `PrimaryCat` (`PrimaryCat`),
KEY `ItemPrefix` (`ItemPrefix`),
KEY `Filename` (`Filename`(4))
Index: branches/unlabeled/unlabeled-1.50.2/core/units/categories/categories_config.php
===================================================================
diff -u -r5970 -r6015
--- branches/unlabeled/unlabeled-1.50.2/core/units/categories/categories_config.php (.../categories_config.php) (revision 5970)
+++ branches/unlabeled/unlabeled-1.50.2/core/units/categories/categories_config.php (.../categories_config.php) (revision 6015)
@@ -266,9 +266,7 @@
'Modified' => Array('type' => 'int', 'formatter' => 'kDateFormatter', 'not_null' => 1,'default' => '#NOW#'),
'ModifiedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'options' => Array(-1 => 'root', -2 => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'not_null' => 1,'default' => '0'),
'CategoryTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
- 'ItemTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
'CachedCategoryTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
- 'CachedItemTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
),
'VirtualFields' => Array(
Index: branches/unlabeled/unlabeled-1.6.2/kernel/units/categories/cache_updater.php
===================================================================
diff -u -r5887 -r6015
--- branches/unlabeled/unlabeled-1.6.2/kernel/units/categories/cache_updater.php (.../cache_updater.php) (revision 5887)
+++ branches/unlabeled/unlabeled-1.6.2/kernel/units/categories/cache_updater.php (.../cache_updater.php) (revision 6015)
@@ -286,7 +286,6 @@
'ParentPath' => '|'.implode('|', $data['parent_path']).'|',
'NamedParentPath' => implode('/', $data['named_path'] ),
'CachedCategoryTemplate' => $data['category_template'],
- 'CachedItemTemplate' => $data['item_template'],
);
$i = 1;
@@ -325,22 +324,13 @@
$fields_hash['CategoryTemplate'] = $record['CategoryTemplate'];
}
- if (!$record['ItemTemplate']) {
- $record['ItemTemplate'] = $this->Application->ConfigValue($root_prefix.'_ItemTemplate');
- $fields_hash['ItemTemplate'] = $record['ItemTemplate'];
- }
-
$this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Category', 'CategoryId = '.$category_id);
}
// if explicitly set, then use it; use parent template otherwise
if ($record['CategoryTemplate']) {
$data['category_template'] = $record['CategoryTemplate'];
}
-
- if ($record['ItemTemplate']) {
- $data['item_template'] = $record['ItemTemplate'];
- }
}
}
Index: branches/unlabeled/unlabeled-1.106.2/admin/install.php
===================================================================
diff -u -r5970 -r6015
--- branches/unlabeled/unlabeled-1.106.2/admin/install.php (.../install.php) (revision 5970)
+++ branches/unlabeled/unlabeled-1.106.2/admin/install.php (.../install.php) (revision 6015)
@@ -560,8 +560,8 @@
$filename = $pathtoroot.$mod_path."/admin/install/upgrades/$file";
if(file_exists($filename))
{
- include($filename);
- if($result&2)break;
+ include($filename);
+ if( $result & 2 ) break;
}
}
}
@@ -686,6 +686,8 @@
{
$filename = $pathtoroot.$mod_path."/admin/install/upgrades/$file";
//echo "Running: $filename
";
+
+ // SQL is processed FIRST (before corresponding PHP according to the sorting order in VersionSort()
if( file_exists($filename) )
{
if($tmp_extension == 'sql')
Index: branches/unlabeled/unlabeled-1.50.2/kernel/units/categories/categories_config.php
===================================================================
diff -u -r5970 -r6015
--- branches/unlabeled/unlabeled-1.50.2/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 5970)
+++ branches/unlabeled/unlabeled-1.50.2/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 6015)
@@ -266,9 +266,7 @@
'Modified' => Array('type' => 'int', 'formatter' => 'kDateFormatter', 'not_null' => 1,'default' => '#NOW#'),
'ModifiedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'options' => Array(-1 => 'root', -2 => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'not_null' => 1,'default' => '0'),
'CategoryTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
- 'ItemTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
'CachedCategoryTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
- 'CachedItemTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
),
'VirtualFields' => Array(
Index: branches/unlabeled/unlabeled-1.4.2/admin/install/upgrades/inportal_upgrade_v1.2.1.php
===================================================================
diff -u -r5733 -r6015
--- branches/unlabeled/unlabeled-1.4.2/admin/install/upgrades/inportal_upgrade_v1.2.1.php (.../inportal_upgrade_v1.2.1.php) (revision 5733)
+++ branches/unlabeled/unlabeled-1.4.2/admin/install/upgrades/inportal_upgrade_v1.2.1.php (.../inportal_upgrade_v1.2.1.php) (revision 6015)
@@ -8,4 +8,36 @@
$sql = 'UPDATE '.$table_name.'
SET '.$ml_formatter->LangFieldName('Name').' = Name, '.$ml_formatter->LangFieldName('Description').' = Description';
$application->Conn->Query($sql);
+
+ // locating possible duplicate records in CategoryItems
+ $query = 'SELECT CategoryId, ItemResourceId, COUNT(*) AS Dups
+ FROM '.TABLE_PREFIX.'CategoryItems
+ GROUP BY CategoryId, ItemResourceId
+ HAVING Dups > 1';
+
+ $dups = $application->Conn->Query($query);
+
+ // removing duplicate records
+ foreach ($dups as $a_dup) {
+ $query = 'DELETE FROM '.TABLE_PREFIX.'CategoryItems
+ WHERE
+ CategoryId = '.$query['CategoryId'].'
+ AND
+ ItemResourceId = '.$query['ItemResourceId'].'
+ LIMIT '.($query['Dups'] - 1);
+ $application->Conn->Query($query);
+
+ }
+
+ // creating unique index
+ $queries[] = 'ALTER TABLE `'.TABLE_PREFIX.'CategoryItems` DROP INDEX `CategoryId` ';
+ $queries[] = 'ALTER TABLE `'.TABLE_PREFIX.'CategoryItems` DROP INDEX `ItemResourceId` ';
+ $queries[] = 'ALTER TABLE `'.TABLE_PREFIX.'CategoryItems` ADD UNIQUE ( `CategoryId` , `ItemResourceId` )';
+ $queries[] = 'ALTER TABLE `'.TABLE_PREFIX.'CategoryItems` ADD INDEX ( `Filename` ) ';
+ $queries[] = 'ALTER TABLE `'.TABLE_PREFIX.'CategoryItems` ADD INDEX ( `ItemPrefix` ) ';
+
+ foreach ($queries as $query) {
+ $application->Conn->Query($query);
+ }
+
?>
\ No newline at end of file
Index: branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php
===================================================================
diff -u -r5715 -r6015
--- branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 5715)
+++ branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 6015)
@@ -268,7 +268,7 @@
$live_object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('live_table' => true, 'skip_autoload' => true));
$live_object->Load($id);
- $cached_fields = Array('Name', 'Filename', 'CategoryTemplate', 'ItemTemplate');
+ $cached_fields = Array('Name', 'Filename', 'CategoryTemplate');
foreach ($cached_fields as $cached_field) {
if ($live_object->GetDBField($cached_field) != $temp_object->GetDBField($cached_field)) {
Index: branches/unlabeled/unlabeled-1.2.2/core/admin_templates/categories/categories_edit.tpl
===================================================================
diff -u -r5551 -r6015
--- branches/unlabeled/unlabeled-1.2.2/core/admin_templates/categories/categories_edit.tpl (.../categories_edit.tpl) (revision 5551)
+++ branches/unlabeled/unlabeled-1.2.2/core/admin_templates/categories/categories_edit.tpl (.../categories_edit.tpl) (revision 6015)
@@ -6,7 +6,7 @@
-
+
@@ -24,9 +24,9 @@
submit_event('c','OnCancel');
}
) );
-
+
a_toolbar.AddButton( new ToolBarSeparator('sep1') );
-
+
a_toolbar.AddButton( new ToolBarButton('prev', '', function() {
go_to_id('c', '');
}
@@ -35,21 +35,21 @@
go_to_id('c', '');
}
) );
-
+
a_toolbar.Render();
-
+
a_toolbar.HideButton('prev');
a_toolbar.HideButton('next');
a_toolbar.HideButton('sep1');
-
+
a_toolbar.DisableButton('next');
a_toolbar.DisableButton('prev');
-
+
@@ -58,15 +58,14 @@
-
+
-
-
+
@@ -75,8 +74,8 @@
-
-
+
+