diff options
| author | ivan <ivan> | 2008-03-03 23:07:58 +0000 |
|---|---|---|
| committer | ivan <ivan> | 2008-03-03 23:07:58 +0000 |
| commit | 479339313bbda612f8fe939217fd067999ef36d4 (patch) | |
| tree | a47e2fbdc0107910bbbd3b57dc0cbfc357f76aa3 /rt/bin | |
| parent | 642d85fc54b066e6364b66644b95c7b123ba8e24 (diff) | |
merge in rt 3.4.6. *gulp*!
Diffstat (limited to 'rt/bin')
| -rw-r--r-- | rt/bin/rt-crontool.in | 86 | ||||
| -rw-r--r-- | rt/bin/rt.in | 4 | ||||
| -rw-r--r-- | rt/bin/webmux.pl.in | 3 |
3 files changed, 74 insertions, 19 deletions
diff --git a/rt/bin/rt-crontool.in b/rt/bin/rt-crontool.in index 76b08c344..0cfc4a9fc 100644 --- a/rt/bin/rt-crontool.in +++ b/rt/bin/rt-crontool.in @@ -75,19 +75,28 @@ unless ( $CurrentUser->Id ) { } 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 @@ if ($template_id) { $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 @@ my $tickets = $search->TicketsObj; 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 @@ while ( my $ticket = $tickets->Next() ) { #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 @@ while ( my $ticket = $tickets->Next() ) { 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 @@ sub help { . 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"; diff --git a/rt/bin/rt.in b/rt/bin/rt.in index d12460b06..c80577f4a 100644 --- a/rt/bin/rt.in +++ b/rt/bin/rt.in @@ -1673,13 +1673,15 @@ Text: -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 -- diff --git a/rt/bin/webmux.pl.in b/rt/bin/webmux.pl.in index 73b10143d..4cc4d6128 100644 --- a/rt/bin/webmux.pl.in +++ b/rt/bin/webmux.pl.in @@ -95,7 +95,8 @@ if ($ENV{'MOD_PERL'} && !$RT::DevelMode) { 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 { |
