This commit was generated by cvs2svn to compensate for changes in r2523,
[freeside.git] / rt / lib / RT / Action / ResolveMembers.pm
1 # This Action will resolve all members of a resolved group ticket
2
3 package RT::Action::ResolveMembers;
4 require RT::Action::Generic;
5 require RT::Links;
6 @ISA=qw(RT::Action::Generic);
7
8 #Do what we need to do and send it out.
9
10 #What does this type of Action does
11
12 # {{{ sub Describe 
13 sub Describe  {
14   my $self = shift;
15   return (ref $self . " will resolve all members of a resolved group ticket.");
16 }
17 # }}}
18
19
20 # {{{ sub Prepare 
21 sub Prepare  {
22     # nothing to prepare
23     return 1;
24 }
25 # }}}
26
27 sub Commit {
28     my $self = shift;
29
30     my $Links=RT::Links->new($RT::SystemUser);
31     $Links->Limit(FIELD => 'Type', VALUE => 'MemberOf');
32     $Links->Limit(FIELD => 'Target', VALUE => $self->TicketObj->id);
33
34     while (my $Link=$Links->Next()) {
35         # Todo: Try to deal with remote URIs as well
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         # I'm afraid this might be a major bottleneck if ResolveGroupTicket is on.
41         $base->Resolve;
42     }
43 }
44
45
46 # Applicability checked in Commit.
47
48 # {{{ sub IsApplicable 
49 sub IsApplicable  {
50   my $self = shift;
51   1;  
52   return 1;
53 }
54 # }}}
55
56 1;
57