From f847efde6c8960e5204a64b52f6803cb4d3b15bf Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 11 Feb 2005 17:53:32 +0000 Subject: [PATCH] merged thread and post templates and got rid of preview template --- docs/upgrades/upgrade_6.2.11-6.3.0.pl | 27 +++++++++++++++++++++++--- docs/upgrades/upgrade_6.2.11-6.3.0.sql | 3 +++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/docs/upgrades/upgrade_6.2.11-6.3.0.pl b/docs/upgrades/upgrade_6.2.11-6.3.0.pl index cd7587466..b55715496 100644 --- a/docs/upgrades/upgrade_6.2.11-6.3.0.pl +++ b/docs/upgrades/upgrade_6.2.11-6.3.0.pl @@ -23,6 +23,30 @@ GetOptions( WebGUI::Session::open("../..",$configFile); +print "\tMerging Forum/Post and Forum/Thread templates.\n" unless ($quiet); +my %threadTemplates; +my $forums = WebGUI::SQL->read("select forumId, threadTemplateId, postTemplateId from forum where threadTemplateId<>'1' and postTemplateId<>'1'"); +while (my ($forumId, $threadTemplateId, $postTemplateId) = $forums->array) { + my $key = "Thread ".$threadTemplateId." | ".$postTemplateId; + unless (exists $threadTemplates{$key}) { + my ($threadTemplate) = WebGUI::SQL->quickArray("select template from template where namepsace='Forum/Thread' and templateId=".quote($threadTemplateId)); + my ($postTemplate) = WebGUI::SQL->quickArray("select template from template where namespace='Forum/Post' and templateId=".quote($postTemplateId)); + $threadTemplate =~ s/\/$postTemplate/ixsg; + $threadTemplates{$key} = $threadTemplate; + } +} +$forums->finish; +my ($defaultThreadTemplate) = WebGUI::SQL->quickArray("select template from template where namespace='Forum/Thread' and templateId='1'"); +my ($defaultPostTemplate) = WebGUI::SQL->quickArray("select template from template where namespace='Forum/Post' and templateId='1'"); +$defaultThreadTemplate =~ s/\/$defaultPostTemplate/ixsg; +WebGUI::SQL->write("update template set template=".quote($defaultThreadTemplate)." where namespace='Forum/Thread' and templateId='1'"); +WebGUI::SQL->write("delete from template where namespace='Forum/Post' or (namespace='Forum/Thread' and templateId<>'1')"); +foreach my $key (%threadTemplates) { + WebGUI::SQL::write("insert into template (templateId, namespace, template, name) values (".quote(WebGUI::Id::generate()).", 'Forum/Thread', + ".quote($threadTemplates{$key}).", ".quote($key).")"); +} + + print "\tFixing navigation template variables.\n" unless ($quiet); my $sth = WebGUI::SQL->read("select * from template where namespace in ('Navigation')"); while (my $data = $sth->hashRef) { @@ -1209,9 +1233,6 @@ sub getNewId { 'Auth/WebGUI/Account' => { '1' => 'PBtmpl0000000000000010' }, - 'Forum/PostPreview' => { - '1' => 'PBtmpl0000000000000030' - }, 'MessageBoard' => { '1' => 'PBtmpl0000000000000047' }, diff --git a/docs/upgrades/upgrade_6.2.11-6.3.0.sql b/docs/upgrades/upgrade_6.2.11-6.3.0.sql index 9cbc09f58..88002e313 100644 --- a/docs/upgrades/upgrade_6.2.11-6.3.0.sql +++ b/docs/upgrades/upgrade_6.2.11-6.3.0.sql @@ -322,3 +322,6 @@ create table Post_read ( userId varchar(22) not null, readDate bigint ); + +delete from template where namespace='Forum/PostPreview'; +