[Rt-commit] r6443 - in rtir/branches/2.1-EXPERIMENTAL: .
html/RTIR/Elements
ruz at bestpractical.com
ruz at bestpractical.com
Wed Nov 15 23:58:07 EST 2006
Author: ruz
Date: Wed Nov 15 23:58:07 2006
New Revision: 6443
Modified:
rtir/branches/2.1-EXPERIMENTAL/ (props changed)
rtir/branches/2.1-EXPERIMENTAL/html/RTIR/Elements/States
rtir/branches/2.1-EXPERIMENTAL/lib/RT/IR.pm
Log:
r1839 at cubic-pc: cubic | 2006-11-16 05:31:21 +0300
* move html/Elements/States into libs, where it had to be since the beginning
Modified: rtir/branches/2.1-EXPERIMENTAL/html/RTIR/Elements/States
==============================================================================
--- rtir/branches/2.1-EXPERIMENTAL/html/RTIR/Elements/States (original)
+++ rtir/branches/2.1-EXPERIMENTAL/html/RTIR/Elements/States Wed Nov 15 23:58:07 2006
@@ -1,32 +1,3 @@
-<%ONCE>
-my %meta = (
- 'Incidents' => { Active => ['open'], Inactive => ['resolved', 'abandoned'] },
- 'Incident Reports' => { Active => ['new', 'open'], Inactive => ['resolved', 'rejected'] },
- 'Investigations' => { Active => ['open'], Inactive => ['resolved'] },
- 'Blocks' => {
- Active => ['pending activation', 'active', 'pending removal'],
- Inactive => ['removed'],
- },
-);
-</%ONCE>
<%INIT>
-my @states;
-if( $Queue ) {
- push @states, @{ $meta{ $Queue }->{'Active'} || [] } if $Active;
- push @states, @{ $meta{ $Queue }->{'Inactive'} || [] } if $Inactive;
-} else {
- foreach ( values %meta ) {
- push @states, @{ $_->{'Active'} || [] } if $Active;
- push @states, @{ $_->{'Inactive'} || [] } if $Inactive;
- }
-}
-
-my %seen = ();
-return sort grep !$seen{$_}++, @states;
-
+return RT::IR::States( %ARGS );
</%INIT>
-<%ARGS>
-$Queue => undef
-$Active => 1,
-$Inactive => 0,
-</%ARGS>
Modified: rtir/branches/2.1-EXPERIMENTAL/lib/RT/IR.pm
==============================================================================
--- rtir/branches/2.1-EXPERIMENTAL/lib/RT/IR.pm (original)
+++ rtir/branches/2.1-EXPERIMENTAL/lib/RT/IR.pm Wed Nov 15 23:58:07 2006
@@ -136,6 +136,7 @@
sub TicketType {
my %arg = ( Queue => undef, Ticket => undef, @_);
+
if ( defined $arg{'Ticket'} && !defined $arg{'Queue'} ) {
my $obj;
if ( ref $arg{'Ticket'} ) {
@@ -143,7 +144,7 @@
}
else {
$obj = RT::Ticket->new( $RT::SystemUser );
- $obj->Load( $args{'Ticket'} );
+ $obj->Load( $arg{'Ticket'} );
}
$arg{'Queue'} = $obj->QueueObj if $obj->id;
}
@@ -159,7 +160,32 @@
return undef;
}
+my %STATES = (
+ 'incidents' => { Active => ['open'], Inactive => ['resolved', 'abandoned'] },
+ 'incident reports' => { Active => ['new', 'open'], Inactive => ['resolved', 'rejected'] },
+ 'investigations' => { Active => ['open'], Inactive => ['resolved'] },
+ 'blocks' => {
+ Active => ['pending activation', 'active', 'pending removal'],
+ Inactive => ['removed'],
+ },
+);
+sub States {
+ my %arg = ( Queue => undef, Active => 1, Inactive => 0, @_ );
+
+ my @states;
+ if ( $arg{'Queue'} ) {
+ push @states, @{ $STATES{ lc $arg{'Queue'} }->{'Active'} || [] } if $arg{'Active'};
+ push @states, @{ $STATES{ lc $arg{'Queue'} }->{'Inactive'} || [] } if $arg{'Inactive'};
+ } else {
+ foreach ( values %STATES ) {
+ push @states, @{ $_->{'Active'} || [] } if $arg{'Active'};
+ push @states, @{ $_->{'Inactive'} || [] } if $arg{'Inactive'};
+ }
+ }
+ my %seen = ();
+ return sort grep !$seen{$_}++, @states;
+}
{
my %cache;
More information about the Rt-commit
mailing list