workflow activity to notify admins of old version tags; start thread group in CS

This commit is contained in:
James Tolley 2007-07-09 20:02:09 +00:00
parent 6e0470771e
commit e1de42261d
8 changed files with 330 additions and 2 deletions

View file

@ -0,0 +1,82 @@
#PBtmpl0000000000000026
<a name="id<tmpl_var assetId>" id="id<tmpl_var assetId>"></a>
<tmpl_if session.var.adminOn>
<p><tmpl_var controls></p>
</tmpl_if>
<tmpl_if displayTitle>
<h2><tmpl_var title></h2>
</tmpl_if>
<tmpl_if description>
<tmpl_var description>
</tmpl_if>
<p>
<tmpl_if user.canStartThread>
<a href="<tmpl_var add.url>"><tmpl_var add.label></a>
&#149;
</tmpl_if>
<tmpl_unless user.isVisitor>
<tmpl_if user.isSubscribed>
<a href="<tmpl_var unsubscribe.url>"><tmpl_var unsubscribe.label></a>
<tmpl_else>
<a href="<tmpl_var subscribe.url>"><tmpl_var subscribe.label></a>
</tmpl_if>
&#149;
</tmpl_unless>
<a href="<tmpl_var search.url>"><tmpl_var search.label></a>
</p>
<table width="100%">
<tr>
<tmpl_if user.isModerator>
<td class="forumHead"><tmpl_var status.label></td>
</tmpl_if>
<td class="forumHead"><tmpl_var subject.label></td>
<td class="forumHead"><tmpl_var user.label></td>
<td class="forumHead"><a href="<tmpl_var sortby.views.url>"><tmpl_var views.label></a></td>
<td class="forumHead"><a href="<tmpl_var sortby.replies.url>"><tmpl_var replies.label></a></td>
<td class="forumHead"><a href="<tmpl_var sortby.rating.url>"><tmpl_var rating.label></a></td>
<td class="forumHead"><a href="<tmpl_var sortby.date.url>"><tmpl_var date.label></a></td>
<tmpl_if displayLastReply>
<td class="forumHead"><a href="<tmpl_var sortby.lastreply.url>"><tmpl_var lastReply.label></a></td>
</tmpl_if>
</tr>
<tmpl_loop post_loop>
<tr>
<tmpl_if user.isModerator>
<td class="<tmpl_if __ODD__>oddThread<tmpl_else>evenThread</tmpl_if>"><tmpl_var status></td>
</tmpl_if>
<td class="<tmpl_if __ODD__>oddThread<tmpl_else>evenThread</tmpl_if>"><a href="<tmpl_var url>"><tmpl_var title></a></td>
<tmpl_if user.isVisitor>
<td class="<tmpl_if __ODD__>oddThread<tmpl_else>evenThread</tmpl_if>"><tmpl_var username></td>
<tmpl_else>
<td class="<tmpl_if __ODD__>oddThread<tmpl_else>evenThread</tmpl_if>"><a href="<tmpl_var userProfile.url>"><tmpl_var username></a></td>
</tmpl_if>
<td class="<tmpl_if __ODD__>oddThread<tmpl_else>evenThread</tmpl_if>" align="center"><tmpl_var views></td>
<td class="<tmpl_if __ODD__>oddThread<tmpl_else>evenThread</tmpl_if>" align="center"><tmpl_var replies></td>
<td class="<tmpl_if __ODD__>oddThread<tmpl_else>evenThread</tmpl_if>" align="center"><tmpl_var rating></td>
<td class="<tmpl_if __ODD__>oddThread<tmpl_else>evenThread</tmpl_if>"><tmpl_var dateSubmitted.human> @ <tmpl_var timeSubmitted.human></td>
<tmpl_if displayLastReply>
<td class="<tmpl_if __ODD__>oddThread<tmpl_else>evenThread</tmpl_if>" style="font-size: 11px;">
<a href="<tmpl_var lastReply.url>"><tmpl_var lastReply.title></a>
by
<tmpl_if lastReply.user.isVisitor>
<tmpl_var lastReply.username>
<tmpl_else>
<a href="<tmpl_var lastReply.userProfile.url>"><tmpl_var lastReply.username></a>
</tmpl_if>
on <tmpl_var lastReply.dateSubmitted.human> @ <tmpl_var lastReply.timeSubmitted.human>
</td>
</tmpl_if>
</tr>
</tmpl_loop>
</table>
<tmpl_if pagination.pageCount.isMultiple>
<div class="pagination">
<tmpl_var pagination.previousPage> &#183; <tmpl_var pagination.pageList.upTo10> &#183; <tmpl_var pagination.nextPage>
</div>
</tmpl_if>

View file

@ -31,9 +31,26 @@ addUserInvitations($session);
addPrivateMessaging($session);
addNewsletter($session);
addHttpProxyUrlPatternFilter($session);
addCanStartThreadToCS($session);
finish($session); # this line required
#-------------------------------------------------
sub addCanStartThreadToCS {
my $session = shift;
# add the columns required
$session->db->write("ALTER TABLE Collaboration add column canStartThreadGroupId varchar(22) NOT NULL default 2 AFTER postGroupId");
$session->db->write("ALTER TABLE Collaboration add column threadApprovalWorkflow varchar(22) NOT NULL default 'pbworkflow000000000003' AFTER approvalWorkflow");
# set defaults for existing records
$session->db->write('UPDATE Collaboration SET canStartThreadGroupId = postGroupId');
$session->db->write('UPDATE Collaboration SET threadApprovalWorkflow = approvalWorkflow');
return;
}
#-------------------------------------------------
sub addKeywordTagging {
my $session = shift;

View file

@ -412,7 +412,7 @@
"WebGUI::Workflow::Activity::GetSyndicatedContent", "WebGUI::Workflow::Activity::ProcessRecurringPayments",
"WebGUI::Workflow::Activity::SyncProfilesToLdap", "WebGUI::Workflow::Activity::SummarizePassiveProfileLog",
"WebGUI::Workflow::Activity::SendQueuedMailMessages","WebGUI::Workflow::Activity::CleanDatabaseCache",
"WebGUI::Workflow::Activity::CalendarUpdateFeeds"],
"WebGUI::Workflow::Activity::CalendarUpdateFeeds","WebGUI::Workflow::Activity::NotifyAdminsWithOpenVersionTags"],
"WebGUI::User" : ["WebGUI::Workflow::Activity::CreateCronJob", "WebGUI::Workflow::Activity::NotifyAboutUser"],
"WebGUI::VersionTag" : ["WebGUI::Workflow::Activity::CommitVersionTag", "WebGUI::Workflow::Activity::RollbackVersionTag",
"WebGUI::Workflow::Activity::TrashVersionTag", "WebGUI::Workflow::Activity::CreateCronJob",

View file

@ -289,6 +289,21 @@ sub canSubscribe {
return ($self->session->user->userId ne "1" && $self->canView);
}
#-------------------------------------------------------------------
sub canStartThread {
my $self = shift;
return (
(
$self->get("status") eq "approved" ||
$self->getTagCount > 1 # checks to make sure that the cs has been committed at least once
) && (
$self->session->user->isInGroup($self->get("canStartThreadGroupId"))
|| $self->SUPER::canEdit
)
);
}
#-------------------------------------------------------------------
sub canView {
my $self = shift;
@ -393,6 +408,14 @@ sub definition {
label=>$i18n->get('approval workflow'),
hoverHelp=>$i18n->get('approval workflow description'),
},
threadApprovalWorkflow =>{
fieldType=>"workflow",
defaultValue=>"pbworkflow000000000003",
type=>'WebGUI::VersionTag',
tab=>'security',
label=>$i18n->get('thread approval workflow'),
hoverHelp=>$i18n->get('thread approval workflow description'),
},
thumbnailSize => {
fieldType => "integer",
defaultValue => 0,
@ -683,6 +706,13 @@ sub definition {
label=>$i18n->get('who posts'),
hoverHelp=>$i18n->get('who posts description'),
},
canStartThreadGroupId =>{
fieldType=>"group",
defaultValue=>'2',
tab=>'security',
label=>$i18n->get('who threads'),
hoverHelp=>$i18n->get('who threads description'),
},
defaultKarmaScale => {
fieldType=>"integer",
defaultValue=>1,
@ -904,6 +934,7 @@ sub getViewTemplateVars {
$sortOrder ||= "desc";
my %var;
$var{'user.canPost'} = $self->canPost;
$var{'user.canStartThread'} = $self->canStartThread;
$var{"add.url"} = $self->getNewThreadUrl;
$var{"rss.url"} = $self->getRssUrl;
$var{'user.isModerator'} = $self->canModerate;
@ -1039,7 +1070,7 @@ See WebGUI::Asset::prepareView() for details.
sub prepareView {
my $self = shift;
$self->SUPER::prepareView();
my $template = WebGUI::Asset::Template->new($self->session, $self->get("collaborationTemplateId"));
my $template = WebGUI::Asset::Template->new($self->session, $self->get("collaborationTemplateId")) or die "no good: ".$self->get("collaborationTemplateId");
$self->session->style->setLink($self->getRssUrl,{ rel=>'alternate', type=>'application/rss+xml', title=>'RSS' });
$template->prepare;
$self->{_viewTemplate} = $template;

View file

@ -61,11 +61,21 @@ our $HELP = {
description => 'who posts description',
namespace => 'Asset_Collaboration',
},
{
title => 'who threads',
description => 'who threads description',
namespace => 'Asset_Collaboration',
},
{
title => 'approval workflow',
description => 'approval workflow description',
namespace => 'Asset_Collaboration',
},
{
title => 'thread approval workflow',
description => 'thread approval workflow description',
namespace => 'Asset_Collaboration',
},
{
title => 'threads/page',
description => 'threads/page description',

View file

@ -0,0 +1,128 @@
package WebGUI::Workflow::Activity::NotifyAdminsWithOpenVersionTags;
=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::Mail::Send;
=head1 NAME
Package WebGUI::Workflow::Activity::NotifyAdminsWithOpenVersionTags
=head1 DESCRIPTION
This sends out notifications to all users that have an uncommitted tag. It only does this if the version tags are empty. It takes an arg which specifies the length of time a tag should be outstanding before sending the notification. The default is 3 days.
=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_NotifyAdminsWithOpenVersionTags");
push(@{$definition}, {
name => $i18n->get('activityName'),
properties => {
daysLeftOpen => {
fieldType => 'integer',
label => $i18n->get('days left open label'),
defaultValue => 3,
hoverHelp => $i18n->get('days left open hoverhelp'),
},
}
});
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------
=head2 execute ( [ object ] )
See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
my $i18n = WebGUI::International->new($self->session, "Workflow_Activity_NotifyAdminsWithOpenVersionTags");
my $daysLeftOpen = $self->get('daysLeftOpen') + 0;
my $sql = <<"ENDSQL";
SELECT email, count(distinct(tagId)) AS count
FROM assetVersionTag
JOIN assetData USING (tagId)
JOIN userProfileData ON assetVersionTag.createdBy = userProfileData.userId
WHERE isCommitted = 0
AND DATE_ADD(FROM_UNIXTIME(creationDate), INTERVAL $daysLeftOpen DAY) < NOW()
GROUP BY userId
ENDSQL
my $dataArrayRef = $self->session->db->buildArrayRefOfHashRefs($sql);
for my $userHashRef (@$dataArrayRef) {
$self->_notify($userHashRef, $i18n);
}
return $self->COMPLETE;
}
# send an email to an admin about their open version tags
sub _notify {
my $self = shift;
my $dataHashRef = shift;
my $i18n = shift;
my $hostname = $self->session->config->get('sitename')->[0];
my($from) = $self->session->db->quickScalar(" SELECT email FROM userProfileData WHERE userId = 3 ");
my $s = $dataHashRef->{count} > 1 ? 's' : '';
my $subject = sprintf($i18n->get('email subject'), $s, $hostname);
my $mail = WebGUI::Mail::Send->create($self->session, {
from => $from,
to => $dataHashRef->{email},
subject => $subject,
});
my $html = sprintf $i18n->get('email message'), $dataHashRef->{count}, $s, $hostname, $hostname;
$mail->addHtml($html);
$mail->send();
}
1;

View file

@ -645,6 +645,11 @@ our $I18N = {
lastUpdated => 1109698614,
},
'who threads' => {
message => q|Who can post a thread?|,
lastUpdated => 1109698614,
},
'threads/page' => {
message => q|Threads Per Page|,
lastUpdated => 1109698614,
@ -1106,11 +1111,26 @@ properties listed below:</p>
lastUpdated => 0,
},
'thread approval workflow description' => {
message => q|Choose a workflow to be executed on each thread as it gets submitted.|,
lastUpdated => 0,
},
'thread approval workflow' => {
message => q|Thread Approval Workflow|,
lastUpdated => 0,
},
'who posts description' => {
message => q|The group allowed to submit posts to this Asset.|,
lastUpdated => 1119070429,
},
'who threads description' => {
message => q|The group allowed to start a thread in this Asset.|,
lastUpdated => 1119070429,
},
'threads/page description' => {
message => q|The number of threads displayed on each page in the system template.
Setting this number very high can slow the generation of the page.|,

View file

@ -0,0 +1,40 @@
package WebGUI::i18n::English::Workflow_Activity_NotifyAdminsWithOpenVersionTags; ##Be sure to change the package name to match the filename
our $I18N = { ##hashref of hashes
'days left open label' => {
message => q|Days Left Open|,
lastUpdated => 0,
context => q||,
},
'days left open hoverhelp' => {
message => q|The number of days a version tag needs to be left open before a notification is sent to its user.|,
lastUpdated => 0,
context => q||,
},
'email subject' => {
message => q|Uncommitted version tag%s on %s|,
lastUpdated => 0,
context => q||,
},
'email message' => {
message => q|You have %d uncommitted version tag%s on %s.<p/>Please <a href="http://%s/?op=manageVersions">process them</a>.<p/>Thank you.|,
lastUpdated => 0,
context => q||,
},
#If the help file documents an Asset, it must include an assetName key
#If the help file documents an Macro, it must include an macroName key
#If the help file documents a Workflow Activity, it must include an activityName key
#If the help file documents a Template Parser, it must include an templateParserName key
#For all other types, use topicName
'activityName' => {
message => q|Notify Admins of Old Version Tags|,
lastUpdated => 1131394072,
},
};
1;