[Rt-commit] rt branch, 4.2/rt-crontool-reminders, created. rt-4.0.5-283-geba0337

Jim Brandt jbrandt at bestpractical.com
Fri May 10 14:43:15 EDT 2013


The branch, 4.2/rt-crontool-reminders has been created
        at  eba0337640546a62b7393ae86711bb405a356050 (commit)

- Log -----------------------------------------------------------------
commit dab9083818681be7687c32d2a58991c1643f8b3d
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri May 10 14:39:38 2013 -0400

    Add AlwaysNotifyActor option for RT::Action::Notify
    
    Provide a way to force notifications even if they would be
    prevented by the NotifyActor setting. This is useful for automated
    notification jobs that might not send email as intended due to
    NotifyActor settings.

diff --git a/lib/RT/Action/Notify.pm b/lib/RT/Action/Notify.pm
index f1aef40..55e5a62 100644
--- a/lib/RT/Action/Notify.pm
+++ b/lib/RT/Action/Notify.pm
@@ -71,8 +71,12 @@ sub Prepare {
 
 =head2 SetRecipients
 
-Sets the recipients of this meesage to Owner, Requestor, AdminCc, Cc or All. 
-Explicitly B<does not> notify the creator of the transaction by default
+Sets the recipients of this message to Owner, Requestor, AdminCc, Cc or All.
+Explicitly B<does not> notify the creator of the transaction by default.
+
+To send email to the selected receipients regardless of RT's NotifyActor
+configuration, include AlwaysNotifyActor as an additional argument with
+the recipients passed in.
 
 =cut
 
@@ -134,12 +138,15 @@ sub SetRecipients {
     my $creatorObj = $self->TransactionObj->CreatorObj;
     my $creator = $creatorObj->EmailAddress() || '';
 
-    #Strip the sender out of the To, Cc and AdminCc and set the 
+    # Strip the sender out of the To, Cc and AdminCc and set the
     # recipients fields used to build the message by the superclass.
-    # unless a flag is set 
+    # Don't strip if AlwaysNotifyActor passed.
+
     my $TransactionCurrentUser = RT::CurrentUser->new;
     $TransactionCurrentUser->LoadByName($creatorObj->Name);
-    if (RT->Config->Get('NotifyActor',$TransactionCurrentUser)) {
+
+    if ( RT->Config->Get('NotifyActor',$TransactionCurrentUser)
+         || $arg =~ /\bAlwaysNotifyActor\b/ ) {
         @{ $self->{'To'} }  = @To;
         @{ $self->{'Cc'} }  = @Cc;
         @{ $self->{'Bcc'} } = @Bcc;

commit eba0337640546a62b7393ae86711bb405a356050
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri May 10 14:23:53 2013 -0400

    Add new docs for reminders including rt-crontool example
    
    The reminder docs include an example of how to schedule automatic
    email for reminders using the included template and new
    AlwaysNotifyActor option. Docs added for RT::Action::BeforeDue
    since it is used in the example.

diff --git a/docs/reminders.pod b/docs/reminders.pod
new file mode 100644
index 0000000..6845203
--- /dev/null
+++ b/docs/reminders.pod
@@ -0,0 +1,68 @@
+=head1 Reminders
+
+Reminders can be attached to a ticket to notify you take some action
+on the ticket. Although there are fields like "Due" on tickets, some
+tickets have dependencies or sub-tasks that need to be completed before you
+can do the ticket. For a "Deploy New Certificate" ticket, for example, you may
+need to remind yourself to order the new cert first.
+
+Reminders are sort of mini-tickets and in fact they are implemented as
+tickets themselves.
+
+Each Reminder has:
+
+=over
+
+=item * Subject
+
+=item * Owner
+
+=item * Due date
+
+=item * Status (new, open, resolved, ...)
+
+=back
+
+=head1 Creating a Reminder
+
+Reminders are attached to tickets, so you create them in the Reminders section of
+the ticket display. Once you give it an Owner and a Due date, the Reminder will
+appear on the Owner's "At-a-glance" page by default.
+
+If you don't see reminders, it may be turned off. Display of reminders can be
+disabled with the C<$EnableReminders> flag in C<RT_SiteConfig.pm>. By default,
+reminders are turned on.
+
+=head1 Email Reminders
+
+While seeing reminders in the web display is handy, you may also want to send out
+email based on reminders that are due or are soon to be due. You can use the
+C<rt-crontool> utility to schedule a job to send these emails for you.
+
+To schedule the reminders, add a line like the following to your RT crontab:
+
+    0 6 * * * root /opt/rt4/bin/rt-crontool \
+                   --search RT::Search::FromSQL \
+                   --search-arg 'Type = "reminder" and (Status = "open" or Status = "new")' \
+                   --condition RT::Condition::BeforeDue \
+                   --condition-arg 2d \
+                   --action RT::Action::SendEmail \
+                   --action-arg Owner \
+                   --transaction first \
+                   --template 'Reminder'
+
+If you have modified the status values for reminders such that you have more
+active statuses than "open" and "new" you should add them as part of your
+"FromSQL" query. You typically
+won't want to send out email on "resolved" reminders, but you could add that
+to the query as well.
+
+The argument to C<RT::Condition::BeforeDue> is an amount of time in the form
+"1d2h3m4s" for 1 day and 2 hours and 3 minutes and 4 seconds. As shown in the
+example, single values can also be passed. The run frequency in your crontab
+should be consistent with the time period you set to avoid missing reminders.
+
+The template value refers to a Template in your RT system. You can use the
+default Reminder template or create your own in Tools > Configuration >
+Global > Templates > Create. You can look at the default template for some
+examples of the values you can use to populate the email.
diff --git a/etc/initialdata b/etc/initialdata
index 468f935..cc23bcc 100755
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -304,6 +304,18 @@ This is a comment.  It is not sent to the Requestor(s):
     },
 
     {  Queue       => '0',
+       Name        => 'Reminder',                           # loc
+       Description => 'Default reminder template',          # loc
+       Content     =>
+'Subject:{$Ticket->Subject} is due {$Ticket->DueAsString}
+
+This reminder is for ticket #{$Target = $Ticket->RefersTo->First->TargetObj;$Target->Id}.
+
+{RT->Config->Get(\'WebURL\')}Ticket/Display.html?id={$Target->Id}
+'
+    },
+
+    {  Queue       => '0',
        Name        => 'Status Change',                                     # loc
        Description => 'Ticket status changed',                             # loc
        Content     => 'Subject: Status Changed to: {$Transaction->NewValue}
diff --git a/etc/upgrade/4.1.16/content b/etc/upgrade/4.1.16/content
new file mode 100644
index 0000000..3bf84f8
--- /dev/null
+++ b/etc/upgrade/4.1.16/content
@@ -0,0 +1,13 @@
+ at Templates = (
+    {  Queue       => '0',
+       Name        => 'Reminder',                           # loc
+       Description => 'Default reminder template',          # loc
+       Content     =>
+'Subject:{$Ticket->Subject} is due {$Ticket->DueAsString}
+
+This reminder is for ticket #{$Target = $Ticket->RefersTo->First->TargetObj;$Target->Id}.
+
+{RT->Config->Get(\'WebURL\')}Ticket/Display.html?id={$Target->Id}
+'
+    },
+);
diff --git a/lib/RT/Condition/BeforeDue.pm b/lib/RT/Condition/BeforeDue.pm
index 11c40e6..88aacb9 100644
--- a/lib/RT/Condition/BeforeDue.pm
+++ b/lib/RT/Condition/BeforeDue.pm
@@ -46,6 +46,23 @@
 #
 # END BPS TAGGED BLOCK }}}
 
+=head1 NAME
+
+RT::Condition::BeforeDue
+
+=head1 DESCRIPTION
+
+Returns true if the ticket we're operating on is within the
+amount of time defined by the passed in argument.
+
+The passed in value is a date in the format "1d2h3m4s"
+for 1 day and 2 hours and 3 minutes and 4 seconds. Single
+units can also be passed such as 1d for just one day.
+
+
+=cut
+
+
 package RT::Condition::BeforeDue;
 use base 'RT::Condition';
 

-----------------------------------------------------------------------


More information about the Rt-commit mailing list