From d089539ddd20f908d07696a85744c7d1d45db036 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 17 May 2006 20:04:33 +0000 Subject: [PATCH] add email posting without subscription --- docs/changelog/6.x.x.txt | 2 ++ docs/upgrades/upgrade_6.99.0-6.99.1.pl | 8 +++++++ lib/WebGUI/Asset/Post/Thread.pm | 14 ++++++++--- lib/WebGUI/Asset/Wobject/Collaboration.pm | 22 ++++++++++++++++- lib/WebGUI/User.pm | 1 - lib/WebGUI/Workflow/Activity/GetCsMail.pm | 13 +++++++--- .../i18n/English/Asset_Collaboration.pm | 24 +++++++++++++++++++ 7 files changed, 76 insertions(+), 8 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index a0b0e969d..b63bb584e 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -20,6 +20,8 @@ - Added a 2.7% speed increase by precaching i18n messages. This should also help increase shared memory amongst Apache children. (Matt Wilson) - fix [ 1488921 ] Help: Commerce, Manage + - Added two new mail posting properties to the collaboration system to get + around a couple of problems clients have brought up. 6.99.0 - Added an Events Management System asset that can help people run diff --git a/docs/upgrades/upgrade_6.99.0-6.99.1.pl b/docs/upgrades/upgrade_6.99.0-6.99.1.pl index f44372cce..3e363af9c 100644 --- a/docs/upgrades/upgrade_6.99.0-6.99.1.pl +++ b/docs/upgrades/upgrade_6.99.0-6.99.1.pl @@ -22,9 +22,17 @@ my $session = start(); # this line required fixTypos($session); updateTemplates(); +csFixes(); finish($session); # this line required +#------------------------------------------------- +sub csFixes { + print "\tFixing CS stuff.\n" unless ($quiet); + $session->db->write("alter table Collaboration add column autoSubscribeToThread int not null default 1"); + $session->db->write("alter table Collaboration add column requireSubscriptionForEmailPosting int not null default 1"); +} + #------------------------------------------------- sub updateTemplates { print "\tFixing template problems\n" unless ($quiet); diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index 13f1aa9e6..62f9249a1 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -22,6 +22,16 @@ use WebGUI::Utility; our @ISA = qw(WebGUI::Asset::Post); +#------------------------------------------------------------------- +sub addRevision { + my $self = shift; + my $newSelf = $self->SUPER::addRevision(@_); + if ($newSelf->get("subscriptionGroupId") eq "") { + $newSelf->createSubscriptionGroup; + } + return $newSelf; +} + #------------------------------------------------------------------- sub archive { my $self = shift; @@ -514,9 +524,6 @@ sub prepareView { sub processPropertiesFromFormPost { my $self = shift; $self->SUPER::processPropertiesFromFormPost; - if ($self->get("subscriptionGroupId") eq "") { - $self->createSubscriptionGroup; - } if ($self->session->form->process("assetId") eq "new") { $self->getParent->incrementThreads($self->get("dateUpdated"),$self->getId) unless ($self->isReply); } @@ -527,6 +534,7 @@ sub processPropertiesFromFormPost { } } + #------------------------------------------------------------------- sub purge { my $self = shift; diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index 5a47c3c68..58c36065b 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -304,6 +304,14 @@ sub definition { label => $i18n->get("visitor cache timeout"), hoverHelp => $i18n->get("visitor cache timeout help") }, + autoSubscribeToThread => { + fieldType=>"yesNo", + defaultValue=>1 + }, + requireSubscriptionForEmailPosting => { + fieldType=>"yesNo", + defaultValue=>1 + }, approvalWorkflow =>{ fieldType=>"workflow", defaultValue=>"pbworkflow000000000003" @@ -542,7 +550,19 @@ sub getEditForm { label=>$i18n->get("mail prefix"), hoverHelp=>$i18n->get("mail prefix help"), ); - $tabform->getTab("display")->interval( + $tabform->getTab("mail")->yesNo( + name=>"autoSubscribeToThread", + value=>$self->getValue("autoSubscribeToThread"), + label=>$i18n->get("auto subscribe to thread"), + hoverHelp=>$i18n->get("auto subscribe to thread help"), + ); + $tabform->getTab("mail")->yesNo( + name=>"requireSubscriptionForEmailPosting", + value=>$self->getValue("requireSubscriptionForEmailPosting"), + label=>$i18n->get("require subscription for email posting"), + hoverHelp=>$i18n->get("require subscription for email posting help"), + ); + $tabform->getTab("display")->interval( -name=>"visitorCacheTimeout", -label=>$i18n->get('visitor cache timeout'), -hoverHelp=>$i18n->get('visitor cache timeout help'), diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index 191a209c9..d18609642 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -256,7 +256,6 @@ sub isInGroup { return 1 if ($gid eq '7'); # everyone is in the everyone group return 1 if ($gid eq '1' && $uid eq '1'); # visitors are in the visitors group return 1 if ($gid eq '2' && $uid ne '1'); # if you're not a visitor, then you're a registered user - return 1 if ($uid eq '3'); #Admin is in every group ### Get data for auxillary checks. my $isInGroup = $self->session->stow->get("isInGroup"); ### Look to see if we've already looked up this group. diff --git a/lib/WebGUI/Workflow/Activity/GetCsMail.pm b/lib/WebGUI/Workflow/Activity/GetCsMail.pm index 7fede6f2f..d3e9541b4 100644 --- a/lib/WebGUI/Workflow/Activity/GetCsMail.pm +++ b/lib/WebGUI/Workflow/Activity/GetCsMail.pm @@ -123,6 +123,7 @@ sub addPost { } $post->postProcess; $post->requestCommit; + return $post; } #------------------------------------------------------------------- @@ -190,10 +191,16 @@ sub execute { my $id = $1; $post = WebGUI::Asset->newByDynamicClass($self->session, $id); } - if (defined $post && $cs->get("allowReplies") && $user->isInGroup($cs->get("postGroupId")) && ($user->isInGroup($cs->get("subscriptionGroupId")) || $user->isInGroup($post->get("subscriptionGroupId")))) { + if (defined $post && $cs->get("allowReplies") && $user->isInGroup($cs->get("postGroupId")) && (!$cs->get("requireSubscriptionForEmailPosting") || $user->isInGroup($cs->get("subscriptionGroupId")) || $user->isInGroup($post->get("subscriptionGroupId")))) { $self->addPost($post, $message, $user, $cs->get("mailPrefix")); - } elsif ($user->isInGroup($cs->get("postGroupId")) && $user->isInGroup($cs->get("subscriptionGroupId"))) { - $self->addPost($cs, $message, $user, $cs->get("mailPrefix")); + if ($cs->get("autoSubscribeToThread") && !($user->isInGroup($cs->get("subscriptionGroupId")) || $user->isInGroup($post->get("subscriptionGroupId")))) { + $user->addToGroups([$post->getThread->get("subscriptionGroupId")]); + } + } elsif ($user->isInGroup($cs->get("postGroupId")) && (!$cs->get("requireSubscriptionForEmailPosting") || $user->isInGroup($cs->get("subscriptionGroupId")))) { + my $thread = $self->addPost($cs, $message, $user, $cs->get("mailPrefix")); + if ($cs->get("autoSubscribeToThread") && !$user->isInGroup($cs->get("subscriptionGroupId"))) { + $user->addToGroups([$thread->get("subscriptionGroupId")]); + } } else { my $send = WebGUI::Mail::Send->create($self->session, { to=>$message->{from}, diff --git a/lib/WebGUI/i18n/English/Asset_Collaboration.pm b/lib/WebGUI/i18n/English/Asset_Collaboration.pm index 80d80f754..e3137e05a 100644 --- a/lib/WebGUI/i18n/English/Asset_Collaboration.pm +++ b/lib/WebGUI/i18n/English/Asset_Collaboration.pm @@ -14,6 +14,30 @@ our $I18N = { context => q|thread link| }, + 'require subscription for email posting' => { + message => q|Require subscription for email posts?|, + lastUpdated => 0, + context => q|field label for mail setting| + }, + + 'require subscription for email posting help' => { + message => q|If this is set to yes, then the user not only has to be in the group to post, but must also be subscribed to the collaboration system or thread in order to post to it.|, + lastUpdated => 0, + context => q|help for mail setting field label| + }, + + 'auto subscribe to thread' => { + message => q|Auto subscribe to thread?|, + lastUpdated => 0, + context => q|field label for mail setting| + }, + + 'auto subscribe to thread help' => { + message => q|If the user is not subscribed to a thread, nor the collaboration system, and they post to the CS via email, should the be subscribed to the thread? If this is set to yes, they will be. Note that this option only works if the 'Require subscription for email posts?' field is set to 'no'.|, + lastUpdated => 0, + context => q|help for mail setting field label| + }, + 'mail prefix' => { message => q|Prefix|, lastUpdated => 0,