From 3ad69de404812705cf70b9ad9c5455e881ccba24 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 18 Oct 2010 13:53:33 -0700 Subject: [PATCH] Template the emails sent out during content approval. Includes new template, i18n, Help docs upgrade sub and code. Fixes bug #11901. --- docs/changelog/7.x.x.txt | 1 + ...t_import_workflow-activity-templates.wgpkg | Bin 0 -> 1287 bytes docs/upgrades/upgrade_7.10.2-7.10.3.pl | 22 ++++++++ ...Workflow_Activity_NotifyAboutVersionTag.pm | 20 ++++++++ .../Activity/NotifyAboutVersionTag.pm | 23 +++++++-- .../Activity/RequestApprovalForVersionTag.pm | 22 +++++--- ...Workflow_Activity_NotifyAboutVersionTag.pm | 47 ++++++++++++++++-- 7 files changed, 119 insertions(+), 16 deletions(-) create mode 100644 docs/upgrades/packages-7.10.3/root_import_workflow-activity-templates.wgpkg create mode 100644 lib/WebGUI/Help/Workflow_Activity_NotifyAboutVersionTag.pm diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index dbd2a9a8a..44c6e5fc2 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -9,6 +9,7 @@ - fixed #11898: String eval used in Image::Graph - fixed #11913: Editing the survey doesn't work - fixed #11915: Date macro returns hour value w/ leading space + - fixed #11901: NotifyAboutVersionTag includes URL, even when inappropriate 7.10.2 - fixed #11884: Editing Templates impossible / Code editor not loaded diff --git a/docs/upgrades/packages-7.10.3/root_import_workflow-activity-templates.wgpkg b/docs/upgrades/packages-7.10.3/root_import_workflow-activity-templates.wgpkg new file mode 100644 index 0000000000000000000000000000000000000000..31e32dc6a5c868d126d05551baba9b550c2a5948 GIT binary patch literal 1287 zcmV+i1^D_OiwFP!00000|Ls^?Z{j!<=DEKj%Jb4D+%lkUC3@RodSiN-YBe2ICUL=S zVrOj!N>}sW_rwXrTz_DwgYlK*fS3pZ_F6A`UM3EF|<{xxGYSE|yQHn}SDePJNe%{-36l z*RKBbYMb|h(GPVIw6|Ii?>Ym>ZwTB50 zmD8LtxkaLM|63ErAMQdnsUlyJF_F`%#1SAW0cQ;eNS^TkbG5vCv8Shq_)3BRQ#E5? zPeh+H$>cQ7kTifA6G0%pd&nQ*OA=w0NVU4&atx^Z3XGMo=P56J6eK@-r>qL=~cqVrU#=vw&5_T#%;>PC!I& zf{0_5mS@&63I(cqLLN$$t?jngZa2M};VH*yYBRb&Yafdshr)msFps-74hMSH9A>RT znK9JQvaBTGy)RlHraqs>vcJHTM8jN3yZ6uVDcY|-d>h8Qi0mGojgJQ3wGtvOrUDE< z_eDTQ=!WqK4X}i`g<;lX4Q~|~Gbqh|Mnu+n(O^l(ehtA`)$SYx70-Fes~01~V@{|{ zO}#NSUDvhK^XB))?~RW*&(=CtL*Qj2%tk(v1%k#>{#SS1XZ){GYdLHFw^}6MC%r2F zdxgp^rGPoZ1cLF1fH$ba;AO*CZEqD4SRiXlxZc}{VrshJPzgm`k=Sj~^thc?(EzAd zbqx1NXt`B56m;KLO*L<^;oqZ^5l)ih^RuH{a(a)xC;cNswuI^}V~1trZg$Km?6*@= zcRNPhim(uHl&Zr76CtyA{$25h~v9IZ)`09(CpmUJH>(REo88?w=hE_CD2u6 z>Kj}~m2W?PX}n4~+KfqQak$!-P`|9>X=#&tEWXSvB6{_fapNgrZkhus7B;oIX&T)Mek>YV#FprddPT`5ndx26z&WnMt;V0Gwf7w z^Vk+bTSgc2o0jfpMuF+N)HP;Qr5;QxQEymN&{OxS*LXS~KHWCYdefinition($session)->[0]->{properties}->{templateId}->{defaultValue}; + my $activityList = $session->db->read(q|select activityId from WorkflowActivity|); + while (my ($activityId) = $activityList->array) { + my $activity = WebGUI::Workflow::Activity->new($session, $activityId); + next unless $activity; + next unless $activity->isa('WebGUI::Workflow::Activity::NotifyAboutVersionTag') + || $activity->isa('WebGUI::Workflow::Activity::RequestApprovalForVersionTag') + ; + $activity->set('templateId', $templateId); + } + print "...DONE!\n" unless $quiet; +} + + # -------------- DO NOT EDIT BELOW THIS LINE -------------------------------- #---------------------------------------------------------------------------- diff --git a/lib/WebGUI/Help/Workflow_Activity_NotifyAboutVersionTag.pm b/lib/WebGUI/Help/Workflow_Activity_NotifyAboutVersionTag.pm new file mode 100644 index 000000000..66b215217 --- /dev/null +++ b/lib/WebGUI/Help/Workflow_Activity_NotifyAboutVersionTag.pm @@ -0,0 +1,20 @@ +package WebGUI::Help::Workflow_Activity_NotifyAboutVersionTag; +use strict; + +our $HELP = { + + 'email template' => { + title => 'email template title', + body => '', + variables => [ + { 'name' => 'message' }, + { 'name' => 'comments' }, + { 'name' => 'url' }, + ], + fields => [], + related => [], + }, + +}; + +1; diff --git a/lib/WebGUI/Workflow/Activity/NotifyAboutVersionTag.pm b/lib/WebGUI/Workflow/Activity/NotifyAboutVersionTag.pm index 2df4ae6c2..12b500709 100644 --- a/lib/WebGUI/Workflow/Activity/NotifyAboutVersionTag.pm +++ b/lib/WebGUI/Workflow/Activity/NotifyAboutVersionTag.pm @@ -19,6 +19,7 @@ use strict; use base 'WebGUI::Workflow::Activity'; use WebGUI::VersionTag; use WebGUI::Inbox; +use WebGUI::Asset; =head1 NAME @@ -71,8 +72,15 @@ sub definition { label=> $i18n->get("notify message"), hoverHelp => $i18n->get("notify message help") }, - } - }); + templateId => { + fieldType =>"template", + defaultValue => "lYhMheuuLROK_iNjaQuPKg", + namespace => 'NotifyAboutVersionTag', + label => $i18n->get("email template", 'Workflow_Activity_NotifyAboutVersionTag'), + hoverHelp => $i18n->get("email template help", 'Workflow_Activity_NotifyAboutVersionTag') + }, + } + }); return $class->SUPER::definition($session,$definition); } @@ -95,11 +103,18 @@ sub execute { my $asset = $versionTag->getAssets->[0]; $urlOfSingleAsset = "\n\n".$self->session->url->getSiteURL().$asset->getUrl("func=view;revision=".$asset->get("revisionDate")); } + my $var = { + message => $self->get('message'), + comments => $versionTag->get('comments'), + url => $urlOfSingleAsset, + }; + my $template = WebGUI::Asset->newByDynamicClass($self->session, $self->get('templateId')); + my $message = $template->process($var); my $properties = { status=>"completed", subject=>$versionTag->get("name"), - message=>$self->get("message")."\n\n".$versionTag->get("comments").$urlOfSingleAsset, - }; + message=>$message, + }; if ($self->get("who") eq "committer") { $properties->{userId} = $versionTag->get("committedBy"); } elsif ($self->get("who") eq "creator") { diff --git a/lib/WebGUI/Workflow/Activity/RequestApprovalForVersionTag.pm b/lib/WebGUI/Workflow/Activity/RequestApprovalForVersionTag.pm index f0891d3e6..7186b578c 100644 --- a/lib/WebGUI/Workflow/Activity/RequestApprovalForVersionTag.pm +++ b/lib/WebGUI/Workflow/Activity/RequestApprovalForVersionTag.pm @@ -17,6 +17,7 @@ package WebGUI::Workflow::Activity::RequestApprovalForVersionTag; use strict; use base 'WebGUI::Workflow::Activity'; +use WebGUI::Asset; use WebGUI::VersionTag; use WebGUI::Inbox; use WebGUI::International; @@ -86,6 +87,13 @@ sub definition { hoverHelp => $i18n->get("do on approve help"), none => 1, noneLabel => $i18n->get('continue with workflow'), + }, + templateId => { + fieldType =>"template", + defaultValue => "lYhMheuuLROK_iNjaQuPKg", + namespace => 'NotifyAboutVersionTag', + label => $i18n->get("email template", 'Workflow_Activity_NotifyAboutVersionTag'), + hoverHelp => $i18n->get("email template help", 'Workflow_Activity_NotifyAboutVersionTag') }, }, }; @@ -265,13 +273,13 @@ sub sendMessage { "op=manageRevisionsInTag;workflowInstanceId=" . $instance->getId . ";tagId=" . $versionTag->getId ); - my $messageText - = join "\n\n", - $self->get("message"), - sprintf('%s', $approvalUrl, $approvalUrl,), - $versionTag->get("comments"), - ; - + my $var = { + message => $self->get('message'), + comments => $versionTag->get('comments'), + url => $approvalUrl, + }; + my $template = WebGUI::Asset->newByDynamicClass($self->session, $self->get('templateId')); + my $messageText = $template->process($var); for my $groupId ( @{ $self->getGroupToApprove } ) { my $message = $inbox->addMessage({ diff --git a/lib/WebGUI/i18n/English/Workflow_Activity_NotifyAboutVersionTag.pm b/lib/WebGUI/i18n/English/Workflow_Activity_NotifyAboutVersionTag.pm index ac4320ef5..3863066aa 100644 --- a/lib/WebGUI/i18n/English/Workflow_Activity_NotifyAboutVersionTag.pm +++ b/lib/WebGUI/i18n/English/Workflow_Activity_NotifyAboutVersionTag.pm @@ -2,11 +2,48 @@ package WebGUI::i18n::English::Workflow_Activity_NotifyAboutVersionTag; use strict; our $I18N = { - 'activityName' => { - message => q|Notify About Version Tag|, - context => q|The name of this workflow activity.|, - lastUpdated => 0, - }, + + 'activityName' => { + message => q|Notify About Version Tag|, + context => q|The name of this workflow activity.|, + lastUpdated => 0, + }, + + 'email template' => { + message => q|Email Template|, + context => q|Label in the edit form. A template for an email.|, + lastUpdated => 0, + }, + + 'email template help' => { + message => q|Select a template for the email that is sent out.|, + context => q|Hoverhelp.|, + lastUpdated => 0, + }, + + 'email template title' => { + message => q|Notify About Version Tag Email Template|, + context => q|Title of the template variable page.|, + lastUpdated => 0, + }, + + 'message' => { + message => q|The message from the Workflow Activity settings|, + context => q|Title of the template variable page.|, + lastUpdated => 0, + }, + + 'comments' => { + message => q|Comments from the version tag, when it was committed. These could be blank if no comments were entered, or if comments are not required on the site.|, + context => q|Title of the template variable page.|, + lastUpdated => 0, + }, + + 'url' => { + message => q|The complete URL to work on the version tag. It is a bare URL, with no HTML wrapped around it.|, + context => q|Title of the template variable page.|, + lastUpdated => 0, + }, };