This commit was generated by cvs2svn to compensate for changes in r6252,
[freeside.git] / rt / lib / RT / Interface / Web_Vendor.pm
1 # Copyright (c) 2004 Ivan Kohler <ivan-rt@420.am>
2 #
3 # This work is made available to you under the terms of Version 2 of
4 # the GNU General Public License. A copy of that license should have
5 # been provided with this software, but in any event can be snarfed
6 # from www.gnu.org.
7
8 # This work is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # General Public License for more details.
12
13 =head1 NAME
14
15 RT::Interface::Web_Vendor
16
17 =head1 SYNOPSIS
18
19 =head1 DESCRIPTION
20
21 Freeside vendor overlay for RT::Interface::Web.
22
23 =begin testing
24
25 use_ok(RT::Interface::Web_Vendor);
26
27 =end testing
28
29 =cut
30
31 #package RT::Interface::Web;
32 #use strict;
33
34 package HTML::Mason::Commands;
35 use strict;
36
37 =head2 ProcessTicketCustomers 
38
39 =cut
40
41 sub ProcessTicketCustomers {
42     my %args = (
43         TicketObj => undef,
44         ARGSRef   => undef,
45         @_
46     );
47     my @results = ();
48
49     my $Ticket  = $args{'TicketObj'};
50     my $ARGSRef = $args{'ARGSRef'};
51
52     ### false laziness w/RT::Interface::Web::ProcessTicketLinks
53     # Delete links that are gone gone gone.
54     foreach my $arg ( keys %$ARGSRef ) {
55         if ( $arg =~ /DeleteLink-(.*?)-(DependsOn|MemberOf|RefersTo)-(.*)$/ ) {
56             my $base   = $1;
57             my $type   = $2;
58             my $target = $3;
59
60             push @results,
61               "Trying to delete: Base: $base Target: $target  Type $type";
62             my ( $val, $msg ) = $Ticket->DeleteLink( Base   => $base,
63                                                      Type   => $type,
64                                                      Target => $target );
65
66             push @results, $msg;
67
68         }
69
70     }
71     ###
72
73     my @delete_custnums =
74       map  { /^Ticket-AddCustomer-(\d+)$/; $1 }
75       grep { /^Ticket-AddCustomer-(\d+)$/ && $ARGSRef->{$_} }
76       keys %$ARGSRef;
77
78     my @custnums = map  { /^Ticket-AddCustomer-(\d+)$/; $1 }
79                    grep { /^Ticket-AddCustomer-(\d+)$/ && $ARGSRef->{$_} }
80                    keys %$ARGSRef;
81
82     foreach my $custnum ( @custnums ) {
83       my( $val, $msg ) =
84         $Ticket->AddLink( 'Type'   => 'MemberOf',
85                           'Target' => "freeside://freeside/cust_main/$custnum",
86                         );
87       push @results, $msg;
88     }
89
90     return @results;
91
92 }
93
94 1;
95