diff --git a/docs/upgrades/upgrade_6.8.7-6.99.0.pl b/docs/upgrades/upgrade_6.8.7-6.99.0.pl index cb6466739..874a9c6c3 100644 --- a/docs/upgrades/upgrade_6.8.7-6.99.0.pl +++ b/docs/upgrades/upgrade_6.8.7-6.99.0.pl @@ -129,7 +129,7 @@ sub addWorkflow { None=>["WebGUI::Workflow::Activity::DecayKarma", "WebGUI::Workflow::Activity::TrashClipboard", "WebGUI::Workflow::Activity::CleanTempStorage", "WebGUI::Workflow::Activity::CleanFileCache", "WebGUI::Workflow::Activity::CleanLoginHistory", "WebGUI::Workflow::Activity::ArchiveOldThreads", "WebGUI::Workflow::Activity::TrashExpiredEvents", "WebGUI::Workflow::Activity::CreateCronJob", "WebGUI::Workflow::Activity::DeleteExpiredSessions", - "WebGUI::Workflow::Activity::DeleteExpiredGroupings", "WebGUI::Workflow::Activity::PurgeOldAssetRevisions", + "WebGUI::Workflow::Activity::ExpireGroupings", "WebGUI::Workflow::Activity::PurgeOldAssetRevisions", "WebGUI::Workflow::Activity::ExpireSubscriptionCodes", "WebGUI::Workflow::Activity::PurgeOldTrash", "WebGUI::Workflow::Activity::GetSyndicatedContent"], "WebGUI::User"=>["WebGUI::Workflow::Activity::CreateCronJob"], @@ -153,8 +153,8 @@ sub addWorkflow { $activity = $workflow->addActivity("WebGUI::Workflow::Activity::TrashExpiredEvents", "pbwfactivity0000000006"); $activity->set("title", "Trash old Events Calendar Events"); $activity->set("trashAfter", 60*60*24*30); - $activity = $workflow->addActivity("WebGUI::Workflow::Activity::DeleteExpiredGroupings", "pbwfactivity0000000007"); - $activity->set("title", "Delete groupings that have expired"); + $activity = $workflow->addActivity("WebGUI::Workflow::Activity::ExpireGroupings", "pbwfactivity0000000007"); + $activity->set("title", "deal with user groupings that have expired"); $activity = $workflow->addActivity("WebGUI::Workflow::Activity::ExpireSubscriptionCodes", "pbwfactivity0000000011"); $activity->set("title", "Expire old subscription codes"); WebGUI::Workflow::Cron->create($session, { diff --git a/lib/WebGUI/Workflow/Activity/DeleteExpiredGroupings.pm b/lib/WebGUI/Workflow/Activity/ExpireGroupings.pm similarity index 65% rename from lib/WebGUI/Workflow/Activity/DeleteExpiredGroupings.pm rename to lib/WebGUI/Workflow/Activity/ExpireGroupings.pm index 00d10176a..094e6ce3a 100644 --- a/lib/WebGUI/Workflow/Activity/DeleteExpiredGroupings.pm +++ b/lib/WebGUI/Workflow/Activity/ExpireGroupings.pm @@ -1,4 +1,4 @@ -package WebGUI::Workflow::Activity::DeleteExpiredGroupings; +package WebGUI::Workflow::Activity::ExpireGroupings; =head1 LEGAL @@ -17,15 +17,16 @@ package WebGUI::Workflow::Activity::DeleteExpiredGroupings; use strict; use base 'WebGUI::Workflow::Activity'; -use WebGUI::Cache::FileCache; +use WebGUI::Inbox; +use WebGUI::International; =head1 NAME -Package WebGUI::Workflow::Activity::DeleteExpiredGroupings; +Package WebGUI::Workflow::Activity::ExpireGroupings =head1 DESCRIPTION -Deletes user groupings that are past their expire date. +Handles expiring user groupings. =head1 SYNOPSIS @@ -50,9 +51,9 @@ sub definition { my $class = shift; my $session = shift; my $definition = shift; - my $i18n = WebGUI::International->new($session, "Workflow_Activity_DeleteExpiredGroupings"); + my $i18n = WebGUI::International->new($session, "WebGUI"); push(@{$definition}, { - name=>$i18n->get("topicName"), + name=>$i18n->get("expire groupings"), properties=> {} }); return $class->SUPER::definition($session,$definition); @@ -69,6 +70,22 @@ See WebGUI::Workflow::Activity::execute() for details. sub execute { my $self = shift; + my $now = time(); + my $inbox = WebGUI::Inbox->new($self->session); + my $i18n = WebGUI::International->new($self->session, "WebGUI"); + my $a = $self->session->db->read("select groupId,expireNotifyOffset,expireNotifyMessage from groups where expireNotify=1"); + while (my $group = $a->hashRef) { + my $start = $now + (86400 * ($group->{expireNotifyOffset}-1)); + my $end = $start + 86400; + my $b = $self->session->db->read("select userId from groupings where groupId=? and expireDate>=? and expireDate<=?", [$group->{groupId}, $start, $end]); + while (my ($userId) = $b->array) { + $inbox->addMessage({ + userId=>$userId, + subject=>$i18n->get(867), + message=>$group->{expireNotifyMessage} + }); + } + } my $sth = $self->session->db->read("select groupId,deleteOffset,dbCacheTimeout from groups"); while (my $data = $sth->hashRef) { if ($data->{dbCacheTimeout} > 0) { diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index 99bc1c8f8..93085e82a 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -1,6 +1,11 @@ package WebGUI::i18n::English::WebGUI; our $I18N = { + 'expire groupings' => { + message => q|Expire User Groupings|, + lastUpdated => 0 + }, + 'show performance indicators' => { message => q|Show performance indicators?|, lastUpdated => 0 diff --git a/lib/WebGUI/i18n/English/Workflow_Activity_DeleteExpiredGroupings.pm b/lib/WebGUI/i18n/English/Workflow_Activity_DeleteExpiredGroupings.pm deleted file mode 100644 index 35c20f8d0..000000000 --- a/lib/WebGUI/i18n/English/Workflow_Activity_DeleteExpiredGroupings.pm +++ /dev/null @@ -1,12 +0,0 @@ -package WebGUI::i18n::English::Workflow_Activity_DeleteExpiredGroupings; - -our $I18N = { - 'topicName' => { - message => q|Delete Expired Groupings|, - context => q|The name of this workflow activity.|, - lastUpdated => 0, - }, - -}; - -1; diff --git a/sbin/Hourly/NotifyExpiredGroupings.pm b/sbin/Hourly/NotifyExpiredGroupings.pm deleted file mode 100644 index d929f3298..000000000 --- a/sbin/Hourly/NotifyExpiredGroupings.pm +++ /dev/null @@ -1,44 +0,0 @@ -package Hourly::NotifyExpiredGroupings; - -#------------------------------------------------------------------- -# 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::International; -use WebGUI::MessageLog; -use WebGUI::Session; -use WebGUI::SQL; - -#----------------------------------------- -sub process { - my $verbose = shift; - my @date = WebGUI::DateTime::localtime(WebGUI::DateTime::time()); - if ($date[3] == 1) { # only occurs at 1am on the day in question. - my $now = WebGUI::DateTime::time(); - my $a = WebGUI::SQL->read("select groupId,expireNotifyOffset,expireNotifyMessage from groups - where expireNotify=1"); - while (my $group = $a->hashRef) { - my $start = $now + (86400 * ($group->{expireNotifyOffset}-1)); - my $end = $start + 86400; - my $b = WebGUI::SQL->read("select userId from groupings where groupId=".quote($group->{groupId})." and - expireDate>=".$start." and expireDate<=".$end); - while (my ($userId) = $b->array) { - WebGUI::MessageLog::addEntry($userId,"",WebGUI::International::get(867),$group->{expireNotifyMessage}); - print "\n\t\tNotified ".$userId." about ".$group->{groupId} if ($verbose); - } - $b->finish; - } - $a->finish; - } -} - -1; -