From aae6a32df4fcf119f3a45a591755355344a8658b Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Mon, 28 Apr 2008 02:07:56 +0000 Subject: [PATCH] added: Ability to enable / disable archiving per Collaboration System. fixed Mech tests again --- docs/changelog/7.x.x.txt | 2 ++ docs/upgrades/upgrade_7.5.10-7.5.11.pl | 13 +++++++++++++ lib/WebGUI/Asset/Wobject/Collaboration.pm | 7 +++++++ .../Workflow/Activity/ArchiveOldThreads.pm | 1 + lib/WebGUI/i18n/English/Asset_Collaboration.pm | 13 +++++++++++++ t/Asset/Wobject/GalleryAlbum/rss.t | 16 ++++++++++++++-- 6 files changed, 50 insertions(+), 2 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index ca5601af4..5940f2f0d 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -44,6 +44,8 @@ - added: DataForm now can use CAPTCHA for Visitors - Spent some time cleaning up DataForm, but it could use more. - added: Commit Version Tag screen shows revisions in the tag + - added: Ability to enable/disable Thread archiving on a per-Collaboration + basis 7.5.10 diff --git a/docs/upgrades/upgrade_7.5.10-7.5.11.pl b/docs/upgrades/upgrade_7.5.10-7.5.11.pl index 15e6d8c6e..071108ef3 100644 --- a/docs/upgrades/upgrade_7.5.10-7.5.11.pl +++ b/docs/upgrades/upgrade_7.5.10-7.5.11.pl @@ -44,9 +44,22 @@ upgradeEMS($session); migrateOldProduct($session); mergeProductsWithCommerce($session); addCaptchaToDataForm( $session ); +addArchiveEnabledToCollaboration( $session ); finish($session); # this line required +#---------------------------------------------------------------------------- +# Add the archiveEnabled field to Collaboration assets +sub addArchiveEnabledToCollaboration { + my $session = shift; + print "\tAdding archiveEnabled to Collaboration... " unless $quiet; + + $session->db->write( + q{ ALTER TABLE Collaboration ADD COLUMN archiveEnabled INT(1) DEFAULT 1 } + ); + + print "DONE!\n" unless $quiet; +} #---------------------------------------------------------------------------- # Add the useCaptcha field to DataForm assets sub addCaptchaToDataForm { diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index b06a1197c..c5b554eb3 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -552,6 +552,13 @@ sub definition { label=>$i18n->get('posts/page'), hoverHelp=>$i18n->get('posts/page description'), }, + archiveEnabled => { + fieldType => "yesNo", + defaultValue => 1, + tab => 'properties', + label => $i18n->get('editForm archiveEnabled label'), + hoverHelp => $i18n->get('editForm archiveEnabled description'), + }, archiveAfter =>{ fieldType=>"interval", defaultValue=>31536000, diff --git a/lib/WebGUI/Workflow/Activity/ArchiveOldThreads.pm b/lib/WebGUI/Workflow/Activity/ArchiveOldThreads.pm index eff25ff6c..09f593f99 100644 --- a/lib/WebGUI/Workflow/Activity/ArchiveOldThreads.pm +++ b/lib/WebGUI/Workflow/Activity/ArchiveOldThreads.pm @@ -74,6 +74,7 @@ sub execute { while (my ($assetId) = $a->array) { my $cs = WebGUI::Asset->new($self->session, $assetId, "WebGUI::Asset::Wobject::Collaboration"); next unless defined $cs; + next unless $cs->get("archiveEnabled"); my $archiveDate = $epoch - $cs->get("archiveAfter"); my $sql = "select asset.assetId, assetData.revisionDate from Post left join asset on asset.assetId=Post.assetId left join assetData on Post.assetId=assetData.assetId and Post.revisionDate=assetData.revisionDate diff --git a/lib/WebGUI/i18n/English/Asset_Collaboration.pm b/lib/WebGUI/i18n/English/Asset_Collaboration.pm index 37e3f5324..44cde0953 100644 --- a/lib/WebGUI/i18n/English/Asset_Collaboration.pm +++ b/lib/WebGUI/i18n/English/Asset_Collaboration.pm @@ -1633,6 +1633,19 @@ the Collaboration Asset, the user will be notified.|, message => q|Verify your humanity|, lastUpdated => 1170543345, }, + + 'editForm archiveEnabled label' => { + message => q{Enable Archiving?}, + lastUpdated => 0, + context => q{Label for asset property}, + }, + + 'editForm archiveEnabled description' => { + message => q{If Yes, Threads will be automatically hidden after a certain interval}, + lastUpdated => 0, + context => q{Hover help for asset property}, + }, + }; 1; diff --git a/t/Asset/Wobject/GalleryAlbum/rss.t b/t/Asset/Wobject/GalleryAlbum/rss.t index 4fe0e1653..f725adb9e 100644 --- a/t/Asset/Wobject/GalleryAlbum/rss.t +++ b/t/Asset/Wobject/GalleryAlbum/rss.t @@ -65,7 +65,17 @@ for my $i ( 0 .. 5 ) { $versionTag->commit; +# Override some settings to make things easier to test +my %oldSettings; +# userFunctionStyleId +$oldSettings{ userFunctionStyleId } = $session->setting->get( 'userFunctionStyleId' ); +$session->setting->set( 'userFunctionStyleId', 'PBtmpl0000000000000132' ); +# specialState +$oldSettings{ specialState } = $session->setting->get( 'specialState' ); +$session->setting->set( 'specialState', '' ); + my ( $mech ); +my $baseUrl = 'http://' . $session->config->get('sitename')->[0]; #---------------------------------------------------------------------------- # Tests @@ -79,8 +89,7 @@ if ( !$mech->success ) { plan skip_all => "Cannot load URL '$baseUrl'. Will not test."; } -plan tests => 2; - +plan tests => 1; #---------------------------------------------------------------------------- # Test www_viewRss @@ -114,4 +123,7 @@ cmp_deeply( # Cleanup END { $versionTag->rollback(); + for my $key ( keys %oldSettings ) { + $session->setting->set( $key, $oldSettings{ $key } ); + } }