Merge remote branch 'upstream/WebGUI8' into 8-merge
Conflicts: docs/gotcha.txt docs/previousVersion.sql lib/WebGUI/Asset/Wobject/GalleryAlbum.pm lib/WebGUI/Asset/Wobject/Navigation.pm lib/WebGUI/AssetLineage.pm lib/WebGUI/Config.pm lib/WebGUI/Form/Template.pm lib/WebGUI/Group.pm lib/WebGUI/VersionTag.pm lib/WebGUI/Workflow/Activity/TrashExpiredEvents.pm t/AdSpace.t t/Asset/AssetExportHtml.t t/Asset/AssetLineage.t t/Asset/Story.t t/Asset/Template/HTMLTemplateExpr.t t/Asset/Wobject/Gallery/00base.t t/Asset/Wobject/GalleryAlbum/00base.t t/Asset/Wobject/GalleryAlbum/ajax.t t/Asset/Wobject/InOutBoard.t t/Asset/Wobject/StoryArchive.t t/Asset/Wobject/Survey/ExpressionEngine.t t/Asset/Wobject/Survey/Reports.t t/AssetAspect/RssFeed.t t/Auth/mech.t t/Group.t t/Mail/Send.t t/Operation/AdSpace.t t/Session/ErrorHandler.t t/Session/Scratch.t t/Session/Url.t t/Shop/Cart.t t/Shop/Pay.t t/Shop/Ship.t t/Shop/ShipDriver.t t/Shop/TaxDriver/Generic.t t/Shop/Vendor.t t/VersionTag.t t/lib/WebGUI/Test.pm
This commit is contained in:
commit
708b47d73c
165 changed files with 3199 additions and 5718 deletions
2472
docs/create.sql
2472
docs/create.sql
File diff suppressed because one or more lines are too long
|
|
@ -7,7 +7,6 @@ upgrading from one version to the next, or even between multiple
|
|||
versions. Be sure to heed the warnings contained herein as they will
|
||||
save you many hours of grief.
|
||||
|
||||
<<<<<<< HEAD
|
||||
8.0.0
|
||||
--------------------------------------------------------------------
|
||||
* WebGUI 8 is not API compatible with WebGUI 7. If you have custom
|
||||
|
|
@ -17,11 +16,10 @@ save you many hours of grief.
|
|||
* WebGUI now requires the following modules
|
||||
- Moose
|
||||
- CHI
|
||||
=======
|
||||
|
||||
7.9.8
|
||||
--------------------------------------------------------------------
|
||||
* Starting in WebGUI 7.9.4, the Net::Twitter module is required.
|
||||
>>>>>>> master
|
||||
|
||||
7.9.7
|
||||
--------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ The information contained herein documents the API changes that have occurred in
|
|||
|
||||
|
||||
WebGUI::Config
|
||||
=============
|
||||
==============
|
||||
WebGUI::Config->new has a new API. Its WebGUI root parameter has been eliminated. It now only accepts a config file as either an absolute path, or a path relative to WebGUI's etc directory.
|
||||
|
||||
my $config = WebGUI::Config->new($filename);
|
||||
|
|
@ -14,10 +14,19 @@ my $config = WebGUI::Config->new($filename);
|
|||
|
||||
|
||||
WebGUI::Session
|
||||
=============
|
||||
===============
|
||||
WebGUI::Session->open has a new API. Its WebGUI root parameter has been eliminated. The config file it is given can be either an absolute path, or a path relative to WebGUI's etc directory.
|
||||
|
||||
my $session = WebGUI::Session->open($configFile, $request, $server);
|
||||
my $session = WebGUI::Session->open($configFile);
|
||||
|
||||
perldoc WebGUI::Session for more details about the arguments.
|
||||
|
||||
|
||||
WebGUI::Session::Env
|
||||
====================
|
||||
WebGUI::Session::Env has been moved into WebGUI::Session::Request. A listing of replacements and equivalents follows:
|
||||
|
||||
$session->env->getIp => $session->request->address
|
||||
|
||||
|
||||
|
||||
|
|
@ -174,3 +183,19 @@ Asset API
|
|||
----------
|
||||
->get will still work, but will be slightly slower since inside it calls the direct Moose accessor. Similarly,
|
||||
getId is slightly slower than ->assetId.
|
||||
|
||||
WebGUI::Shop::Vendor
|
||||
====================
|
||||
Object properties are no longer written to the database when an object is created from scratch. The write method needs
|
||||
to be called.
|
||||
|
||||
WebGUI::Shop::AddressBook
|
||||
=========================
|
||||
Since create is now really new, there is no way to create an address book for an arbitrary userId. To work around this,
|
||||
update the address book with the new userId after it has been created.
|
||||
|
||||
WebGUI::Shop::Address
|
||||
=====================
|
||||
Object properties are no longer written to the database when an object is created from scratch. The write method needs
|
||||
to be called.
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,176 +0,0 @@
|
|||
#!/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.9.3';
|
||||
my $quiet; # this line required
|
||||
|
||||
|
||||
my $session = start(); # this line required
|
||||
|
||||
reindexSiteForDefaultSynopsis( $session );
|
||||
addTopLevelWikiKeywords( $session );
|
||||
renameMapPointStateColumn( $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 renameMapPointStateColumn {
|
||||
my $session = shift;
|
||||
print "\tRename the MapPoint column state to region... " unless $quiet;
|
||||
|
||||
$session->db->write('ALTER TABLE MapPoint CHANGE state region char(35)');
|
||||
|
||||
print "Done.\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub addTopLevelWikiKeywords {
|
||||
my $session = shift;
|
||||
print "\tAdding top level keywords page to WikiMaster... " unless $quiet;
|
||||
|
||||
my $sth = $session->db->read('DESCRIBE `WikiMaster`');
|
||||
while (my ($col) = $sth->array) {
|
||||
if ($col eq 'topLevelKeywords') {
|
||||
print "Skipped.\n" unless $quiet;
|
||||
return;
|
||||
}
|
||||
}
|
||||
$session->db->write('ALTER TABLE WikiMaster ADD COLUMN topLevelKeywords LONGTEXT');
|
||||
|
||||
print "Done.\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Reindex the site to clear out default synopsis
|
||||
sub reindexSiteForDefaultSynopsis {
|
||||
my $session = shift;
|
||||
print "\tRe-indexing site to clear out default synopses... " unless $quiet;
|
||||
|
||||
my $rs = $session->db->read("select assetId, className from asset where state='published'");
|
||||
my @searchableAssetIds;
|
||||
while (my ($id, $class) = $rs->array) {
|
||||
my $asset = WebGUI::Asset->new($session,$id,$class);
|
||||
if (defined $asset && $asset->get("state") eq "published" && ($asset->get("status") eq "approved" || $asset->get("status") eq "archived")) {
|
||||
$asset->indexContent;
|
||||
push (@searchableAssetIds, $id);
|
||||
}
|
||||
}
|
||||
|
||||
# delete indexes of assets that are no longer searchable
|
||||
my $list = $session->db->quoteAndJoin(\@searchableAssetIds) if scalar(@searchableAssetIds);
|
||||
$session->db->write("delete from assetIndex where assetId not in (".$list.")") if $list;
|
||||
|
||||
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;
|
||||
|
||||
print "\tUpgrading package $file\n" unless $quiet;
|
||||
# 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 = eval {
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
$node->importPackage( $storage, {
|
||||
overwriteLatest => 1,
|
||||
clearPackageFlag => 1,
|
||||
setDefaultTemplate => 1,
|
||||
} );
|
||||
};
|
||||
|
||||
if ($package eq 'corrupt') {
|
||||
die "Corrupt package found in $file. Stopping upgrade.\n";
|
||||
}
|
||||
if ($@ || !defined $package) {
|
||||
die "Error during package import on $file: $@\nStopping upgrade\n.";
|
||||
}
|
||||
|
||||
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',".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
|
||||
|
|
@ -1,267 +0,0 @@
|
|||
#!/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::Asset::WikiPage;
|
||||
use WebGUI::Exception;
|
||||
use WebGUI::Shop::Pay;
|
||||
|
||||
|
||||
my $toVersion = '7.9.4';
|
||||
my $quiet; # this line required
|
||||
|
||||
|
||||
my $session = start(); # this line required
|
||||
|
||||
# upgrade functions go here
|
||||
addWikiSubKeywords($session);
|
||||
addSynopsistoEachWikiPage($session);
|
||||
dropVisitorAddressBooks($session);
|
||||
alterCartTable($session);
|
||||
alterAddressBookTable($session);
|
||||
addWizardHandler( $session );
|
||||
addTemplateExampleImage( $session );
|
||||
addPayDriverTemplates( $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;
|
||||
#}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Add example images to templates
|
||||
sub addTemplateExampleImage {
|
||||
my $session = shift;
|
||||
print "\tAdding example image field to template... " unless $quiet;
|
||||
|
||||
$session->db->write( q{
|
||||
ALTER TABLE template ADD storageIdExample CHAR(22)
|
||||
} );
|
||||
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
sub addWizardHandler {
|
||||
my ( $sesssion ) = @_;
|
||||
print "\tAdding WebGUI::Wizard... " unless $quiet;
|
||||
|
||||
if ( !grep { $_ eq 'WebGUI::Content::Wizard' } @{$session->config->get('contentHandlers')} ) {
|
||||
# Find the place of Operation and add before
|
||||
my @handlers = ();
|
||||
for my $handler ( @{$session->config->get('contentHandlers')} ) {
|
||||
if ( $handler eq 'WebGUI::Content::Operation' ) {
|
||||
push @handlers, 'WebGUI::Content::Wizard';
|
||||
}
|
||||
push @handlers, $handler;
|
||||
}
|
||||
$session->config->set('contentHandlers',\@handlers);
|
||||
}
|
||||
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub addWikiSubKeywords {
|
||||
my $session = shift;
|
||||
print "\tAdd the WikiMaster sub-keywords table... " unless $quiet;
|
||||
# and here's our code
|
||||
$session->db->write(<<EOSQL);
|
||||
CREATE TABLE IF NOT EXISTS WikiMasterKeywords (
|
||||
assetId CHAR(22) binary not null,
|
||||
keyword CHAR(64) not null,
|
||||
subKeyword CHAR(64),
|
||||
PRIMARY KEY (`assetId`,`keyword`, `subKeyword`),
|
||||
KEY `assetId` (`assetId`),
|
||||
KEY `keyword` (`keyword`),
|
||||
KEY `subKeyword` (`subKeyword`)
|
||||
)
|
||||
EOSQL
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub addSynopsistoEachWikiPage {
|
||||
my $session = shift;
|
||||
print "\tAdd a synopsis to each wiki page this may take a while... " unless $quiet;
|
||||
my $pager = WebGUI::Asset::WikiPage->getIsa($session);
|
||||
PAGE: while (1) {
|
||||
my $page = eval {$pager->()};
|
||||
next PAGE if Exception::Class->caught();
|
||||
last PAGE unless $page;
|
||||
my ($synopsis) = $page->getSynopsisAndContent(undef, $page->get('content'));
|
||||
$page->update({synopsis => $synopsis});
|
||||
}
|
||||
# and here's our code
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub dropVisitorAddressBooks {
|
||||
my $session = shift;
|
||||
print "\tDrop AddressBooks owned by Visitor... " unless $quiet;
|
||||
my $sth = $session->db->read(q|SELECT addressBookId FROM addressBook where userId='1'|);
|
||||
BOOK: while (my ($addressBookId) = $sth->array) {
|
||||
my $book = eval { WebGUI::Shop::AddressBook->new($session, $addressBookId); };
|
||||
next BOOK if Exception::Class->caught();
|
||||
$book->delete;
|
||||
}
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub alterAddressBookTable {
|
||||
my $session = shift;
|
||||
print "\tDrop sessionId from the Address Book database table... " unless $quiet;
|
||||
# and here's our code
|
||||
$session->db->write("ALTER TABLE addressBook DROP COLUMN sessionId");
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub alterCartTable {
|
||||
my $session = shift;
|
||||
print "\tAdd billing address column to the Cart table... " unless $quiet;
|
||||
# and here's our code
|
||||
$session->db->write("ALTER TABLE cart ADD COLUMN billingAddressId CHAR(22)");
|
||||
$session->db->write("ALTER TABLE cart ADD COLUMN gatewayId CHAR(22)");
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub addPayDriverTemplates {
|
||||
my $session = shift;
|
||||
print "\tAdd templates to the Payment Drivers that need them... " unless $quiet;
|
||||
# and here's our code
|
||||
my $pay = WebGUI::Shop::Pay->new($session);
|
||||
my @gateways = @{ $pay->getPaymentGateways };
|
||||
GATEWAY: foreach my $gateway (@gateways) {
|
||||
next GATEWAY unless $gateway;
|
||||
my $properties = $gateway->get;
|
||||
if ($gateway->isa('WebGUI::Shop::PayDriver::Cash')) {
|
||||
$properties->{summaryTemplateId} = '30h5rHxzE_Q0CyI3Gg7EJw';
|
||||
}
|
||||
elsif ($gateway->isa('WebGUI::Shop::PayDriver::ITransact')) {
|
||||
##Nothing to do. This template was only changed, not added.
|
||||
}
|
||||
elsif ($gateway->isa('WebGUI::Shop::PayDriver::Ogone')) {
|
||||
$properties->{summaryTemplateId} = 'jysVZeUR0Bx2NfrKs5sulg';
|
||||
}
|
||||
elsif ($gateway->isa('WebGUI::Shop::PayDriver::PayPal::PayPalStd')) {
|
||||
$properties->{summaryTemplateId} = '300AozDaeveAjB_KN0ljlQ';
|
||||
}
|
||||
elsif ($gateway->isa('WebGUI::Shop::PayDriver::PayPal::ExpressCheckout')) {
|
||||
$properties->{summaryTemplateId} = 'GqnZPB0gLoZmqQzYFaq7bg';
|
||||
}
|
||||
else {
|
||||
die "Unknown payment driver type found. Unable to automatically upgrade.\n";
|
||||
}
|
||||
$gateway->update($properties);
|
||||
}
|
||||
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;
|
||||
|
||||
print "\tUpgrading package $file\n" unless $quiet;
|
||||
# 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 = eval {
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
$node->importPackage( $storage, {
|
||||
overwriteLatest => 1,
|
||||
clearPackageFlag => 1,
|
||||
setDefaultTemplate => 1,
|
||||
} );
|
||||
};
|
||||
|
||||
if ($package eq 'corrupt') {
|
||||
die "Corrupt package found in $file. Stopping upgrade.\n";
|
||||
}
|
||||
if ($@ || !defined $package) {
|
||||
die "Error during package import on $file: $@\nStopping upgrade\n.";
|
||||
}
|
||||
|
||||
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',".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
|
||||
|
|
@ -1,207 +0,0 @@
|
|||
#!/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::Instance;
|
||||
|
||||
|
||||
my $toVersion = '7.9.5';
|
||||
my $quiet; # this line required
|
||||
|
||||
|
||||
my $session = start(); # this line required
|
||||
|
||||
# upgrade functions go here
|
||||
modifySortItems( $session );
|
||||
fixRequestForApprovalScratch($session);
|
||||
addRejectNoticeSetting($session);
|
||||
updateGroupGroupingsTable($session);
|
||||
installNewCSUnsubscribeTemplate($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;
|
||||
#}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Adds setting which allows users to set whether or not to send reject notices
|
||||
sub addRejectNoticeSetting {
|
||||
my $session = shift;
|
||||
print "\tAdding reject notice setting... " unless $quiet;
|
||||
$session->setting->add('sendRejectNotice',1);
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub installNewCSUnsubscribeTemplate {
|
||||
my $session = shift;
|
||||
print "\tAdding new unsubscribe template to the CS... " unless $quiet;
|
||||
$session->db->write(q|ALTER TABLE Collaboration ADD COLUMN unsubscribeTemplateId CHAR(22) NOT NULL|);
|
||||
$session->db->write(q|UPDATE Collaboration set unsubscribeTemplateId='default_CS_unsubscribe'|);
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Add keys and indicies to groupGroupings to help speed up group queries
|
||||
sub updateGroupGroupingsTable {
|
||||
my $session = shift;
|
||||
print "\tAdding primary key and indicies to groupGroupings table... " unless $quiet;
|
||||
my $sth = $session->db->read('show create table groupGroupings');
|
||||
my ($field,$stmt) = $sth->array;
|
||||
$sth->finish;
|
||||
unless ($stmt =~ m/PRIMARY KEY/i) {
|
||||
$session->db->write("alter table groupGroupings add primary key (groupId,inGroup)");
|
||||
}
|
||||
unless ($stmt =~ m/KEY `inGroup`/i) {
|
||||
$session->db->write("alter table groupGroupings add index inGroup (inGroup)");
|
||||
}
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
sub fixRequestForApprovalScratch {
|
||||
my $session = shift;
|
||||
print "\tCorrect RequestApprovalForVersionTag workflow instance data with leading commas... " unless $quiet;
|
||||
# and here's our code
|
||||
my $instances = WebGUI::Workflow::Instance->getAllInstances($session);
|
||||
INSTANCE: foreach my $instance (@{ $instances }) {
|
||||
my $messageId = $instance->getScratch('messageId');
|
||||
next INSTANCE unless $messageId;
|
||||
$messageId =~ s/^,//;
|
||||
$instance->setScratch('messageId', $messageId);
|
||||
}
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Changes sortItems to a SelectBox
|
||||
sub modifySortItems {
|
||||
my $session = shift;
|
||||
print "\tUpdating SyndicatedContent...\n" unless $quiet;
|
||||
|
||||
require WebGUI::Form::SelectBox;
|
||||
|
||||
print "\t\tModifying table...\n" unless $quiet;
|
||||
my $type = WebGUI::Form::SelectBox->getDatabaseFieldType;
|
||||
$session->db->write("ALTER TABLE SyndicatedContent MODIFY sortItems $type");
|
||||
|
||||
print "\t\tConverting old values..." unless $quiet;
|
||||
$session->db->write(q{
|
||||
UPDATE SyndicatedContent
|
||||
SET sortItems = 'none'
|
||||
WHERE sortItems <> '1'
|
||||
});
|
||||
$session->db->write(q{
|
||||
UPDATE SyndicatedContent
|
||||
SET sortItems = 'pubDate_des'
|
||||
WHERE sortItems = '1'
|
||||
});
|
||||
|
||||
# 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;
|
||||
|
||||
print "\tUpgrading package $file\n" unless $quiet;
|
||||
# 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 = eval {
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
$node->importPackage( $storage, {
|
||||
overwriteLatest => 1,
|
||||
clearPackageFlag => 1,
|
||||
setDefaultTemplate => 1,
|
||||
} );
|
||||
};
|
||||
|
||||
if ($package eq 'corrupt') {
|
||||
die "Corrupt package found in $file. Stopping upgrade.\n";
|
||||
}
|
||||
if ($@ || !defined $package) {
|
||||
die "Error during package import on $file: $@\nStopping upgrade\n.";
|
||||
}
|
||||
|
||||
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',".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
|
||||
|
|
@ -1,161 +0,0 @@
|
|||
#!/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.9.6';
|
||||
my $quiet; # this line required
|
||||
|
||||
|
||||
my $session = start(); # this line required
|
||||
|
||||
# upgrade functions go here
|
||||
fixConvertUTCMacroName($session);
|
||||
dropOldEMSTableColumn($session);
|
||||
addIndexForInbox($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;
|
||||
#}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Add keys and indicies to groupGroupings to help speed up group queries
|
||||
sub addIndexForInbox {
|
||||
my $session = shift;
|
||||
print "\tAdding index to inbox_messageState... " unless $quiet;
|
||||
my $sth = $session->db->read('show create table inbox_messageState');
|
||||
my ($field,$stmt) = $sth->array;
|
||||
$sth->finish;
|
||||
unless ($stmt =~ m/KEY `userId_deleted_isRead`/i) {
|
||||
$session->db->write("alter table inbox_messageState add index userId_deleted_isRead (userId,deleted,isRead)");
|
||||
}
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
sub fixConvertUTCMacroName {
|
||||
my $session = shift;
|
||||
print "\tFix the name of the ConvertUTCToTZ macro in the config file... " unless $quiet;
|
||||
$session->config->deleteFromHash('macros', 'ConvertToUTC');
|
||||
$session->config->addToHash('macros', 'ConvertUTCToTZ', 'ConvertUTCToTZ');
|
||||
# and here's our code
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
sub dropOldEMSTableColumn {
|
||||
my $session = shift;
|
||||
print "\tDrop an old column from the EventMangementSystem table that is no longer used... " unless $quiet;
|
||||
$session->db->write(q|ALTER TABLE EventManagementSystem DROP COLUMN groupToApproveEvents|);
|
||||
# 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;
|
||||
|
||||
print "\tUpgrading package $file\n" unless $quiet;
|
||||
# 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 = eval {
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
$node->importPackage( $storage, {
|
||||
overwriteLatest => 1,
|
||||
clearPackageFlag => 1,
|
||||
setDefaultTemplate => 1,
|
||||
} );
|
||||
};
|
||||
|
||||
if ($package eq 'corrupt') {
|
||||
die "Corrupt package found in $file. Stopping upgrade.\n";
|
||||
}
|
||||
if ($@ || !defined $package) {
|
||||
die "Error during package import on $file: $@\nStopping upgrade\n.";
|
||||
}
|
||||
|
||||
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',".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
|
||||
|
|
@ -1,241 +0,0 @@
|
|||
#!/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::Asset::Wobject::Collaboration;
|
||||
use WebGUI::Exception;
|
||||
use WebGUI::Workflow::Cron;
|
||||
use WebGUI::Utility qw/isIn/;
|
||||
|
||||
|
||||
my $toVersion = '7.9.7';
|
||||
my $quiet; # this line required
|
||||
|
||||
|
||||
my $session = start(); # this line required
|
||||
|
||||
# upgrade functions go here
|
||||
restoreDefaultCronJobs($session);
|
||||
restoreCsCronJobs($session);
|
||||
cleanup_inbox_messageStateTable($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;
|
||||
#}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
sub cleanup_inbox_messageStateTable {
|
||||
my $session = shift;
|
||||
print "\tDelete dead entries from the inbox_MessageState table. This may take a long time... " unless $quiet;
|
||||
# and here's our code
|
||||
my $source = $session->db->read("select messageId from inbox_messageState s where not exists(select messageId from inbox where messageId = s.messageId)");
|
||||
my $cleaner = $session->db->prepare("delete from inbox_messageState where messageId=?");
|
||||
while (my ($messageId) = $source->array) {
|
||||
$cleaner->execute([$messageId]);
|
||||
}
|
||||
$source->finish;
|
||||
$cleaner->finish;
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
sub restoreDefaultCronJobs {
|
||||
my $session = shift;
|
||||
# and here's our code
|
||||
print "\tRestore missing default cron jobs that may have been deleted... " unless $quiet;
|
||||
my $tasks = WebGUI::Workflow::Cron->getAllTasks($session);
|
||||
my @taskIds = map { $_->getId } @{ $tasks };
|
||||
if (! isIn('pbcron0000000000000001', @taskIds)) {
|
||||
print "\n\t\tRestoring Daily Maintenance Task... " unless $quiet;
|
||||
WebGUI::Workflow::Cron->create($session, {
|
||||
title => "Daily Maintenance", dayOfMonth => '*',
|
||||
enabled => 1, monthOfYear => '*',
|
||||
runOnce => 0, dayOfWeek => '*',
|
||||
minuteOfHour => 30, workflowId => 'pbworkflow000000000001',
|
||||
hourOfDay => 23, priority => 3,
|
||||
},
|
||||
'pbcron0000000000000001');
|
||||
}
|
||||
if (! isIn('pbcron0000000000000002', @taskIds)) {
|
||||
print "\n\t\tRestoring Weekly Maintenance Task... " unless $quiet;
|
||||
WebGUI::Workflow::Cron->create($session, {
|
||||
title => "Weekly Maintenance", dayOfMonth => '*',
|
||||
enabled => 1, monthOfYear => '*',
|
||||
runOnce => 0, dayOfWeek => '0',
|
||||
minuteOfHour => 30, workflowId => 'pbworkflow000000000002',
|
||||
hourOfDay => 1, priority => 3,
|
||||
},
|
||||
'pbcron0000000000000002');
|
||||
}
|
||||
if (! isIn('pbcron0000000000000003', @taskIds)) {
|
||||
print "\n\t\tRestoring Hourly Maintenance Task... " unless $quiet;
|
||||
WebGUI::Workflow::Cron->create($session, {
|
||||
title => "Hourly Maintenance", dayOfMonth => '*',
|
||||
enabled => 1, monthOfYear => '*',
|
||||
runOnce => 0, dayOfWeek => '*',
|
||||
minuteOfHour => 15, workflowId => 'pbworkflow000000000004',
|
||||
hourOfDay => '*', priority => 3,
|
||||
},
|
||||
'pbcron0000000000000003');
|
||||
}
|
||||
if (! isIn('pbcron0000000000000004', @taskIds)) {
|
||||
print "\n\t\tRestoring Email Delivery Task... " unless $quiet;
|
||||
WebGUI::Workflow::Cron->create($session, {
|
||||
title => "Send Queued Email Messages Every 5 Minutes",
|
||||
dayOfMonth => '*',
|
||||
enabled => 1, monthOfYear => '*',
|
||||
runOnce => 0, dayOfWeek => '*',
|
||||
minuteOfHour => '*/5', workflowId => 'pbworkflow000000000007',
|
||||
hourOfDay => '*', priority => 3,
|
||||
},
|
||||
'pbcron0000000000000004');
|
||||
}
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
sub restoreCsCronJobs {
|
||||
my $session = shift;
|
||||
print "\tRestore missing Collaboration System cron jobs that may have been deleted... " unless $quiet;
|
||||
my $i18n = WebGUI::International->new($session, "Asset_Collaboration");
|
||||
my $getCs = WebGUI::Asset::Wobject::Collaboration->getIsa($session);
|
||||
CS: while (1) {
|
||||
my $cs = eval { $getCs->(); };
|
||||
if (my $e = Exception::Class->caught()) {
|
||||
$session->log->error($@);
|
||||
next CS;
|
||||
}
|
||||
last CS unless $cs;
|
||||
##Do something useful with $product
|
||||
my $cron = undef;
|
||||
if ($cs->get("getMailCronId")) {
|
||||
$cron = WebGUI::Workflow::Cron->new($session, $cs->get("getMailCronId"));
|
||||
}
|
||||
next CS if $cron;
|
||||
$cron = WebGUI::Workflow::Cron->create($session, {
|
||||
title => $cs->getTitle." ".$i18n->get("mail"),
|
||||
minuteOfHour => "*/".($cs->get("getMailInterval")/60),
|
||||
className => (ref $cs),
|
||||
methodName => "new",
|
||||
parameters => $cs->getId,
|
||||
workflowId => "csworkflow000000000001"
|
||||
});
|
||||
$cs->update({getMailCronId=>$cron->getId});
|
||||
if ($cs->get("getMail")) {
|
||||
$cron->set({enabled=>1,title=>$cs->getTitle." ".$i18n->get("mail"), minuteOfHour=>"*/".($cs->get("getMailInterval")/60)});
|
||||
} else {
|
||||
$cron->set({enabled=>0,title=>$cs->getTitle." ".$i18n->get("mail"), minuteOfHour=>"*/".($cs->get("getMailInterval")/60)});
|
||||
}
|
||||
|
||||
}
|
||||
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;
|
||||
|
||||
print "\tUpgrading package $file\n" unless $quiet;
|
||||
# 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 = eval {
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
$node->importPackage( $storage, {
|
||||
overwriteLatest => 1,
|
||||
clearPackageFlag => 1,
|
||||
setDefaultTemplate => 1,
|
||||
} );
|
||||
};
|
||||
|
||||
if ($package eq 'corrupt') {
|
||||
die "Corrupt package found in $file. Stopping upgrade.\n";
|
||||
}
|
||||
if ($@ || !defined $package) {
|
||||
die "Error during package import on $file: $@\nStopping upgrade\n.";
|
||||
}
|
||||
|
||||
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',".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
|
||||
|
|
@ -1,190 +0,0 @@
|
|||
#!/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::Asset::Wobject::Collaboration;
|
||||
use WebGUI::Asset::Post::Thread;
|
||||
use WebGUI::ProfileField;
|
||||
|
||||
my $toVersion = '7.9.8';
|
||||
my $quiet; # this line required
|
||||
|
||||
my $session = start(); # this line required
|
||||
|
||||
# upgrade functions go here
|
||||
changeFirstDayOfWeekDefault($session);
|
||||
updateLastPostCS($session);
|
||||
updateLastPostThread($session);
|
||||
addTwitterAuth( $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;
|
||||
#}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Add twitter auth and macro
|
||||
sub addTwitterAuth {
|
||||
my $session = shift;
|
||||
print "\tAdding twitter auth method... " unless $quiet;
|
||||
|
||||
$session->config->addToArray( 'authMethods', 'Twitter' );
|
||||
$session->config->addToHash( 'macros', "TwitterLogin" => "TwitterLogin" );
|
||||
$session->setting->set( 'twitterEnabled', 0 );
|
||||
$session->setting->set( 'twitterTemplateIdChooseUsername', 'mfHGkp6t9gdclmzN33OEnw' );
|
||||
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
sub changeFirstDayOfWeekDefault {
|
||||
my $session = shift;
|
||||
print "\tMake the default for firstDayOfWeek a number instead of a string... " unless $quiet;
|
||||
# and here's our code
|
||||
my $profileField = WebGUI::ProfileField->new($session, 'firstDayOfWeek');
|
||||
my $properties = $profileField->get();
|
||||
$properties->{dataDefault} = 0;
|
||||
$profileField->set($properties);
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
sub updateLastPostCS {
|
||||
my $session = shift;
|
||||
print "\tUpdating last post information in every Collaboration System. This could take a very long time... " unless $quiet;
|
||||
# and here's our code
|
||||
my $getCs = WebGUI::Asset::Wobject::Collaboration->getIsa($session);
|
||||
CS: while (my $cs = eval { $getCs->() } ) {
|
||||
next CS if Exception::Class->caught();
|
||||
last CS if ! $cs;
|
||||
next CS unless $cs->get('lastPostId');
|
||||
my $lastPost = WebGUI::Asset->newByDynamicClass($session, $cs->get('lastPostId'));
|
||||
next CS unless $lastPost && $lastPost->get('status') eq 'archived';
|
||||
$lastPost->disqualifyAsLastPost;
|
||||
}
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
sub updateLastPostThread {
|
||||
my $session = shift;
|
||||
print "\tUpdating last post information in every Thread. This could also take a very long time... " unless $quiet;
|
||||
# and here's our code
|
||||
my $getThread = WebGUI::Asset::Wobject::Collaboration->getIsa($session);
|
||||
THREAD: while (my $thread = eval { $getThread->() } ) {
|
||||
next THREAD if Exception::Class->caught();
|
||||
last THREAD if ! $thread;
|
||||
next THREAD unless $thread->get('lastPostId');
|
||||
my $lastPost = WebGUI::Asset->newByDynamicClass($session, $thread->get('lastPostId'));
|
||||
next THREAD unless $lastPost && $lastPost->get('status') eq 'archived';
|
||||
$lastPost->disqualifyAsLastPost;
|
||||
}
|
||||
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;
|
||||
|
||||
print "\tUpgrading package $file\n" unless $quiet;
|
||||
# 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 = eval {
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
$node->importPackage( $storage, {
|
||||
overwriteLatest => 1,
|
||||
clearPackageFlag => 1,
|
||||
setDefaultTemplate => 1,
|
||||
} );
|
||||
};
|
||||
|
||||
if ($package eq 'corrupt') {
|
||||
die "Corrupt package found in $file. Stopping upgrade.\n";
|
||||
}
|
||||
if ($@ || !defined $package) {
|
||||
die "Error during package import on $file: $@\nStopping upgrade\n.";
|
||||
}
|
||||
|
||||
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',".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
|
||||
Loading…
Add table
Add a link
Reference in a new issue