summaryrefslogtreecommitdiff
path: root/rt/webrt/Ticket/Display.html
blob: cb0dc25015ccc0f7614e37372c205831cda09462 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
%# $Header: /home/cvs/cvsroot/freeside/rt/webrt/Ticket/Attic/Display.html,v 1.1 2002-08-12 06:17:09 ivan Exp $
%# Copyright 1996-2000 Jesse Vincent <jesse@fsck.com>

<& /Elements/Header, Title => "Ticket #".$Ticket->Id ." ".$Ticket->Subject &>
<& /Ticket/Elements/Tabs, Ticket => $Ticket, current_tab => 'Ticket/Display.html?id='.$Ticket->id &>

<& /Elements/ListActions, actions => \@Actions &>

<& /Ticket/Elements/ShowSummary,  Ticket => $Ticket &>


<BR>
<& /Ticket/Elements/ShowHistory , 
      Ticket => $Ticket, 
      Collapsed => $ARGS{'Collapsed'}, 
      ShowHeaders => $ARGS{'ShowHeaders'} &> 

  
<%ARGS>
$id => undef
$Create => undef
$ShowHeaders => undef
$Collapsed => undef
</%ARGS>

<%INIT>

  
  my ($linkid, $message, $tid, $Ticket, @Actions);  

$Ticket = new RT::Ticket($session{'CurrentUser'});

unless ($id) {
    Abort('No ticket specified');
}

if ($ARGS{'id'} eq 'new') {
    # {{{ Create a new ticket
    
    my $Queue = new RT::Queue($session{'CurrentUser'});	
    unless ($Queue->Load($ARGS{'Queue'})) {
	Abort('Queue not found');
    }
    
    unless ($Queue->CurrentUserHasRight('CreateTicket')) {
	Abort('You have no permission to create tickets in that queue.');
    }
   
    my $due = new RT::Date($session{'CurrentUser'});
    $due->Set(Format => 'unknown', Value => $ARGS{'Due'});
    my $starts = new RT::Date($session{'CurrentUser'});
    $starts->Set(Format => 'unknown', Value => $ARGS{'Starts'});
    
 
    my @Requestors = split(/,/,$ARGS{'Requestors'});
    my @Cc = split(/,/,$ARGS{'Cc'});
    my @AdminCc = split(/,/,$ARGS{'AdminCc'});
    
    my $MIMEObj = MakeMIMEEntity( Subject => $ARGS{'Subject'},
				  From => $ARGS{'From'},
				  Cc => $ARGS{'Cc'},
				  Body => $ARGS{'Content'},
				  AttachmentFieldName => 'Attach');
 
				  
    my %create_args = ( 
		       Queue=>$ARGS{Queue},
		       Owner=>$ARGS{ValueOfOwner},
		       InitialPriority=> $ARGS{InitialPriority},
		       FinalPriority=> $ARGS{FinalPriority},
		       TimeLeft => $ARGS{TimeLeft},
		       TimeWorked => $ARGS{TimeWorked},
		       Requestor=> \@Requestors,
		       Cc => \@Cc,
		       AdminCc => \@AdminCc,
		       Subject=>$ARGS{Subject},
		       Status=>$ARGS{Status},
		       Due => $due->ISO,
		       Starts => $starts->ISO,
		       MIMEObj => $MIMEObj	  
		      );         

    
    # we need to get any KeywordSelect-<integer> fields into %create_args..
    grep { $_ =~ /^KeywordSelect-/ && {$create_args{$_} = $ARGS{$_}}} %ARGS;

    my ($id, $Trans, $ErrMsg)= $Ticket->Create(%create_args);
    unless ($id && $Trans) {
	Abort($ErrMsg);
    }
    my @linktypes = qw( DependsOn MemberOf RefersTo );
    
    foreach my $linktype (@linktypes) {
      foreach my $luri (split (/ /,$ARGS{"new-$linktype"})) {
	$luri =~ s/\s*$//; # Strip trailing whitespace
	my ($val, $msg) = $Ticket->AddLink( Target => $luri,
					    Type => $linktype);
	push @Actions, $msg;
      }
      
      foreach my $luri (split (/ /,$ARGS{"$linktype-new"})) {
	my ($val, $msg) = $Ticket->AddLink( Base => $luri,
					    Type => $linktype);
	
	push @Actions, $msg;
      }
    }
    # don't try to change queue to the current queue
    delete $ARGS{'Queue'};

    push(@Actions, $ErrMsg);
    unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
      Abort("No permission to view newly created ticket #".$Ticket->id.".");
    }
    # }}}
}

else { 
    $Ticket = LoadTicket($ARGS{'id'});
    unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
	Abort("No permission to view ticket");
    }


if (defined $ARGS{'Action'}) {
  if ($ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/) {
    my $action = $1;
    my ($res, $msg)=$Ticket->$action();
    push(@Actions, $msg);
  }
}
    $ARGS{'UpdateContent'} =~ s/\r\n/\n/g;

    if ($ARGS{'UpdateContent'} &&
        $ARGS{'UpdateContent'} ne '' &&
        $ARGS{'UpdateContent'} ne  "-- \n" .
                                $session{'CurrentUser'}->UserObj->Signature
       ) {
	    ProcessUpdateMessage(ARGSRef=>\%ARGS, 
				 Actions=>\@Actions, 
				 TicketObj=>$Ticket);
	}
#Process status updates
my @BasicActions = ProcessTicketBasics(ARGSRef => \%ARGS, TicketObj=>$Ticket);

push (@Actions, @BasicActions);
}
</%INIT>