[freeside-commits] freeside/rt/bin rt-crontool.in, 1.1.1.5, 1.1.1.5.4.1 rt.in, 1.1.1.4, 1.1.1.4.4.1 webmux.pl.in, 1.1.1.5, 1.1.1.5.4.1

Ivan,,, ivan at wavetail.420.am
Mon Mar 3 15:07:39 PST 2008


Update of /home/cvs/cvsroot/freeside/rt/bin
In directory wavetail.420.am:/tmp/cvs-serv10370/bin

Modified Files:
      Tag: FREESIDE_1_7_BRANCH
	rt-crontool.in rt.in webmux.pl.in 
Log Message:
merge in rt 3.4.6.  *gulp*!

Index: rt.in
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/bin/rt.in,v
retrieving revision 1.1.1.4
retrieving revision 1.1.1.4.4.1
diff -u -d -r1.1.1.4 -r1.1.1.4.4.1
--- rt.in	15 Oct 2005 09:11:16 -0000	1.1.1.4
+++ rt.in	3 Mar 2008 23:07:37 -0000	1.1.1.4.4.1
@@ -1673,13 +1673,15 @@
         -t type         Specifies object type.
         -f a,b,c        Restrict the display to the specified fields.
         -S var=val      Submits the specified variable with the request.
-
+        -v              Verbose display
     Examples:
 
         rt show -t ticket -f id,subject,status 1-3
         rt show ticket/3/attachments/29
         rt show ticket/3/attachments/29/content
         rt show ticket/1-3/links
+        rt show ticket/3/history
+        rt show -v ticket/3/history
         rt show -t user 2
 
 --

Index: webmux.pl.in
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/bin/webmux.pl.in,v
retrieving revision 1.1.1.5
retrieving revision 1.1.1.5.4.1
diff -u -d -r1.1.1.5 -r1.1.1.5.4.1
--- webmux.pl.in	15 Oct 2005 09:11:16 -0000	1.1.1.5
+++ webmux.pl.in	3 Mar 2008 23:07:37 -0000	1.1.1.5.4.1
@@ -95,7 +95,8 @@
     
     use File::Path qw( rmtree );
     use File::Glob qw( bsd_glob );
-    rmtree([ bsd_glob("$RT::MasonDataDir/obj/*") ], 0, 1);
+    my @files = bsd_glob("$RT::MasonDataDir/obj/*");
+    rmtree([ @files ], 0, 1) if @files;
 }
 
 sub handler {

Index: rt-crontool.in
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/bin/rt-crontool.in,v
retrieving revision 1.1.1.5
retrieving revision 1.1.1.5.4.1
diff -u -d -r1.1.1.5 -r1.1.1.5.4.1
--- rt-crontool.in	15 Oct 2005 09:11:16 -0000	1.1.1.5
+++ rt-crontool.in	3 Mar 2008 23:07:37 -0000	1.1.1.5.4.1
@@ -75,19 +75,28 @@
 }
 
 my ( $search, $condition, $action, $search_arg, $condition_arg, $action_arg,
-     $template_id, $help, $verbose );
-GetOptions( "search=s"        => \$search,
-            "search-arg=s"    => \$search_arg,
-            "condition=s"     => \$condition,
-            "condition-arg=s" => \$condition_arg,
-            "action-arg=s"    => \$action_arg,
-            "action=s"        => \$action,
-	    "template-id=s"   => \$template_id,
-            "help"            => \$help,
-            "verbose|v"       => \$verbose );
+     $template_id, $transaction, $transaction_type, $help, $verbose );
+GetOptions( "search=s"           => \$search,
+            "search-arg=s"       => \$search_arg,
+            "condition=s"        => \$condition,
+            "condition-arg=s"    => \$condition_arg,
+            "action-arg=s"       => \$action_arg,
+            "action=s"           => \$action,
+            "template-id=s"      => \$template_id,
+            "transaction=s"      => \$transaction,
+            "transaction-type=s" => \$transaction_type,
+            "help"               => \$help,
+            "verbose|v"          => \$verbose );
 
 help() if $help or not $search or not $action;
 
+$transaction ||= 'first';
+unless ( $transaction =~ /^(first|last)$/i ) {
+    print STDERR loc("--transaction argument could be only 'first' or 'last'");
+    exit 1;
+}
+$transaction = lc($transaction) eq 'first'? 'ASC': 'DESC';
+
 # We _must_ have a search object
 load_module($search);
 load_module($action)    if ($action);
@@ -99,6 +108,8 @@
     $template_obj = RT::Template->new($CurrentUser);
     $template_obj->Load($template_id);
 }
+my $void_scrip = RT::Scrip->new( $CurrentUser );
+my $void_scrip_action = RT::ScripAction->new( $CurrentUser );
 
 #At the appointed time:
 
@@ -119,11 +130,20 @@
 while ( my $ticket = $tickets->Next() ) {
     print $ticket->Id() . ": " if ($verbose);
 
+    my $transaction = get_transaction($ticket);
+    print loc("Using transaction #[_1]...", $transaction->id)
+        if $verbose && $transaction;
+
     # perform some more advanced check
     if ($condition) {
-        my $condition_obj = $condition->new( TicketObj => $ticket,
-                                             Argument  => $condition_arg,
-                                             CurrentUser => $CurrentUser );
+        my $condition_obj = $condition->new(
+            TransactionObj => $transaction,
+            TicketObj      => $ticket,
+            ScripObj       => $void_scrip,
+            TemplateObj    => $template_obj,
+            Argument       => $condition_arg,
+            CurrentUser    => $CurrentUser,
+        );
 
         # if the condition doesn't apply, get out of here
 
@@ -133,10 +153,13 @@
 
     #prepare our action
     my $action_obj = $action->new(
-        TicketObj   => $ticket,
-        TemplateObj => $template_obj,
-        Argument    => $action_arg,
-        CurrentUser => $CurrentUser
+        TicketObj      => $ticket,
+        TransactionObj => $transaction,
+        TemplateObj    => $template_obj,
+        Argument       => $action_arg,
+        ScripObj       => $void_scrip,
+        ScripActionObj => $void_scrip_action,
+        CurrentUser    => $CurrentUser,
     );
 
     #if our preparation, move onto the next ticket
@@ -148,6 +171,26 @@
     print loc("Action committed.\n") if ($verbose);
 }
 
+=head2 get_transaction
+
+Takes ticket and returns its transaction acording to command
+line arguments C<--transaction> and <--transaction-type>.
+
+=cut
+
+sub get_transaction {
+    my $ticket = shift;
+    my $txns = $ticket->Transactions;
+    $txns->OrderByCols(
+        { FIELD => 'Created', ORDER => $transaction },
+        { FIELD => 'id', ORDER => $transaction },
+    );
+    $txns->Limit( FIELD => 'Type', VALUE => $transaction_type )
+        if $transaction_type;
+    $txns->RowsPerPage(1);
+    return $txns->First;
+}
+
 # {{{ load_module 
 
 =head2 load_module
@@ -207,6 +250,15 @@
       . loc( "[_1] - An argument to pass to [_2]", "--action-argument", "--action" )
       . "\n";
     print "	"
+      . loc( "[_1] - Specify id of the template you want to use", "--template-id" )
+      . "\n";
+    print "	"
+      . loc( "[_1] - Specify if you want to use either 'first' or 'last' tarnsaction", "--transaction" )
+      . "\n";
+    print "	"
+      . loc( "[_1] - Specify the type of a transaction you want to use", "--transaction-type" )
+      . "\n";
+    print "	"
       . loc( "[_1] - Output status updates to STDOUT", "--verbose" ) . "\n";
     print "\n";
     print "\n";



More information about the freeside-commits mailing list