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 000000000..31e32dc6a Binary files /dev/null and b/docs/upgrades/packages-7.10.3/root_import_workflow-activity-templates.wgpkg differ diff --git a/docs/upgrades/upgrade_7.10.2-7.10.3.pl b/docs/upgrades/upgrade_7.10.2-7.10.3.pl index f4711a6b9..e34b26b8a 100644 --- a/docs/upgrades/upgrade_7.10.2-7.10.3.pl +++ b/docs/upgrades/upgrade_7.10.2-7.10.3.pl @@ -32,6 +32,7 @@ my $session = start(); # this line required # upgrade functions go here pruneInboxMessagesFromDeletedUsers($session); +addTemplateToNotifyAboutVersionTag($session); finish($session); # this line required @@ -61,6 +62,27 @@ EOSQL } +#---------------------------------------------------------------------------- +# Describe what our function does +sub addTemplateToNotifyAboutVersionTag { + my $session = shift; + print "\tAdd template to Notify About Version Tag workflow activities." unless $quiet; + use WebGUI::Workflow::Activity; + use WebGUI::Workflow::Activity::NotifyAboutVersionTag; + my $templateId = WebGUI::Workflow::Activity::NotifyAboutVersionTag->definition($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, + }, };