merge to 10219

This commit is contained in:
Colin Kuskie 2009-04-08 16:35:31 +00:00
parent ae28bf79c8
commit 4c1307e3d0
194 changed files with 8203 additions and 2134 deletions

View file

@ -60,21 +60,19 @@ sub addPackage {
# Import the package into the import node
my $package = WebGUI::Asset->getImportNode($session)->importPackage( $storage );
# Make the package not a package anymore
$package->update({ isPackage => 0 });
# Set the default flag for templates added
my $assetIds
= $package->getLineage( ['self','descendants'], {
includeOnlyClasses => [ 'WebGUI::Asset::Template' ],
} );
# Turn off the package flag, and set the default flag for templates added
my $assetIds = $package->getLineage( ['self','descendants'] );
for my $assetId ( @{ $assetIds } ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
if ( !$asset ) {
print "Couldn't instantiate asset with ID '$assetId'. Please check package '$file' for corruption.\n";
next;
}
$asset->update( { isDefault => 1 } );
my $properties = { isPackage => 0 };
if ($asset->isa('WebGUI::Asset::Template')) {
$properties->{isDefault} = 1;
}
$asset->update( $properties );
}
return;

Binary file not shown.

Binary file not shown.

View file

@ -32,17 +32,14 @@ my $quiet; # this line required
my $session = start(); # this line required
# upgrade functions go here
addAccountActivationTemplateToSettings( $session );
addGroupToAddToMatrix( $session );
addScreenshotTemplatesToMatrix( $session );
surveyDoAfterTimeLimit($session);
surveyRemoveResponseTemplate($session);
surveyEndWorkflow($session);
installAssetHistory($session);
# Story Manager
installStoryManagerTables($session);
sm_upgradeConfigFiles($session);
sm_updateDailyWorkflow($session);
addMinimumCartCheckoutSetting( $session );
# Passive Analytics
pa_installLoggingTables($session);
@ -58,6 +55,16 @@ createShopAcccountPluginSettings( $session );
finish($session); # this line required
#----------------------------------------------------------------------------
sub addAccountActivationTemplateToSettings {
my $session = shift;
print "\tAdding account activation template to settings \n" unless $quiet;
$session->db->write("insert into settings (name, value) values ('webguiAccountActivationTemplate','PBtmpl0000000000000016')");
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub addGroupToAddToMatrix {
my $session = shift;
@ -115,7 +122,7 @@ sub installAssetHistory {
print "\tAdding Asset History content handler... \n" unless $quiet;
##Content Handler
my $contentHandlers = $session->config->get('contentHandlers');
if (! isIn('WebGUI::Content::Handler', @{ $contentHandlers }) ) {
if (! isIn('WebGUI::Content::AssetHistory', @{ $contentHandlers }) ) {
my @newHandlers = ();
foreach my $handler (@{ $contentHandlers }) {
push @newHandlers, $handler;
@ -307,13 +314,23 @@ sub addTransactionItemFlags {
#----------------------------------------------------------------------------
sub createShopAcccountPluginSettings {
my $session = shift;
print "Creating default settings for the account plugin..." unless $quiet;
print "\tCreating default settings for the account plugin..." unless $quiet;
$session->setting->add('shopMySalesTemplateId', '-zxyB-O50W8YnL39Ouoc4Q');
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub addMinimumCartCheckoutSetting {
my $session = shift;
print "\tAdding setting for minimum cart checkout..." unless $quiet;
$session->setting->add( 'shopCartCheckoutMinimum', '0.00' );
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {
@ -323,97 +340,6 @@ sub createShopAcccountPluginSettings {
# print "DONE!\n" unless $quiet;
#}
sub installStoryManagerTables {
my ($session) = @_;
print "\tAdding Story Manager tables... " unless $quiet;
my $db = $session->db;
$db->write(<<EOSTORY);
CREATE TABLE Story (
assetId CHAR(22) BINARY NOT NULL,
revisionDate BIGINT NOT NULL,
headline CHAR(255),
subtitle CHAR(255),
byline CHAR(255),
location CHAR(255),
highlights TEXT,
story MEDIUMTEXT,
photo LONGTEXT,
PRIMARY KEY ( assetId, revisionDate )
)
EOSTORY
$db->write(<<EOARCHIVE);
CREATE TABLE StoryArchive (
assetId CHAR(22) BINARY NOT NULL,
revisionDate BIGINT NOT NULL,
storiesPerFeed INTEGER,
storiesPerPage INTEGER,
groupToPost CHAR(22) BINARY,
templateId CHAR(22) BINARY,
storyTemplateId CHAR(22) BINARY,
editStoryTemplateId CHAR(22) BINARY,
archiveAfter INT(11),
richEditorId CHAR(22) BINARY,
approvalWorkflowId CHAR(22) BINARY DEFAULT 'pbworkflow000000000003',
PRIMARY KEY ( assetId, revisionDate )
)
EOARCHIVE
$db->write(<<EOTOPIC);
CREATE TABLE StoryTopic (
assetId CHAR(22) BINARY NOT NULL,
revisionDate BIGINT NOT NULL,
storiesPer INTEGER,
storiesShort INTEGER,
templateId CHAR(22) BINARY,
storyTemplateId CHAR(22) BINARY,
PRIMARY KEY ( assetId, revisionDate )
)
EOTOPIC
print "DONE!\n" unless $quiet;
}
sub sm_upgradeConfigFiles {
my ($session) = @_;
print "\tAdding Story Manager to config file... " unless $quiet;
my $config = $session->config;
$config->addToHash(
'assets',
'WebGUI::Asset::Wobject::StoryTopic' => {
'category' => 'community'
},
);
$config->addToHash(
'assets',
"WebGUI::Asset::Wobject::StoryArchive" => {
"isContainer" => 1,
"category" => "community"
},
);
my $activities = $config->get('workflowActivities');
my $none = $activities->{None};
if (!isIn('WebGUI::Workflow::Activity::ArchiveOldStories', @{ $none })) {
unshift @{ $none }, 'WebGUI::Workflow::Activity::ArchiveOldStories';
}
$config->set('workflowActivities', $activities);
print "DONE!\n" unless $quiet;
}
sub sm_updateDailyWorkflow {
my ($session) = @_;
print "\tAdding Archive Old Stories to Daily Workflow... " unless $quiet;
my $workflow = WebGUI::Workflow->new($session, 'pbworkflow000000000001');
foreach my $activity (@{ $workflow->getActivities }) {
return if $activity->getName() eq 'WebGUI::Workflow::Activity::ArchiveOldStories';
}
my $activity = $workflow->addActivity('WebGUI::Workflow::Activity::ArchiveOldStories');
$activity->set('title', 'Archive Old Stories');
$activity->set('description', 'Archive old stories, based on the settings of the Story Archives that own them');
print "DONE!\n" unless $quiet;
}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------

View file

@ -0,0 +1,237 @@
#!/usr/bin/env perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "../..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Getopt::Long;
use WebGUI::Session;
use WebGUI::Storage;
use WebGUI::Asset;
my $toVersion = '7.7.1';
my $quiet; # this line required
my $session = start(); # this line required
# upgrade functions go here
adSkuInstall($session);
addWelcomeMessageTemplateToSettings( $session );
addStatisticsCacheTimeoutToMatrix( $session );
removeOldSettings( $session );
#add Survey table
addSurveyQuestionTypes($session);
# image mods
addImageAnnotation($session);
# rss mods
addRssLimit($session);
finish($session); # this line required
# remove old settings that aren't used any more
sub removeOldSettings {
my $session = shift;
print "\tRemoving old, unused settings... " unless $quiet;
my $setting = $session->setting;
$setting->remove('commerceCheckoutCanceledTemplateId');
$setting->remove('commerceConfirmCheckoutTemplateId');
$setting->remove('commerceEnableSalesTax');
$setting->remove('commercePaymentPlugin');
$setting->remove('commercePurchaseHistoryTemplateId');
$setting->remove('commerceSelectPaymentGatewayTemplateId');
$setting->remove('commerceSelectShippingMethodTemplateId');
$setting->remove('commerceSendDailyReportTo');
$setting->remove('commerceViewShoppingCartTemplateId');
print "Done.\n" unless $quiet;
}
sub addSurveyQuestionTypes{
my $session = shift;
print "\tAdding new survey table Survey_questionTypes... " unless $quiet;
$session->db->write("
CREATE TABLE `Survey_questionTypes` (
`questionType` varchar(56) NOT NULL,
`answers` text NOT NULL,
PRIMARY KEY (`questionType`))
");
$session->db->write(q{
INSERT INTO `Survey_questionTypes` VALUES ('Scale',''),('Gender','Male,Female'),('Education','Elementary or some high school,High school/GED,Some college/vocational school,College graduate,Some graduate work,Master\\'s degree,Doctorate (of any type),Other degree (verbatim)'),('Importance','Not at all important,,,,,,,,,,Extremely important'),('Yes/No','Yes,No'),('Confidence','Not at all confident,,,,,,,,,,Extremely confident'),('Effectiveness','Not at all effective,,,,,,,,,,Extremely effective'),('Oppose/Support','Strongly oppose,,,,,,Strongly support'),('Certainty','Not at all certain,,,,,,,,,,Extremely certain'),('True/False','True,False'),('Concern','Not at all concerned,,,,,,,,,,Extremely concerned'),('Ideology','Strongly liberal,Liberal,Somewhat liberal,Middle of the road,Slightly conservative,Conservative,Strongly conservative'),('Security','Not at all secure,,,,,,,,,,Extremely secure'),('Risk','No risk,,,,,,,,,,Extreme risk'),('Agree/Disagree','Strongly disagree,,,,,,Strongly agree'),('Race','American Indian,Asian,Black,Hispanic,White non-Hispanic,Something else (verbatim)'),('Threat','No threat,,,,,,,,,,Extreme threat'),('Party','Democratic party,Republican party (or GOP),Independent party,Other party (verbatim)'),('Likelihood','Not at all likely,,,,,,,,,,Extremely likely'),('Multiple Choice',''),('Satisfaction','Not at all satisfied,,,,,,,,,,Extremely satisfied')
});
print "Done.\n" unless $quiet;
}
sub addWelcomeMessageTemplateToSettings {
my $session = shift;
print "\tAdding welcome message template to settings... " unless $quiet;
$session->db->write("insert into settings values ('webguiWelcomeMessageTemplate', 'PBtmpl0000000000000015');");
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub addRssLimit {
my $session = shift;
print "\tAdding rssLimit to RSSCapable table, if needed... " unless $quiet;
my $sth = $session->db->read('describe RSSCapable rssCapableRssLimit');
if (! defined $sth->hashRef) {
$session->db->write("alter table RSSCapable add column rssCapableRssLimit integer");
}
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub addImageAnnotation {
my $session = shift;
print "\tAdding annotations to ImageAsset table, if needed... " unless $quiet;
my $sth = $session->db->read('describe ImageAsset annotations');
if (! defined $sth->hashRef) {
$session->db->write("alter table ImageAsset add column annotations mediumtext");
}
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub addStatisticsCacheTimeoutToMatrix{
my $session = shift;
print "\tAdding statisticsCacheTimeout setting to Matrix table... " unless $quiet;
$session->db->write("alter table Matrix add statisticsCacheTimeout int(11) not null default 3600");
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
# Describe what our function does
sub adSkuInstall {
my $session = shift;
print "\tInstalling the AdSku Asset...\n" unless $quiet;
print "\t\tCreate AdSku database table.\n" unless $quiet;
$session->db->write("CREATE TABLE AdSku (
assetId VARCHAR(22) BINARY NOT NULL,
revisionDate BIGINT NOT NULL,
purchaseTemplate VARCHAR(22) BINARY NOT NULL,
manageTemplate VARCHAR(22) BINARY NOT NULL,
adSpace VARCHAR(22) BINARY NOT NULL,
priority INTEGER DEFAULT '1',
pricePerClick Float DEFAULT '0',
pricePerImpression Float DEFAULT '0',
clickDiscounts VARCHAR(1024) default '',
impressionDiscounts VARCHAR(1024) default '',
PRIMARY KEY (assetId,revisionDate)
)");
print "\t\tCreate Adsku crud table.\n" unless $quiet;
use WebGUI::AssetCollateral::Sku::Ad::Ad;
WebGUI::AssetCollateral::Sku::Ad::Ad->crud_createTable($session);
print "\t\tAdding to config file.\n" unless $quiet;
$session->config->addToHash("assets", 'WebGUI::Asset::Sku::Ad' => { category => 'shop' } );
print "\tDone.\n" unless $quiet;
}
#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {
# my $session = shift;
# print "\tWe're doing some stuff here that you should know about... " unless $quiet;
# # and here's our code
# print "DONE!\n" unless $quiet;
#}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
#----------------------------------------------------------------------------
# Add a package to the import node
sub addPackage {
my $session = shift;
my $file = shift;
# Make a storage location for the package
my $storage = WebGUI::Storage->createTemp( $session );
$storage->addFileFromFilesystem( $file );
# Import the package into the import node
my $package = WebGUI::Asset->getImportNode($session)->importPackage( $storage );
# Make the package not a package anymore
$package->update({ isPackage => 0 });
# Set the default flag for templates added
my $assetIds
= $package->getLineage( ['self','descendants'], {
includeOnlyClasses => [ 'WebGUI::Asset::Template' ],
} );
for my $assetId ( @{ $assetIds } ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
if ( !$asset ) {
print "Couldn't instantiate asset with ID '$assetId'. Please check package '$file' for corruption.\n";
next;
}
$asset->update( { isDefault => 1 } );
}
return;
}
#-------------------------------------------------
sub start {
my $configFile;
$|=1; #disable output buffering
GetOptions(
'configFile=s'=>\$configFile,
'quiet'=>\$quiet
);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
$session->user({userId=>3});
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Upgrade to ".$toVersion});
return $session;
}
#-------------------------------------------------
sub finish {
my $session = shift;
updateTemplates($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->commit;
$session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".$session->datetime->time().")");
$session->close();
}
#-------------------------------------------------
sub updateTemplates {
my $session = shift;
return undef unless (-d "packages-".$toVersion);
print "\tUpdating packages.\n" unless ($quiet);
opendir(DIR,"packages-".$toVersion);
my @files = readdir(DIR);
closedir(DIR);
my $newFolder = undef;
foreach my $file (@files) {
next unless ($file =~ /\.wgpkg$/);
# Fix the filename to include a path
$file = "packages-" . $toVersion . "/" . $file;
addPackage( $session, $file );
}
}
#vim:ft=perl

View file

@ -0,0 +1,284 @@
#!/usr/bin/env perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "../..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Getopt::Long;
use WebGUI::Session;
use WebGUI::Storage;
use WebGUI::Asset;
use WebGUI::Workflow;
use WebGUI::Utility;
my $toVersion = '7.7.2';
my $quiet; # this line required
my $session = start(); # this line required
# upgrade functions go here
recalculateMatrixListingMedianValue( $session );
addRssFeedAspect($session);
addRssFeedAspectToAssets($session);
convertCollaborationToRssAspect($session);
removeRssCapableAsset($session);
addCreationTimeToCart($session);
addCartKillerActivityToConfig($session);
addCartKillerActivityToWorkflow($session);
finish($session); # this line required
#----------------------------------------------------------------------------
sub recalculateMatrixListingMedianValue{
my $session = shift;
print "\tRecalculating median value for Matrix Listing ratings... " unless $quiet;
my $matrices = WebGUI::Asset->getRoot($session)->getLineage(['descendants'],
{
statesToInclude => ['published','trash','clipboard','clipboard-limbo','trash-limbo'],
statusToInclude => ['pending','approved','deleted','archived'],
includeOnlyClasses => ['WebGUI::Asset::Wobject::Matrix'],
returnObjects => 1,
});
for my $matrix (@{$matrices})
{
next unless defined $matrix;
my %categories = keys %{$matrix->getCategories};
my $listings = $session->db->read("select distinct listingId from MatrixListing_rating where assetId = ?"
,[$matrix->getId]);
while (my $listing= $listings->hashRef){
foreach my $category (%categories) {
my $half = $session->db->quickScalar("select round((select count(*) from MatrixListing_rating where
listingId = ? and category = ?)/2)",[$listing->{listingId},$category]);
my $medianValue = $session->db->quickScalar("select rating from MatrixListing_rating where listingId =?
and category =? order by rating limit $half,1;",[$listing->{listingId},$category]);
$session->db->write("update MatrixListing_ratingSummary set medianValue = ? where listingId = ? and
category = ?",[$medianValue,$listing->{listingId},$category]);
}
}
}
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub addRssFeedAspect {
my $session = shift;
print "\tAdding RssFeed asset aspect..." unless $quiet;
$session->db->write(q{create table assetAspectRssFeed (
assetId char(22) binary not null,
revisionDate bigint not null,
itemsPerFeed int(11) default 25,
feedCopyright text,
feedTitle text,
feedDescription mediumtext,
feedImage char(22) binary,
feedImageLink text,
feedImageDescription mediumtext,
feedHeaderLinks char(32) default 'rss\natom',
primary key (assetId, revisionDate)
)});
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub addRssFeedAspectToAssets {
my $session = shift;
my $db = $session->db;
foreach my $asset_class (qw( WikiMaster SyndicatedContent Gallery GalleryAlbum )) {
print "\tAdding RssFeed aspect to $asset_class table..." unless $quiet;
my $pages = $db->read("select assetId,revisionDate from $asset_class");
while (my ($id, $rev) = $pages->array) {
$db->write("INSERT INTO assetAspectRssFeed (assetId, revisionDate, itemsPerFeed, feedTitle, feedDescription, feedImage, feedImageLink, feedImageDescription) VALUES (?,?,25,'','',NULL,'','')",[$id,$rev]);
}
print "Done.\n" unless $quiet;
}
}
#----------------------------------------------------------------------------
sub convertCollaborationToRssAspect {
my $session = shift;
print "\tAdding RssFeed aspect to Collaboration, (porting rssCapableRssLimit to itemsPerFeed)..." unless $quiet;
my $db = $session->db;
my @rssFromParents;
my $pages = $db->read("SELECT Collaboration.assetId, Collaboration.revisionDate, RSSCapable.rssCapableRssLimit, RSSCapable.rssCapableRssFromParentId, RSSCapable.rssCapableRssEnabled FROM Collaboration INNER JOIN RSSCapable ON Collaboration.assetId=RSSCapable.assetId AND Collaboration.revisionDate=RSSCapable.revisionDate");
while (my ($id, $rev, $limit, $fromParent, $enabled) = $pages->array) {
if ($fromParent) {
push @rssFromParents, $fromParent;
}
my $headerLinks = $enabled ? "rss\natom" : q{};
$db->write("INSERT INTO assetAspectRssFeed (assetId, revisionDate, itemsPerFeed, feedTitle, feedDescription, feedImage, feedImageLink, feedImageDescription, feedHeaderLinks) VALUES (?,?,?,'','',NULL,'','',?)",[$id,$rev,$limit || 25, $headerLinks]);
}
for my $assetId (@rssFromParents) {
my $asset = eval { WebGUI::Asset->newPending($session, $assetId) };
if ($asset) {
$asset->purge;
}
}
$db->write("DELETE FROM RSSCapable WHERE assetId IN (SELECT assetId FROM Collaboration GROUP BY assetId)");
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub removeRssCapableAsset {
my $session = shift;
print "\tChecking for uses of RSSCapable...\n" unless $quiet;
my @rssCapableClasses = $session->db->buildArray('SELECT className FROM RSSCapable INNER JOIN asset ON RSSCapable.assetId=asset.assetId GROUP BY className');
if (@rssCapableClasses) {
warn "\t\tThis site is using the assets\n\t\t\t" . join(', ', @rssCapableClasses) . "\n\t\twhich use the RSSCapable class! Support RSSCapable has been dropped and it will no longer be maintained.\n";
}
else {
print "\t\tNot used, removing.\n" unless $quiet;
$session->db->write("DROP TABLE RSSCapable");
$session->db->write("DROP TABLE RSSFromParent");
my $rssCapableTemplates = WebGUI::Asset->getRoot($session)->getLineage(['descendants'], {
statesToInclude => [qw(published clipboard clipboard-limbo trash-limbo)],
statusToInclude => [qw(approved pending archived)],
returnObjects => 1,
includeOnlyClasses => ['WebGUI::Asset::Template'],
joinClass => 'WebGUI::Asset::Template',
whereClause => q{template.namespace = 'RSSCapable/RSS'},
});
for my $template (@{$rssCapableTemplates}) {
$template->trash;
}
}
print "\tDone.\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub addCreationTimeToCart {
my $session = shift;
print "\tAdding creation time to cart..." unless $quiet;
$session->db->write("alter table cart add column creationDate int(20)");
$session->db->write('update cart set creationDate=NOW()');
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub addCartKillerActivityToConfig {
my $session = shift;
print "\tAdding Remove Old Carts workflow activity to config files..." unless $quiet;
my $activities = $session->config->get('workflowActivities');
my $none = $activities->{'None'};
if (!isIn('WebGUI::Workflow::Activity::RemoveOldCarts', @{ $none })) {
push @{ $none }, 'WebGUI::Workflow::Activity::RemoveOldCarts';
}
$session->config->set('workflowActivities', $activities);
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub addCartKillerActivityToWorkflow {
my $session = shift;
print "\tAdding Remove Old Carts workflow activity to Daily Workflow..." unless $quiet;
my $workflow = WebGUI::Workflow->new($session, 'pbworkflow000000000001');
my $removeCarts = $workflow->addActivity('WebGUI::Workflow::Activity::RemoveOldCarts');
$removeCarts->set('title', 'Remove old carts');
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {
# my $session = shift;
# print "\tWe're doing some stuff here that you should know about... " unless $quiet;
# # and here's our code
# print "DONE!\n" unless $quiet;
#}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
#----------------------------------------------------------------------------
# Add a package to the import node
sub addPackage {
my $session = shift;
my $file = shift;
# Make a storage location for the package
my $storage = WebGUI::Storage->createTemp( $session );
$storage->addFileFromFilesystem( $file );
# Import the package into the import node
my $package = WebGUI::Asset->getImportNode($session)->importPackage( $storage );
# Make the package not a package anymore
$package->update({ isPackage => 0 });
# Set the default flag for templates added
my $assetIds
= $package->getLineage( ['self','descendants'], {
includeOnlyClasses => [ 'WebGUI::Asset::Template' ],
} );
for my $assetId ( @{ $assetIds } ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
if ( !$asset ) {
print "Couldn't instantiate asset with ID '$assetId'. Please check package '$file' for corruption.\n";
next;
}
$asset->update( { isDefault => 1 } );
}
return;
}
#-------------------------------------------------
sub start {
my $configFile;
$|=1; #disable output buffering
GetOptions(
'configFile=s'=>\$configFile,
'quiet'=>\$quiet
);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
$session->user({userId=>3});
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Upgrade to ".$toVersion});
return $session;
}
#-------------------------------------------------
sub finish {
my $session = shift;
updateTemplates($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->commit;
$session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".$session->datetime->time().")");
$session->close();
}
#-------------------------------------------------
sub updateTemplates {
my $session = shift;
return undef unless (-d "packages-".$toVersion);
print "\tUpdating packages.\n" unless ($quiet);
opendir(DIR,"packages-".$toVersion);
my @files = readdir(DIR);
closedir(DIR);
my $newFolder = undef;
foreach my $file (@files) {
next unless ($file =~ /\.wgpkg$/);
# Fix the filename to include a path
$file = "packages-" . $toVersion . "/" . $file;
addPackage( $session, $file );
}
}
#vim:ft=perl

View file

@ -0,0 +1,240 @@
#!/usr/bin/env perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "../..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Getopt::Long;
use WebGUI::Session;
use WebGUI::Storage;
use WebGUI::Asset;
use WebGUI::Utility;
my $toVersion = '7.7.3';
my $quiet; # this line required
my $session = start(); # this line required
# upgrade functions go here
addSurveyQuizModeColumns($session);
addSurveyExpressionEngineConfigFlag($session);
# Story Manager
installStoryManagerTables($session);
sm_upgradeConfigFiles($session);
sm_updateDailyWorkflow($session);
finish($session); # this line required
#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {
# my $session = shift;
# print "\tWe're doing some stuff here that you should know about... " unless $quiet;
# # and here's our code
# print "DONE!\n" unless $quiet;
#}
sub addSurveyQuizModeColumns{
my $session = shift;
print "\tAdding columns to Survey table... " unless $quiet;
$session->db->write("alter table Survey add column `quizModeSummary` TINYINT(3)");
$session->db->write("alter table Survey add column `surveySummaryTemplateId` char(22)");
print "Done.\n" unless $quiet;
}
sub addSurveyExpressionEngineConfigFlag{
my $session = shift;
print "\tAdding enableSurveyExpressionEngine config option... " unless $quiet;
$session->config->set('enableSurveyExpressionEngine', 0);
print "Done.\n" unless $quiet;
}
sub installStoryManagerTables {
my ($session) = @_;
print "\tAdding Story Manager tables... " unless $quiet;
my $db = $session->db;
$db->write(<<EOSTORY);
CREATE TABLE Story (
assetId CHAR(22) BINARY NOT NULL,
revisionDate BIGINT NOT NULL,
headline CHAR(255),
subtitle CHAR(255),
byline CHAR(255),
location CHAR(255),
highlights TEXT,
story MEDIUMTEXT,
photo LONGTEXT,
PRIMARY KEY ( assetId, revisionDate )
)
EOSTORY
$db->write(<<EOARCHIVE);
CREATE TABLE StoryArchive (
assetId CHAR(22) BINARY NOT NULL,
revisionDate BIGINT NOT NULL,
storiesPerFeed INTEGER,
storiesPerPage INTEGER,
groupToPost CHAR(22) BINARY,
templateId CHAR(22) BINARY,
storyTemplateId CHAR(22) BINARY,
editStoryTemplateId CHAR(22) BINARY,
archiveAfter INT(11),
richEditorId CHAR(22) BINARY,
approvalWorkflowId CHAR(22) BINARY DEFAULT 'pbworkflow000000000003',
PRIMARY KEY ( assetId, revisionDate )
)
EOARCHIVE
$db->write(<<EOTOPIC);
CREATE TABLE StoryTopic (
assetId CHAR(22) BINARY NOT NULL,
revisionDate BIGINT NOT NULL,
storiesPer INTEGER,
storiesShort INTEGER,
templateId CHAR(22) BINARY,
storyTemplateId CHAR(22) BINARY,
PRIMARY KEY ( assetId, revisionDate )
)
EOTOPIC
print "DONE!\n" unless $quiet;
}
sub sm_upgradeConfigFiles {
my ($session) = @_;
print "\tAdding Story Manager to config file... " unless $quiet;
my $config = $session->config;
$config->addToHash(
'assets',
'WebGUI::Asset::Wobject::StoryTopic' => {
'category' => 'community'
},
);
$config->addToHash(
'assets',
"WebGUI::Asset::Wobject::StoryArchive" => {
"isContainer" => 1,
"category" => "community"
},
);
my $activities = $config->get('workflowActivities');
my $none = $activities->{None};
if (!isIn('WebGUI::Workflow::Activity::ArchiveOldStories', @{ $none })) {
unshift @{ $none }, 'WebGUI::Workflow::Activity::ArchiveOldStories';
}
$config->set('workflowActivities', $activities);
print "DONE!\n" unless $quiet;
}
sub sm_updateDailyWorkflow {
my ($session) = @_;
print "\tAdding Archive Old Stories to Daily Workflow... " unless $quiet;
my $workflow = WebGUI::Workflow->new($session, 'pbworkflow000000000001');
foreach my $activity (@{ $workflow->getActivities }) {
return if $activity->getName() eq 'WebGUI::Workflow::Activity::ArchiveOldStories';
}
my $activity = $workflow->addActivity('WebGUI::Workflow::Activity::ArchiveOldStories');
$activity->set('title', 'Archive Old Stories');
$activity->set('description', 'Archive old stories, based on the settings of the Story Archives that own them');
print "DONE!\n" unless $quiet;
}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
#----------------------------------------------------------------------------
# Add a package to the import node
sub addPackage {
my $session = shift;
my $file = shift;
# Make a storage location for the package
my $storage = WebGUI::Storage->createTemp( $session );
$storage->addFileFromFilesystem( $file );
# Import the package into the import node
my $package = WebGUI::Asset->getImportNode($session)->importPackage( $storage );
# Make the package not a package anymore
$package->update({ isPackage => 0 });
# Set the default flag for templates added
my $assetIds
= $package->getLineage( ['self','descendants'], {
includeOnlyClasses => [ 'WebGUI::Asset::Template' ],
} );
for my $assetId ( @{ $assetIds } ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
if ( !$asset ) {
print "Couldn't instantiate asset with ID '$assetId'. Please check package '$file' for corruption.\n";
next;
}
$asset->update( { isDefault => 1 } );
}
return;
}
#-------------------------------------------------
sub start {
my $configFile;
$|=1; #disable output buffering
GetOptions(
'configFile=s'=>\$configFile,
'quiet'=>\$quiet
);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
$session->user({userId=>3});
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Upgrade to ".$toVersion});
return $session;
}
#-------------------------------------------------
sub finish {
my $session = shift;
updateTemplates($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->commit;
$session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".$session->datetime->time().")");
$session->close();
}
#-------------------------------------------------
sub updateTemplates {
my $session = shift;
return undef unless (-d "packages-".$toVersion);
print "\tUpdating packages.\n" unless ($quiet);
opendir(DIR,"packages-".$toVersion);
my @files = readdir(DIR);
closedir(DIR);
my $newFolder = undef;
foreach my $file (@files) {
next unless ($file =~ /\.wgpkg$/);
# Fix the filename to include a path
$file = "packages-" . $toVersion . "/" . $file;
addPackage( $session, $file );
}
}
#vim:ft=perl