import rt 2.0.14
[freeside.git] / rt / lib / RT / Action / OpenDependent.pm
1 # $Header: /home/cvs/cvsroot/freeside/rt/lib/RT/Action/Attic/OpenDependent.pm,v 1.1 2002-08-12 06:17:07 ivan Exp $
2 # This Action will open the BASE if a dependent is resolved.
3
4 package RT::Action::OpenDependent;
5 require RT::Action::Generic;
6 require RT::Links;
7 @ISA=qw(RT::Action::Generic);
8
9 #Do what we need to do and send it out.
10
11 #What does this type of Action does
12
13 # {{{ sub Describe 
14 sub Describe  {
15   my $self = shift;
16   return (ref $self . " will stall a [local] BASE if it's open and a dependency link is created.");
17 }
18 # }}}
19
20
21 # {{{ sub Prepare 
22 sub Prepare  {
23     # nothing to prepare
24     return 1;
25 }
26 # }}}
27
28 sub Commit {
29     my $self = shift;
30
31     my $Links=RT::Links->new($RT::SystemUser);
32     $Links->Limit(FIELD => 'Type', VALUE => 'DependsOn');
33     $Links->Limit(FIELD => 'Target', VALUE => $self->TicketObj->id);
34
35     while (my $Link=$Links->Next()) {
36         next unless $Link->BaseIsLocal;
37         my $base=RT::Ticket->new($self->TicketObj->CurrentUser);
38         # Todo: Only work if Base is a plain ticket num:
39         $base->Load($Link->Base);
40         $base->Open if $base->Status eq 'stalled';
41     }
42 }
43
44
45 # Applicability checked in Commit.
46
47 # {{{ sub IsApplicable 
48 sub IsApplicable  {
49   my $self = shift;
50   1;  
51   return 1;
52 }
53 # }}}
54
55 1;