diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index b3a250791..a6a860894 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -1,4 +1,7 @@ 6.9.0 + - Added a workflow system. + - Added a workflow scheduler system. + - Converted the runHourly.pl scripts to run as scheduled workflows. - Converted WebGUI to use a new object oriented session system. More details in migation.txt. - Added a lot more tests to the test suite. diff --git a/docs/gotcha.txt b/docs/gotcha.txt index 2c4a0dcc5..bbccbe67e 100644 --- a/docs/gotcha.txt +++ b/docs/gotcha.txt @@ -7,15 +7,19 @@ 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. -6.9.0 +6.99.0 -------------------------------------------------------------------- + * The 6.99 series is the last round of changes before 7.0.0 is + released. It will serve as the beta, gamma, and release + candidates for 7.0.0. + * The session system has been replaced by a new object-oriented one, which has caused massive API changes. Please consult migration.txt to bring your custom code up to date with the new API. * You need to upgrade to the latest 6.8 release before you can - upgrade to 6.9. + upgrade to 6.99. * If you wish to use one of the new optional template engines you'll need to install the perl modules for them: @@ -43,6 +47,11 @@ save you many hours of grief. Don't be alarmed by this, it's a normal part of the upgrade procedure. + * You no longer need the cron job for runHourly.pl. Instead, you + must start sbin/spectre.pl when your server starts up. + Spectre is WebGUI's offline execution engine. It triggers + scheduled events and executes workflow tasks. + 6.8.4 -------------------------------------------------------------------- diff --git a/docs/migration.txt b/docs/migration.txt index 6a1edb674..20151597d 100644 --- a/docs/migration.txt +++ b/docs/migration.txt @@ -196,7 +196,7 @@ be using this any longer anyway, but we thought we'd warn you anyway. 1.8 Output Chunking -Starting in 6.9 WebGUI www_ asset methods are capable of having full control +Starting in 6.99 WebGUI www_ asset methods are capable of having full control over the output buffer. They can use $session->output->print() to send chunks of content back to the browser before the page is entirely processed. The advantage here is that the page appears to load more quickly to the end user. @@ -275,10 +275,14 @@ take a look a WebGUI::Asset::Template for changes in the template system API. 4. Scheduler Migration ----------------------- -4.1 Nothing Yet - -There have currently been no changes to the scheduler API. +4.1 Converted to Workflow +As of 6.99 we've converted the scheduler (runHourly.pl) and it's plugins +(sbin/Hourly/*) to the new WebGUI Workflow system. The program that replaces +runHourly.pl is sbin/spectre.pl, which is always running and therefore doesn't +need to be scheduled via crontab or Windows Scheduler. To see the new API for +the sbin/Hourly/* scripts, check out +lib/WebGUI/Workflow/Activity/_activity.skeleton 5. System Changes Affecting Migration @@ -564,7 +568,7 @@ Apache2::Request which is referenced through $session{modperl} and $session{req} 5.23 Session System Replaced -As of 6.9.0 we've removed the old global session system and replaced it with a +As of 6.99 we've removed the old global session system and replaced it with a newer, safer, more modern, object oriented session system. Because session is the glue that holds WebGUI together, it has basically affected every API in the system. Here's a (hopefully complete) list of what's been changed and how @@ -630,7 +634,7 @@ perl -pi.bak -e 's!\$session{scratch}{(.*)}!\$self->session->scratch->get("$1")! 5.23.1 WebGUI::SQL API Refactored -The SQL API has been made more object oriented in 6.9, so it now handles database +The SQL API has been made more object oriented in 6.99, so it now handles database connections for you. You can get the default database connection via $session->db or a random slave via $session->dbSlave or you can create your own by my $db = WebGUI::SQL->connect($session, $dsn, $user, $pass); @@ -654,14 +658,14 @@ perl -pi.bak -e 's!WebGUI\:\:FormProcessor\:\:!\$self->session->form->!g' fileNa 5.23.3 WebGUI::ErrorHandler API Refactored -As of 6.9 WebGUI::ErrorHandler is now accessed through session. +As of 6.99 WebGUI::ErrorHandler is now accessed through session. perl -pi.bak -e 's!WebGUI\:\:ErrorHandler\:\:!\$self->session->errorHandler->!g' fileNameGoesHere 5.23.4 WebGUI::Style API Refactored -As of 6.9 the WebGUI::Style API has been convereted to OO and is accessed +As of 6.99 the WebGUI::Style API has been convereted to OO and is accessed through session. The following command line tricks will help you convert your assets. @@ -679,14 +683,14 @@ perl -pi.bak -e 's!WebGUI\:\:Macro\:\:process\((.*)\)!WebGUI::Macro::process(\$s 5.23.6 WebGUI::URL API Refactored -As of 6.9 WebGUI::URL is now accessed through session like $session->url +As of 6.99 WebGUI::URL is now accessed through session like $session->url perl -pi.bak -e 's!WebGUI\:\:URL\:\:!\$self->session->url->!g' fileNameGoesHere 5.23.7 WebGUI::Cache API Refactored -As of 6.9 WebGUI::Cache requires you to pass in a reference to $session into +As of 6.99 WebGUI::Cache requires you to pass in a reference to $session into the constructor. perl -pi.bak -e 's!WebGUI\:\:Cache\-\>new\(!WebGUI::Cache->new(\$self->session,!g' fileNameGoesHere @@ -694,7 +698,7 @@ perl -pi.bak -e 's!WebGUI\:\:Cache\-\>new\(!WebGUI::Cache->new(\$self->session,! 5.23.8 WebGUI::AdminConsole Refactored -As of 6.9 WebGUI::AdminConsole requires you to pass a reference to $session +As of 6.99 WebGUI::AdminConsole requires you to pass a reference to $session into the constructor. perl -pi.bak -e 's!WebGUI\:\:AdminConsole\-\>new\(!WebGUI::AdminConsole->new(\$self->session,!g' fileNameGoesHere @@ -702,7 +706,7 @@ perl -pi.bak -e 's!WebGUI\:\:AdminConsole\-\>new\(!WebGUI::AdminConsole->new(\$s 5.23.9 WebGUI::DatabaseLink API Refactored -As of 6.9 WebGUI::DatabaseLink requires you to pass in a reference to +As of 6.99 WebGUI::DatabaseLink requires you to pass in a reference to $session into the constructor. Also, the API has been heavily refactored to be more complete. Please see it's API docs for more info. @@ -712,7 +716,7 @@ perl -pi.bak -e 's!WebGUI\:\:DatabaseLink\-\>new\(!WebGUI::DatabaseLink->new(\$s 5.23.10 WebGUI::Privilege API Refactored WebGUI::Privilege is now accessed through session like $session->privilege as -of 6.9. +of 6.99. perl -pi.bak -e 's!WebGUI\:\:Privilege\:\:!\$self->session->privilege->!g' fileNameGoesHere @@ -735,7 +739,7 @@ perl -pi.bak -e 's!WebGUI\:\:DateTime\:\:!\$self->session->datetime->!g' fileNam 5.23.12 WebGUI::Form API Refactored -In 6.9 the WebGUI::Form API was refactored to accept $session as the first +In 6.99 the WebGUI::Form API was refactored to accept $session as the first parameter to each method. perl -pi.bak -e 's!WebGUI\:\:Form\:\:(\w+)\((.*)\)!WebGUI::Form::$1(\$self->session,$2)!g' fileNameGoesHere diff --git a/docs/upgrades/upgrade_6.8.6-6.9.0.pl b/docs/upgrades/upgrade_6.8.6-6.9.0.pl index f9e6859af..52fb41a24 100644 --- a/docs/upgrades/upgrade_6.8.6-6.9.0.pl +++ b/docs/upgrades/upgrade_6.8.6-6.9.0.pl @@ -97,16 +97,19 @@ sub addWorkflow { primary key (activityId, name) )"); my $workflow = WebGUI::Workflow->create($session, { - title=>"Clean Up Temp Files", - description=>"This workflow deletes temporary files from the WebGUI uploads folder.", + title=>"Daily Maintenance Tasks", + description=>"This workflow runs daily maintenance tasks such as cleaning up old temporary files and cache.", enabled=>1, type=>"none" }, "pbworkflow000000000001"); my $activity = $workflow->addActivity("WebGUI::Workflow::Activity::CleanTempStorage", "pbwfactivity0000000001"); - $activity->set("title","Delete files older than 24 hours"); + $activity->set("title","Delete temp files older than 24 hours"); $activity->set("storageTimeout",60*60*24); - my $cron = WebGUI::Workflow::Cron->create($session, { - title=>'Delete temp files', + $activity = $workflow->addActivity("WebGUI::Workflow::Activity::CleanFileCache", "pbwfactivity0000000002"); + $activity->set("title","Prune cache larger than 100MB"); + $activity->set("sizeLimit", 1000000000); + WebGUI::Workflow::Cron->create($session, { + title=>'Daily Maintenance', enabled=>1, runOnce=>0, minuteOfHour=>"30", @@ -115,10 +118,40 @@ sub addWorkflow { workflowId=>$workflow->getId }, "pbcron0000000000000001"); $session->config->set("workflowActivities", { - none=>["WebGUI::Workflow::Activity::CleanTempStorage"], + none=>["WebGUI::Workflow::Activity::DecayKarma", "WebGUI::Workflow::Activity::TrashClipboard", "WebGUI::Workflow::Activity::CleanTempStorage", + "WebGUI::Workflow::Activity::CleanFileCache", "WebGUI::Workflow::Activity::CleanLoginHistory"], user=>[], - versiontag=>[] + versiontag=>["WebGUI::Workflow::Activity::CommitVersionTag", "WebGUI::Workflow::Activity::RollbackVersionTag"] }); + $workflow = WebGUI::Workflow->create($session, { + title=>"Weekly Maintenance Tasks", + description=>"This workflow runs once per week to perform maintenance tasks like cleaning up log files.", + enabled=>1, + type=>"none" + }, "pbworkflow000000000002"); + $activity = $workflow->addActivity("WebGUI::Workflow::Activity::CleanLoginHistory", "pbwfactivity0000000003"); + $activity->set("title", "Delete login entries older than 90 days"); + $activity->set("ageToDelete", 60*60*24*90); + $activity = $workflow->addActivity("WebGUI::Workflow::Activity::TrashClipboard", "pbwfactivity0000000004"); + $activity->set("title", "Move clipboard items older than 30 days to trash"); + $activity->set("trashAfter", 60*60*24*30); + WebGUI::Workflow::Cron->create($session, { + title=>'Weekly Maintenance Maintenance', + enabled=>1, + runOnce=>0, + minuteOfHour=>"30", + hourOfDay=>"1", + dayOfWeek=>"0", + priority=>3, + workflowId=>$workflow->getId + }, "pbcron0000000000000002"); + $session->db->write("alter table assetVersionTag add column isLocked int not null default 0"); + $session->db->write("alter table assetVersionTag add column lockedBy varchar(22) binary not null"); + $session->config->delete("fileCacheSizeLimit"); + $session->config->delete("CleanLoginHistory_ageToDelete"); + $session->config->delete("DecayKarma_minimumKarma"); + $session->config->delete("DecayKarma_decayFactor"); + $session->config->delete("DeleteExpiredClipboard_offset"); } #------------------------------------------------- diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index e900a41b1..7a76ff27b 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -50,10 +50,6 @@ # "fileCacheRoot" : "/path/to/cache", -# Tell WebGUI how big to let the file cache grow in bytes. - -"fileCacheSizeLimit" : 100000000, - # Support for the memcached distributed caching system. # See http://www.danga.com/memcached/ for details on memcached. # Uncomment this and point it to your memcached server(s). Use a @@ -282,24 +278,6 @@ "passiveProfileInterval" : 86400, -# If specified, the user login log will delete login history -# information older than the specified value. It is specified in -# days. - -# "CleanLoginHistory_ageToDelete" : 90, - -# If minimum karma and decay factor are both specified, then a -# user's karma will be decremented by the decay factor every hour -# until the user has less than the minimum karma. - -# "DecayKarma_minimumKarma" : 100, -# "DecayKarma_decayFactor" : 1, - -# Specify the number of days content should remain in the -# clipboard before being moved to the trash. - -"DeleteExpiredClipboard_offset" : 30, - # Specify the number of days content should remain in the trash # before it gets purged from the system completely. diff --git a/lib/WebGUI/Session/Scratch.pm b/lib/WebGUI/Session/Scratch.pm index d6f980aeb..8de112fc7 100644 --- a/lib/WebGUI/Session/Scratch.pm +++ b/lib/WebGUI/Session/Scratch.pm @@ -76,7 +76,7 @@ Deletes all scratch variables for this session. sub deleteAll { my $self = shift; delete $self->{_data}; - $self->session->db->write("delete from userSessionScratch where sessionId=".$self->session->db->quote($self->{_sessionId})); + $self->session->db->write("delete from userSessionScratch where sessionId=?", [$self->{_sessionId}]); } @@ -97,7 +97,32 @@ sub deleteName { my $name = shift; return undef unless ($name); delete $self->{_data}{$name}; - $self->session->db->write("delete from userSessionScratch where name=".$self->session->db->quote($name)); + $self->session->db->write("delete from userSessionScratch where name=?", [$name]); +} + +#------------------------------------------------------------------- + +=head2 deleteNameByValue ( name, value ) + +Deletes a scratch variable for all users where a particular name equals a particular value. This function must be used with care. + +=head3 name + +The name of the scratch variable. + +=head3 value + +The value to match. + +=cut + +sub deleteName { + my $self = shift; + my $name = shift; + my $value = shift; + return undef unless ($name); + delete $self->{_data}{$name}; + $self->session->db->write("delete from userSessionScratch where name=? and value=?", [$name,$value]); } diff --git a/lib/WebGUI/Workflow/Activity/CleanFileCache.pm b/lib/WebGUI/Workflow/Activity/CleanFileCache.pm new file mode 100644 index 000000000..077fea245 --- /dev/null +++ b/lib/WebGUI/Workflow/Activity/CleanFileCache.pm @@ -0,0 +1,93 @@ +package WebGUI::Workflow::Activity::CleanFileCache; + + +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2006 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 + ------------------------------------------------------------------- + +=cut + +use strict; +use base 'WebGUI::Workflow::Activity'; +use WebGUI::Cache::FileCache; + +=head1 NAME + +Package WebGUI::Workflow::Activity::CleanFileCache + +=head1 DESCRIPTION + +This activity deletes files from the file cache if the file cache has gotten too big. + +=head1 SYNOPSIS + +See WebGUI::Workflow::Activity for details on how to use any activity. + +=head1 METHODS + +These methods are available from this class: + +=cut + + +#------------------------------------------------------------------- + +=head2 definition ( session, definition ) + +See WebGUI::Workflow::Activity::defintion() for details. + +=cut + +sub definition { + my $class = shift; + my $session = shift; + my $definition = shift; + my $i18n = WebGUI::International->new($session, "Workflow_Activity_CleanFileCache"); + push(@{$definition}, { + name=>$i18n->get("topicName"), + properties=> { + sizeLimit => { + fieldType=>"integer", + label=>$i18n->get("size limit"), + subtext=>$i18n->get("bytes"), + defaultValue=>100000000, + hoverHelp=>$i18n->get("size limit help") + } + } + }); + return $class->SUPER::definition($session,$definition); +} + + +#------------------------------------------------------------------- + +=head2 execute ( ) + +See WebGUI::Workflow::Activity::execute() for details. + +=cut + +sub execute { + my $self = shift; + my $size = $self->get("sizeLimit") + 10; + my $expiresModifier = 0; + my $cache = WebGUI::Cache::FileCache->new; + while ($size > $self->get("sizeLimit")) { + $size = $cache->getNamespaceSize($expiresModifier); + $expiresModifier += 60 * 30; # add 30 minutes each pass + } +} + + + +1; + + diff --git a/lib/WebGUI/Workflow/Activity/CleanLoginHistory.pm b/lib/WebGUI/Workflow/Activity/CleanLoginHistory.pm new file mode 100644 index 000000000..ccf39712d --- /dev/null +++ b/lib/WebGUI/Workflow/Activity/CleanLoginHistory.pm @@ -0,0 +1,85 @@ +package WebGUI::Workflow::Activity::CleanLoginHistory; + + +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2006 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 + ------------------------------------------------------------------- + +=cut + +use strict; +use base 'WebGUI::Workflow::Activity'; + +=head1 NAME + +Package WebGUI::Workflow::Activity::CleanLoginHistory + +=head1 DESCRIPTION + +Deletes some of the old cruft from the userLoginLog table. + +=head1 SYNOPSIS + +See WebGUI::Workflow::Activity for details on how to use any activity. + +=head1 METHODS + +These methods are available from this class: + +=cut + + +#------------------------------------------------------------------- + +=head2 definition ( session, definition ) + +See WebGUI::Workflow::Activity::defintion() for details. + +=cut + +sub definition { + my $class = shift; + my $session = shift; + my $definition = shift; + my $i18n = WebGUI::International->new($session, "Workflow_Activity_CleanLoginHistory"); + push(@{$definition}, { + name=>$i18n->get("topicName"), + properties=> { + ageToDelete => { + fieldType=>"interval", + label=>$i18n->get("age to delete"), + defaultValue=>60 * 60 * 24 * 90, + hoverHelp=>$i18n->get("age to delete help") + } + } + }); + return $class->SUPER::definition($session,$definition); +} + + +#------------------------------------------------------------------- + +=head2 execute ( ) + +See WebGUI::Workflow::Activity::execute() for details. + +=cut + +sub execute { + my $self = shift; + $self->session->db->write("delete from userLoginLog where timeStamp < ?", [(time()-(86400*$self->get("ageToDelete")))]); +} + + + +1; + + diff --git a/lib/WebGUI/Workflow/Activity/CommitVersionTag.pm b/lib/WebGUI/Workflow/Activity/CommitVersionTag.pm index 8073eb34d..71bfcf229 100644 --- a/lib/WebGUI/Workflow/Activity/CommitVersionTag.pm +++ b/lib/WebGUI/Workflow/Activity/CommitVersionTag.pm @@ -1,4 +1,4 @@ -package WebGUI::Workflow::Activity::CleanCommitVersionTag; +package WebGUI::Workflow::Activity::CommitVersionTag; =head1 LEGAL diff --git a/lib/WebGUI/Workflow/Activity/DecayKarma.pm b/lib/WebGUI/Workflow/Activity/DecayKarma.pm new file mode 100644 index 000000000..8fa8e6b6f --- /dev/null +++ b/lib/WebGUI/Workflow/Activity/DecayKarma.pm @@ -0,0 +1,91 @@ +package WebGUI::Workflow::Activity::DecayKarma; + + +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2006 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 + ------------------------------------------------------------------- + +=cut + +use strict; +use base 'WebGUI::Workflow::Activity'; + +=head1 NAME + +Package WebGUI::Workflow::Activity::DecayKarma + +=head1 DESCRIPTION + +Subtracts a little bit of karma from each user. This can be used to slowly degrade the abilities of the users who stay away from the site for a long period of time. + +=head1 SYNOPSIS + +See WebGUI::Workflow::Activity for details on how to use any activity. + +=head1 METHODS + +These methods are available from this class: + +=cut + + +#------------------------------------------------------------------- + +=head2 definition ( session, definition ) + +See WebGUI::Workflow::Activity::defintion() for details. + +=cut + +sub definition { + my $class = shift; + my $session = shift; + my $definition = shift; + my $i18n = WebGUI::International->new($session, "Workflow_Activity_DecayKarma"); + push(@{$definition}, { + name=>$i18n->get("topicName"), + properties=> { + minimumKarma => { + fieldType=>"integer", + label=>$i18n->get("minimum karma"), + defaultValue=>0, + hoverHelp=>$i18n->get("minimum karma help") + }, + decayFactor => { + fieldType=>"integer", + label=>$i18n->get("decay factor"), + defaultValue=>1, + hoverHelp=>$i18n->get("decay factor help") + } + } + }); + return $class->SUPER::definition($session,$definition); +} + + +#------------------------------------------------------------------- + +=head2 execute ( ) + +See WebGUI::Workflow::Activity::execute() for details. + +=cut + +sub execute { + my $self = shift; + $self->session->db->write("update users set karma=karma-? where karma > ?", [$self->get("decayFactor"), $self->get("minimumKarma")]); +} + + + +1; + + diff --git a/lib/WebGUI/Workflow/Activity/RollbackVersionTag.pm b/lib/WebGUI/Workflow/Activity/RollbackVersionTag.pm new file mode 100644 index 000000000..a6bc204d5 --- /dev/null +++ b/lib/WebGUI/Workflow/Activity/RollbackVersionTag.pm @@ -0,0 +1,81 @@ +package WebGUI::Workflow::Activity::RollbackVersionTag; + + +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2006 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 + ------------------------------------------------------------------- + +=cut + +use strict; +use base 'WebGUI::Workflow::Activity'; +use WebGUI::VersionTag; + + +=head1 NAME + +Package WebGUI::Workflow::Activity::RollbackVersionTag + +=head1 DESCRIPTION + +This activity rolls back a version tag. + +=head1 SYNOPSIS + +See WebGUI::Workflow::Activity for details on how to use any activity. + +=head1 METHODS + +These methods are available from this class: + +=cut + +#------------------------------------------------------------------- + +=head2 definition ( session, definition ) + +See WebGUI::Workflow::Activity::defintion() for details. + +=cut + +sub definition { + my $class = shift; + my $session = shift; + my $definition = shift; + my $i18n = WebGUI::International->new($session, "Workflow_Activity_RollbackVersionTag"); + push(@{$definition}, { + name=>$i18n->get("topicName"), + properties=> { } + }); + return $class->SUPER::definition($session,$definition); +} + + +#------------------------------------------------------------------- + +=head2 execute ( ) + +See WebGUI::Workflow::Activity::execute() for details. + +=cut + +sub execute { + my $self = shift; + my $versionTag = shift; + $versionTag->rollback; +} + + + + +1; + + diff --git a/lib/WebGUI/Workflow/Activity/TrashClipboard.pm b/lib/WebGUI/Workflow/Activity/TrashClipboard.pm new file mode 100644 index 000000000..f6196b7f9 --- /dev/null +++ b/lib/WebGUI/Workflow/Activity/TrashClipboard.pm @@ -0,0 +1,90 @@ +package WebGUI::Workflow::Activity::TrashClipboard; + + +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2006 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 + ------------------------------------------------------------------- + +=cut + +use strict; +use base 'WebGUI::Workflow::Activity'; + +=head1 NAME + +Package WebGUI::Workflow::Activity::TrashClipboard; + +=head1 DESCRIPTION + +Deletes + +=head1 SYNOPSIS + +See WebGUI::Workflow::Activity for details on how to use any activity. + +=head1 METHODS + +These methods are available from this class: + +=cut + + +#------------------------------------------------------------------- + +=head2 definition ( session, definition ) + +See WebGUI::Workflow::Activity::defintion() for details. + +=cut + +sub definition { + my $class = shift; + my $session = shift; + my $definition = shift; + my $i18n = WebGUI::International->new($session, "Workflow_Activity_TrashClipboard"); + push(@{$definition}, { + name=>$i18n->get("topicName"), + properties=> { + trashAfter => { + fieldType=>"interval", + label=>$i18n->get("trash after"), + defaultValue=>60 * 60 * 24 * 30, + hoverHelp=>$i18n->get("trash after help") + } + } + }); + return $class->SUPER::definition($session,$definition); +} + + +#------------------------------------------------------------------- + +=head2 execute ( ) + +See WebGUI::Workflow::Activity::execute() for details. + +=cut + +sub execute { + my $self = shift; + my $expireDate = (time()-(86400*$self->get("trashAfter"))); + my $sth = $self->session->db->read("select assetId,className from asset where state='clipboard' and stateChanged < ?", [$expireDate]); + while (my ($id, $class) = $sth->array) { + my $asset = WebGUI::Asset->new($id,$class); + $asset->trash; + } +} + + + +1; + + diff --git a/lib/WebGUI/Workflow/Activity/_activity.skeleton b/lib/WebGUI/Workflow/Activity/_activity.skeleton new file mode 100644 index 000000000..0b20e659e --- /dev/null +++ b/lib/WebGUI/Workflow/Activity/_activity.skeleton @@ -0,0 +1,84 @@ +package WebGUI::Workflow::Activity::Skeleton; # change "Skeleton" to your namespace. + + +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2006 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 + ------------------------------------------------------------------- + +=cut + +use strict; +use base 'WebGUI::Workflow::Activity'; + +=head1 NAME + +Package WebGUI::Workflow::Activity::Skeleton + +=head1 DESCRIPTION + +Tell a little about what this activity does. + +=head1 SYNOPSIS + +See WebGUI::Workflow::Activity for details on how to use any activity. + +=head1 METHODS + +These methods are available from this class: + +=cut + + +#------------------------------------------------------------------- + +=head2 definition ( session, definition ) + +See WebGUI::Workflow::Activity::defintion() for details. + +=cut + +sub definition { + my $class = shift; + my $session = shift; + my $definition = shift; + push(@{$definition}, { + name=>$i18n->get("topicName"), + properties=> { + someField => { + fieldType=>"integer", + label=>"Some Field" + defaultValue=>0, + hoverHelp=>"Hover help for some field." + }, + } + }); + return $class->SUPER::definition($session,$definition); +} + + +#------------------------------------------------------------------- + +=head2 execute ( [ object ] ) + +See WebGUI::Workflow::Activity::execute() for details. + +=cut + +sub execute { + my $self = shift; + # do some work here, whatever this activity is supposed to do +} + + + +1; + + diff --git a/lib/WebGUI/Workflow/Cron.pm b/lib/WebGUI/Workflow/Cron.pm index 9b0ee8596..02b934136 100644 --- a/lib/WebGUI/Workflow/Cron.pm +++ b/lib/WebGUI/Workflow/Cron.pm @@ -246,11 +246,23 @@ sub set { } $self->{_data}{title} = $properties->{title} || $self->{_data}{title} || "Untitled"; $self->{_data}{priority} = $properties->{priority} || $self->{_data}{priority} || 2; - $self->{_data}{minuteOfHour} = $properties->{minuteOfHour} || $self->{_data}{minuteOfHour} || 0; - $self->{_data}{hourOfDay} = $properties->{hourOfDay} || $self->{_data}{hourOfDay} || "*"; $self->{_data}{dayOfMonth} = $properties->{dayOfMonth} || $self->{_data}{dayOfMonth} || "*"; $self->{_data}{monthOfYear} = $properties->{monthOfYear} || $self->{_data}{monthOfYear} || "*"; - $self->{_data}{dayOfWeek} = $properties->{dayOfWeek} || $self->{_data}{dayOfWeek} || "*"; + if ($properties->{minuteOfHour} ne "") { + $self->{_data}{minuteOfHour} = $properties->{minuteOfHour}; + } elsif ($self->{_data}{minuteOfHour} eq "") { + $self->{_data}{minuteOfHour} = "0"; + } + if ($properties->{hourOfDay} ne "") { + $self->{_data}{hourOfDay} = $properties->{hourOfDay}; + } elsif ($self->{_data}{hourOfDay} eq "") { + $self->{_data}{hourOfDay} = "*"; + } + if ($properties->{dayOfWeek} ne "") { + $self->{_data}{dayOfWeek} = $properties->{dayOfWeek}; + } elsif ($self->{_data}{dayOfWeek} eq "") { + $self->{_data}{dayOfWeek} = "*"; + } $self->{_data}{workflowId} = $properties->{workflowId} || $self->{_data}{workflowId}; $self->{_data}{className} = (exists $properties->{className}) ? $properties->{className} : $self->{_data}{className}; $self->{_data}{methodName} = (exists $properties->{methodName}) ? $properties->{methodName} : $self->{_data}{methodName}; diff --git a/lib/WebGUI/i18n/English/Workflow_Activity_CleanFileCache.pm b/lib/WebGUI/i18n/English/Workflow_Activity_CleanFileCache.pm new file mode 100644 index 000000000..69e901b87 --- /dev/null +++ b/lib/WebGUI/i18n/English/Workflow_Activity_CleanFileCache.pm @@ -0,0 +1,30 @@ +package WebGUI::i18n::English::Workflow_Activity_CleanTempStorage; + +our $I18N = { + 'size limit help' => { + message => q|How big should WebGUI allow the file cache to get before pruning down old cache entries?|, + context => q|the hover help for the file cache field|, + lastUpdated => 0, + }, + + 'size limit' => { + message => q|Size Limit|, + context => q|a label indicating how big we're willing to allow the file cache to get on this site|, + lastUpdated => 0, + }, + + 'bytes' => { + message => q|Bytes|, + context => q|The unit of measurement for the size limit field.|, + lastUpdated => 0, + }, + + 'topicName' => { + message => q|Clean File Cache|, + context => q|The name of this workflow activity.|, + lastUpdated => 0, + }, + +}; + +1; diff --git a/lib/WebGUI/i18n/English/Workflow_Activity_CleanLoginHistory.pm b/lib/WebGUI/i18n/English/Workflow_Activity_CleanLoginHistory.pm new file mode 100644 index 000000000..458bb1514 --- /dev/null +++ b/lib/WebGUI/i18n/English/Workflow_Activity_CleanLoginHistory.pm @@ -0,0 +1,24 @@ +package WebGUI::i18n::English::Workflow_Activity_CleanLoginHistory; + +our $I18N = { + 'age to delete help' => { + message => q|After what period of time is it ok to start deleteing entries from the user login history?|, + context => q|the hover help for the age to delete field|, + lastUpdated => 0, + }, + + 'age to delete' => { + message => q|Age To Delete|, + context => q|a label how old we should allow the login history to get|, + lastUpdated => 0, + }, + + 'topicName' => { + message => q|Clean Login History|, + context => q|The name of this workflow activity.|, + lastUpdated => 0, + }, + +}; + +1; diff --git a/lib/WebGUI/i18n/English/Workflow_Activity_DecayKarma.pm b/lib/WebGUI/i18n/English/Workflow_Activity_DecayKarma.pm new file mode 100644 index 000000000..80daa07a1 --- /dev/null +++ b/lib/WebGUI/i18n/English/Workflow_Activity_DecayKarma.pm @@ -0,0 +1,36 @@ +package WebGUI::i18n::English::Workflow_Activity_DecayKarma; + +our $I18N = { + 'decay factor help' => { + message => q|How many points of karma should be removed from a user's account when Decay Karma runs?|, + context => q|the hover help for the decay factor field|, + lastUpdated => 0, + }, + + 'decay factor' => { + message => q|Decay Factor|, + context => q|a label indicating how much karma should be deleted from a user's account per run|, + lastUpdated => 0, + }, + + 'minimum karma help' => { + message => q|What's the minimum amount that a user's karma can decay to?|, + context => q|the hover help for the minimum karma field|, + lastUpdated => 0, + }, + + 'minimum karma' => { + message => q|Minimum Karma|, + context => q|a label indicating the lowest point karma can decay to|, + lastUpdated => 0, + }, + + 'topicName' => { + message => q|Decay Karma|, + context => q|The name of this workflow activity.|, + lastUpdated => 0, + }, + +}; + +1; diff --git a/lib/WebGUI/i18n/English/Workflow_Activity_RollbackVersionTag.pm b/lib/WebGUI/i18n/English/Workflow_Activity_RollbackVersionTag.pm new file mode 100644 index 000000000..2d6893ec0 --- /dev/null +++ b/lib/WebGUI/i18n/English/Workflow_Activity_RollbackVersionTag.pm @@ -0,0 +1,13 @@ +package WebGUI::i18n::English::Workflow_Activity_RollbackVersionTag; + +our $I18N = { + + 'topicName' => { + message => q|Rollback Version Tag|, + context => q|The name of this workflow activity.|, + lastUpdated => 0, + }, + +}; + +1; diff --git a/lib/WebGUI/i18n/English/Workflow_Activity_TrashClipboard.pm b/lib/WebGUI/i18n/English/Workflow_Activity_TrashClipboard.pm new file mode 100644 index 000000000..188af7be8 --- /dev/null +++ b/lib/WebGUI/i18n/English/Workflow_Activity_TrashClipboard.pm @@ -0,0 +1,24 @@ +package WebGUI::i18n::English::Workflow_Activity_TrashClipboard; + +our $I18N = { + 'trash after help' => { + message => q|How long should WebGUI let content sit in the clipboard before moving it to the trash?|, + context => q|the hover help for the trash after field|, + lastUpdated => 0, + }, + + 'trash after' => { + message => q|Trash After|, + context => q|a label indicating how long content should sit in the clipboard|, + lastUpdated => 0, + }, + + 'topicName' => { + message => q|Empty Clipboard to Trash|, + context => q|The name of this workflow activity.|, + lastUpdated => 0, + }, + +}; + +1; diff --git a/sbin/Hourly/CleanFileCache.pm b/sbin/Hourly/CleanFileCache.pm deleted file mode 100644 index a92c7923e..000000000 --- a/sbin/Hourly/CleanFileCache.pm +++ /dev/null @@ -1,30 +0,0 @@ -package Hourly::CleanFileCache; - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2006 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 -#------------------------------------------------------------------- - -use strict; -use WebGUI::Session; -use WebGUI::Cache::FileCache; - -#------------------------------------------------------------------- -sub process { - my $size = $session{config}{fileCacheSizeLimit} + 10; - my $expiresModifier = 0; - my $cache = WebGUI::Cache::FileCache->new; - while ($size > $session{config}{fileCacheSizeLimit}) { - $size = $cache->getNamespaceSize($expiresModifier); - $expiresModifier += 600; # add 10 minutes each pass - } -} - - -1; - diff --git a/sbin/Hourly/CleanLoginHistory.pm b/sbin/Hourly/CleanLoginHistory.pm deleted file mode 100644 index d145907a5..000000000 --- a/sbin/Hourly/CleanLoginHistory.pm +++ /dev/null @@ -1,28 +0,0 @@ -package Hourly::CleanLoginHistory; - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2006 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 -#------------------------------------------------------------------- - - -use strict; -use WebGUI::DateTime; -use WebGUI::Session; -use WebGUI::SQL; - -#----------------------------------------- -sub process { - if ($session{config}{CleanLoginHistory_ageToDelete}) { - WebGUI::SQL->write("delete from userLoginLog - where timeStamp < ".(time()-(86400*$session{config}{CleanLoginHistory_ageToDelete}))); - } -} - -1; - diff --git a/sbin/Hourly/CleanTemp.pm b/sbin/Hourly/CleanTemp.pm deleted file mode 100644 index 717ea6abc..000000000 --- a/sbin/Hourly/CleanTemp.pm +++ /dev/null @@ -1,62 +0,0 @@ -package Hourly::CleanTemp; - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2006 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 -#------------------------------------------------------------------- - -use File::Path; -use File::stat; -use strict; -use WebGUI::Session; - -#----------------------------------------- -# _checkFileAge(filenameWithPath,ageToCheck) -# return: true/false -# checks age of file against specified age and reports true/false -sub _checkFileAge { - my ($filestat, $flag); - $filestat = stat($_[0]) or print "No $_[0]: $!"; - if ((time()-$filestat->mtime) > $_[1]) { - $flag = 1; - } else { - $flag = 0; - } - return $flag; -} - -#----------------------------------------- -# _recurseFileSystem(path, ageOfFilesToDelete) -# recurses the filesystem looking for files to delete -sub _recurseFileSystem { - my (@filelist, $file); - if (opendir(DIR,$_[0])) { - @filelist = readdir(DIR); - closedir(DIR); - foreach $file (@filelist) { - unless ($file eq "." || $file eq "..") { - _recurseFileSystem($_[0].$session{os}{slash}.$file,$_[1]); - if (_checkFileAge($_[0].$session{os}{slash}.$file,$_[1])) { - rmtree($_[0].$session{os}{slash}.$file); - } - } - } - } -} - - - -#----------------------------------------- -sub process { - my $pathToClean = $session{config}{uploadsPath}.$session{os}{slash}."temp"; - my $timeToDie = 86400; - _recurseFileSystem($pathToClean,$timeToDie); -} - -1; - diff --git a/sbin/Hourly/DecayKarma.pm b/sbin/Hourly/DecayKarma.pm deleted file mode 100644 index 943916cfa..000000000 --- a/sbin/Hourly/DecayKarma.pm +++ /dev/null @@ -1,27 +0,0 @@ -package Hourly::DecayKarma; - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2006 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 -#------------------------------------------------------------------- - - -use strict; -use WebGUI::Session; -use WebGUI::SQL; - -#----------------------------------------- -sub process { - if ($session{config}{DecayKarma_minimumKarma} ne "" && $session{config}{DecayKarma_decayFactor}) { - WebGUI::SQL->write("update users set karma=karma-".$session{config}{DecayKarma_decayFactor} - ." where karma > ".$session{config}{DecayKarma_minimumKarma}); - } -} - -1; - diff --git a/sbin/Hourly/DeleteExpiredClipboard.pm b/sbin/Hourly/DeleteExpiredClipboard.pm deleted file mode 100644 index 5e9758fde..000000000 --- a/sbin/Hourly/DeleteExpiredClipboard.pm +++ /dev/null @@ -1,33 +0,0 @@ -package Hourly::DeleteExpiredClipboard; - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2006 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 -#------------------------------------------------------------------- - - -use strict; -use WebGUI::Asset; -use WebGUI::Session; -use WebGUI::SQL; - -#----------------------------------------- -sub process { - if ($session{config}{DeleteExpiredClipboard_offset} ne "") { - my $expireDate = (time()-(86400*$session{config}{DeleteExpiredClipboard_offset})); - my $sth = WebGUI::SQL->read("select assetId,className from asset where state='clipboard' and stateChanged <".$expireDate); - while (my ($id, $class) = $sth->array) { - my $asset = WebGUI::Asset->new($id,$class); - $asset->trash; - } - $sth->finish; - } -} - -1; - diff --git a/sbin/Hourly/_hourlyScript.skeleton b/sbin/Hourly/_hourlyScript.skeleton deleted file mode 100644 index 9d3673fe5..000000000 --- a/sbin/Hourly/_hourlyScript.skeleton +++ /dev/null @@ -1,25 +0,0 @@ -package Hourly::NewHourlyScript; - -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2005 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 -#------------------------------------------------------------------- - - -use strict; -use WebGUI::Asset; -use WebGUI::Session; -use WebGUI::SQL; - -#----------------------------------------- -sub process { - # Perform some action that needs to be done on a periodic basis. -} - -1; -