[Rt-commit] rt branch, 4.2/move-open-on-setstarted-to-scrip, created. rt-4.1.17-1-gdbc1865

Todd Wade todd at bestpractical.com
Tue Jul 16 12:48:50 EDT 2013


The branch, 4.2/move-open-on-setstarted-to-scrip has been created
        at  dbc1865e5a2563dc9e1f49734fe6ae8634c32b1d (commit)

- Log -----------------------------------------------------------------
commit dbc1865e5a2563dc9e1f49734fe6ae8634c32b1d
Author: Todd Wade <todd at bestpractical.com>
Date:   Wed Jul 10 11:26:31 2013 -0400

    Move the code that opens a ticket on SetStarted to a Scrip
    
    This commit resolves a TODO from RT::Ticket that moves code that
    sets a ticket status to open to a Scrip for upgrading users. The
    functionality is removed for new installs.
    
    See issues#17474

diff --git a/docs/UPGRADING-4.2 b/docs/UPGRADING-4.2
index c63921c..3fb6c7b 100644
--- a/docs/UPGRADING-4.2
+++ b/docs/UPGRADING-4.2
@@ -130,6 +130,11 @@ UPGRADING FROM RT 4.0.0 and greater
   performance problems.  Unprivileged Owners (if they exist) may still
   be set using the Autocompleter.
 
+* The functionality that changed the ticket status to Open when the Started
+  date is set has been moved to a Scrip called 'On transaction and SetStarted
+  Open Ticket'. If you do not depend on this functionality, the Scrip can
+  be deleted.
+
 * New installs will notify Ccs and one-time Ccs/Bccs on create and Owners on
   create and correspond.  Upgraded installations will not.  If you'd like to
   adjust your scrips, the actions are available from the admin scrip pages.
diff --git a/etc/upgrade/4.1.18/content b/etc/upgrade/4.1.18/content
new file mode 100644
index 0000000..818351b
--- /dev/null
+++ b/etc/upgrade/4.1.18/content
@@ -0,0 +1,16 @@
+use strict;
+use warnings;
+
+# Ticket-level notifications
+our @ScripActions = ({
+    Name        => 'On SetStarted Open Ticket',
+    Description => 'When Started is Updated Set Ticket Status to Open',
+    ExecModule  => 'OpenOnStarted',
+});
+
+our @Scrips = ({
+    Description    => "On transaction and SetStarted Open Ticket",
+    ScripCondition => 'On Transaction',
+    ScripAction    => 'On SetStarted Open Ticket',
+    Template       => 'Blank'
+});
diff --git a/lib/RT/Action/OpenOnStarted.pm b/lib/RT/Action/OpenOnStarted.pm
new file mode 100644
index 0000000..f7551c3
--- /dev/null
+++ b/lib/RT/Action/OpenOnStarted.pm
@@ -0,0 +1,87 @@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
+#                                          <sales at bestpractical.com>
+#
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
+#
+# This work is made available to you under the terms of Version 2 of
+# the GNU General Public License. A copy of that license should have
+# been provided with this software, but in any event can be snarfed
+# from www.gnu.org.
+#
+# This work is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+#
+#
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# END BPS TAGGED BLOCK }}}
+
+=head1 NAME
+
+  RT::Action::OpenOnStarted
+
+=head1 DESCRIPTION
+
+OpenOnStarted is a ScripAction which sets a ticket status to open when the
+ticket is given a Started value. Before this commit, this functionality used to
+happen in RT::Ticket::SetStarted which made the functionality the policy for
+setting started. Moving the functionality to a scrip allows for it to be
+disabled if it is not desired.
+
+=cut
+
+package RT::Action::OpenOnStarted;
+use base 'RT::Action';
+use strict;
+use warnings;
+
+sub Prepare {
+    my $self = shift;
+    return 0 unless $self->TransactionObj->Type eq "Set";
+    return 0 unless $self->TransactionObj->Field eq "Started";
+    return 1;
+}
+
+sub Commit {
+    my $self   = shift;
+    my $ticket = $self->TicketObj;
+
+    my $next = $ticket->FirstActiveStatus;
+    $ticket->SetStatus( $next ) if defined $next;
+
+    return 1;
+}
+
+RT::Base->_ImportOverlays();
+
+1;
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index a926e9f..1433900 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1289,16 +1289,6 @@ sub SetStarted {
         $time_obj->SetToNow();
     }
 
-    # We need $TicketAsSystem, in case the current user doesn't have
-    # ShowTicket
-    my $TicketAsSystem = RT::Ticket->new(RT->SystemUser);
-    $TicketAsSystem->Load( $self->Id );
-    # Now that we're starting, open this ticket
-    # TODO: do we really want to force this as policy? it should be a scrip
-    my $next = $TicketAsSystem->FirstActiveStatus;
-
-    $self->SetStatus( $next ) if defined $next;
-
     return ( $self->_Set( Field => 'Started', Value => $time_obj->ISO ) );
 
 }

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


More information about the Rt-commit mailing list