package WebGUI::Workflow::Activity::SendEmailAboutVersionTag; =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; use WebGUI::International; use WebGUI::Macro; use WebGUI::Mail::Send; =head1 NAME Package WebGUI::Workflow::Activity::SendEmailAboutVersionTag =head1 DESCRIPTION Send an email to anyone about a version tag. If this version tag contains only one asset, then a URL to that asset will be included in the message automatically. =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_SendEmailAboutVersionTag"); push(@{$definition}, { name=>$i18n->get("activityName"), properties=> { to => { fieldType=>"text", label=>$i18n->get("to"), defaultValue=>$session->setting->get("companyEmail"), hoverHelp=>$i18n->get("to help") }, subject => { fieldType=>"text", label=>$i18n->get("subject"), defaultValue=>undef, hoverHelp=>$i18n->get("subject help") }, message => { fieldType=>"textarea", label=>$i18n->get("message"), defaultValue=>undef, hoverHelp=>$i18n->get("message help") }, } }); return $class->SUPER::definition($session,$definition); } #------------------------------------------------------------------- =head2 execute ( ) See WebGUI::Workflow::Activity::execute() for details. =cut sub execute { my $self = shift; my $versionTag = shift; my $inbox = WebGUI::Inbox->new($self->session); my $urlOfSingleAsset = ""; my $message = $self->get("message"); WebGUI::Macro::process(\$message); my $to = $self->get("to"); WebGUI::Macro::process(\$to); my $subject = $self->get("subject"); WebGUI::Macro::process(\$subject); if ($versionTag->getAssetCount) { # if there's only one asset in the tag, we might as well give them a direct link to it my $asset = $versionTag->getAssets->[0]; $urlOfSingleAsset = "\n\n".$self->session->url->getSiteURL().$asset->getUrl("func=view;revision=".$asset->get("revisionDate")); } my $mail = WebGUI::Mail::Send->create($self->session, { to=>$to, subject=>$subject }); $mail->addText($message.$urlOfSingleAsset); $mail->addFooter; return $mail->send ? $self->COMPLETE : $self->ERROR; } 1;