From 08d0efe0604ccd66a3ccf8da5f8a7ef77eb2adef Mon Sep 17 00:00:00 2001 From: JT Smith Date: Mon, 10 Apr 2006 02:02:19 +0000 Subject: [PATCH] getting close to having a working email to discussion system --- docs/upgrades/upgrade_6.8.8-6.99.0.pl | 10 ++++++ lib/WebGUI/Asset/Wobject/Collaboration.pm | 37 +++++++++++++++++++++++ lib/WebGUI/Workflow/Activity/GetCsMail.pm | 3 ++ 3 files changed, 50 insertions(+) diff --git a/docs/upgrades/upgrade_6.8.8-6.99.0.pl b/docs/upgrades/upgrade_6.8.8-6.99.0.pl index 2e6a82915..f206d5c73 100644 --- a/docs/upgrades/upgrade_6.8.8-6.99.0.pl +++ b/docs/upgrades/upgrade_6.8.8-6.99.0.pl @@ -191,6 +191,16 @@ sub updateCs { $session->db->write("alter table Collaboration add column mailPrefix varchar(255)"); $session->db->write("alter table Collaboration add column getMail int not null default 0"); $session->db->write("alter table Collaboration add column getMailInterval int not null default 300"); + $session->db->write("alter table Collaboration add column getMailCronId varchar(22) binary"); + my $workflow = WebGUI::Workflow->create($session, { + isSerial=>1, + type=>"WebGUI::Asset::Wobject::Collaboration", + enabled=>1, + description=>"Retrieves mail from a POP3 account for the given Collaboration System.", + title=>"Get CS Mail" + }, "csworkflow000000000001"); + my $activity = $workflow->addActivity("WebGUI::Workflow::Activity::GetCsMail","csactivity000000000001"); + $activity->set("title","Get the mail"); } #------------------------------------------------- diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index 3ae573a6a..4d61d759b 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -19,6 +19,7 @@ use WebGUI::International; use WebGUI::Paginator; use WebGUI::Utility; use WebGUI::Asset::Wobject; +use WebGUI::Workflow::Cron; our @ISA = qw(WebGUI::Asset::Wobject); @@ -195,6 +196,33 @@ sub canView { return $self->SUPER::canView || $self->canPost; } +#------------------------------------------------------------------- +sub commit { + my $self = shift; + $self->SUPER::commit; + my $cron = undef; + if ($self->get("getMailCronId")) { + $cron = WebGUI::Workflow::Cron->new($self->session, $self->get("getMailCronId")); + } + my $i18n = WebGUI::International->new($self->session, "Asset_Collaboration"); + unless (defined $cron) { + $cron = WebGUI::Workflow::Cron->create($self->session, { + title=>$self->getTitle." ".$i18n->get("mail"), + minuteOfHour=>"*/".($self->get("getMailInterval")/60), + className=>"WebGUI::Asset::Wobject::Collaboration", + methodName=>"new", + parameters=>$self->getId, + workflowId=>"csworkflow000000000001" + }); + $self->update({getMailCronId=>$cron->getId}); + } + if ($self->get("getMail")) { + $cron->set({enabled=>1,title=>$self->getTitle." ".$i18n->get("mail"), minuteOfHour=>"*/".($self->get("getMailInterval")/60)}); + } else { + $cron->set({enabled=>0,title=>$self->getTitle." ".$i18n->get("mail"), minuteOfHour=>"*/".($self->get("getMailInterval")/60)}); + } +} + #------------------------------------------------------------------- sub createSubscriptionGroup { my $self = shift; @@ -277,6 +305,11 @@ sub definition { fieldType=>"email", defaultValue=>undef }, + getMailCronId=>{ + fieldType=>"hidden", + defaultValue=>undef, + noFormPost=>1 + }, getMail=>{ fieldType=>"yesNo", defaultValue=>0 @@ -895,6 +928,10 @@ sub purge { my $self = shift; my $group = WebGUI::Group->new($self->session, $self->get("subscriptionGroupId")); $group->delete; + if ($self->get("getMailCronId")) { + my $cron = WebGUI::Workflow::Cron->new($self->session, $self->get("getMailCronId")); + $cron->delete if defined $cron; + } $self->SUPER::purge; } diff --git a/lib/WebGUI/Workflow/Activity/GetCsMail.pm b/lib/WebGUI/Workflow/Activity/GetCsMail.pm index 1d2e2472d..37783bc6b 100644 --- a/lib/WebGUI/Workflow/Activity/GetCsMail.pm +++ b/lib/WebGUI/Workflow/Activity/GetCsMail.pm @@ -18,7 +18,10 @@ package WebGUI::Workflow::Activity::GetCsMail; use strict; use base 'WebGUI::Workflow::Activity'; use WebGUI::Mail::Get; +use WebGUI::Mail::Send; use WebGUI::Asset; +use WebGUI::International; +use WebGUI::User; =head1 NAME