This commit was generated by cvs2svn to compensate for changes in r8690,
[freeside.git] / rt / share / html / Ticket / Elements / Tabs
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %# 
5 %# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
6 %#                                          <jesse@bestpractical.com>
7 %# 
8 %# (Except where explicitly superseded by other copyright notices)
9 %# 
10 %# 
11 %# LICENSE:
12 %# 
13 %# This work is made available to you under the terms of Version 2 of
14 %# the GNU General Public License. A copy of that license should have
15 %# been provided with this software, but in any event can be snarfed
16 %# from www.gnu.org.
17 %# 
18 %# This work is distributed in the hope that it will be useful, but
19 %# WITHOUT ANY WARRANTY; without even the implied warranty of
20 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 %# General Public License for more details.
22 %# 
23 %# You should have received a copy of the GNU General Public License
24 %# along with this program; if not, write to the Free Software
25 %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
28 %# 
29 %# 
30 %# CONTRIBUTION SUBMISSION POLICY:
31 %# 
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
37 %# 
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
46 %# 
47 %# END BPS TAGGED BLOCK }}}
48 % $m->callback( Ticket => $Ticket, actions=> $actions, tabs => $tabs, %ARGS );
49 <& /Elements/Tabs, 
50     tabs => $tabs, 
51     actions => $actions, 
52     current_tab => $current_tab, 
53     current_toptab => $current_toptab,
54     Title => $Title &> 
55 <%INIT>
56 my $tabs = {};
57 my $current_toptab = "Search/Build.html", my $searchtabs = {};
58 my $actions;
59
60 if ($Ticket) {
61
62     my $id = $Ticket->id();
63
64     if ( defined $session{'tickets'} ) {
65
66         # we have to update session data if we get new ItemMap
67         my $updatesession = 1 unless ( $session{'tickets'}->{'item_map'} );
68
69         my $item_map = $session{'tickets'}->ItemMap;
70
71         if ($updatesession) {
72             $session{'i'}++;
73             $session{'tickets'}->PrepForSerialization();
74         }
75
76         # Don't display prev links if we're on the first ticket
77         if ( $item_map->{ $Ticket->Id }->{prev} ) {
78             $searchtabs->{'_a'} = {
79                 class => "nav",
80                 path  => "Ticket/Display.html?id=" . $item_map->{first},
81                 title => '<< ' . loc('First')
82             };
83             $searchtabs->{"_b"} = {
84                 class => "nav",
85                 path  => "Ticket/Display.html?id="
86                     . $item_map->{ $Ticket->Id }->{prev},
87                 title => '< ' . loc('Prev')
88             };
89         }
90
91         # Don't display next links if we're on the last ticket
92         if ( $item_map->{ $Ticket->Id }->{next} ) {
93             $searchtabs->{'d'} = {
94                 class => "nav",
95                 path  => "Ticket/Display.html?id="
96                     . $item_map->{ $Ticket->Id }->{next},
97                 title => loc('Next') . ' >'
98             };
99             $searchtabs->{'e'} = {
100                 class => "nav",
101                 path  => "Ticket/Display.html?id=" . $item_map->{last},
102                 title => loc('Last') . ' >>'
103             };
104         }
105     }
106
107     $tabs->{"this"} = {
108         class          => "currentnav",
109         path           => "Ticket/Display.html?id=" . $Ticket->id,
110         title          => "#" . $id,
111         current_subtab => $current_subtab
112     };
113
114     my $ticket_page_tabs = {
115         _A => {
116             title => loc('Display'),
117             path  => "Ticket/Display.html?id=" . $id,
118         },
119
120         _Ab => {
121             title => loc('History'),
122             path  => "Ticket/History.html?id=" . $id,
123         },
124         _B => {
125             title => loc('Basics'),
126             path  => "Ticket/Modify.html?id=" . $id,
127         },
128
129         _C => {
130             title => loc('Dates'),
131             path  => "Ticket/ModifyDates.html?id=" . $id,
132         },
133         _D => {
134             title => loc('People'),
135             path  => "Ticket/ModifyPeople.html?id=" . $id,
136         },
137         _E => {
138             title => loc('Links'),
139             path  => "Ticket/ModifyLinks.html?id=" . $id,
140         },
141         _X => {
142             title => loc('Jumbo'),
143             path  => "Ticket/ModifyAll.html?id=" . $id,
144         },
145
146     };
147
148     if ( RT->Config->Get('EnableReminders') ) {
149         $ticket_page_tabs->{_F} = {
150             title     => loc('Reminders'),
151             path      => "Ticket/Reminders.html?id=" . $id,
152             separator => 1,
153         };
154     }
155
156     foreach my $tab ( sort keys %{$ticket_page_tabs} ) {
157         if ( $ticket_page_tabs->{$tab}->{'path'} eq $current_tab ) {
158             $ticket_page_tabs->{$tab}->{"subtabs"} = $subtabs;
159             $tabs->{'this'}->{"current_subtab"}
160                 = $ticket_page_tabs->{$tab}->{"path"};
161         }
162     }
163     $tabs->{'this'}->{"subtabs"} = $ticket_page_tabs;
164     $current_tab = "Ticket/Display.html?id=" . $id;
165
166     my %can = ( ModifyTicket => $Ticket->CurrentUserHasRight('ModifyTicket'), );
167
168     if ( $can{'ModifyTicket'} or $Ticket->CurrentUserHasRight('ReplyToTicket') )
169     {
170         $actions->{'F'} = {
171             title => loc('Reply'),
172             path  => "Ticket/Update.html?Action=Respond&id=" . $id,
173         };
174     }
175
176     if ( $Ticket->CurrentUserHasRight('ForwardMessage') )
177     {
178         $actions->{'FA'} = {
179             title => loc('Forward'),
180             path  => "Ticket/Forward.html?id=" . $id,
181         };
182     }
183
184     if ( $can{'ModifyTicket'} ) {
185         if ( $Ticket->Status ne 'resolved' ) {
186             $actions->{'G'} = {
187                 path =>
188                     "Ticket/Update.html?Action=Comment&DefaultStatus=resolved&id="
189                     . $id,
190                 title => loc('Resolve')
191             };
192         }
193         if ( $Ticket->Status ne 'open' ) {
194             $actions->{'A'} = {
195                 path  => "Ticket/Display.html?Status=open&id=" . $id,
196                 title => loc('Open it')
197             };
198         }
199     }
200
201     if ( $Ticket->CurrentUserHasRight('OwnTicket') ) {
202         if ( $Ticket->OwnerObj->Id == $RT::Nobody->id ) {
203             $actions->{'B'} = {
204                 path  => "Ticket/Display.html?Action=Take&id=" . $id,
205                 title => loc('Take'),
206                 }
207                 if $can{'ModifyTicket'}
208                     or $Ticket->CurrentUserHasRight('TakeTicket');
209         } elsif ( $Ticket->OwnerObj->id != $session{CurrentUser}->id ) {
210             $actions->{'C'} = {
211                 path  => "Ticket/Display.html?Action=Steal&id=" . $id,
212                 title => loc('Steal'),
213                 }
214                 if $can{'ModifyTicket'}
215                     or $Ticket->CurrentUserHasRight('StealTicket');
216         }
217     }
218
219     if (   $can{'ModifyTicket'}
220         or $Ticket->CurrentUserHasRight('CommentOnTicket') )
221     {
222         $actions->{'E'} = {
223             title => loc('Comment'),
224             path  => "Ticket/Update.html?Action=Comment&id=" . $id,
225         };
226     }
227
228     $actions->{'_ZZ'}
229         = { html => $m->scomp( '/Ticket/Elements/Bookmark', id => $Ticket->id ),
230         };
231
232 }
233
234 if ( ( defined $actions->{A} || defined $actions->{B} || defined $actions->{C} )
235     && (   defined $actions->{E}
236         || defined $actions->{F}
237         || defined $actions->{G} ) )
238 {
239
240     if    ( defined $actions->{C} ) { $actions->{C}->{separator} = 1 }
241     elsif ( defined $actions->{B} ) { $actions->{B}->{separator} = 1 }
242     elsif ( defined $actions->{A} ) { $actions->{A}->{separator} = 1 }
243 }
244
245 my $args = '';
246 my $has_query = '';
247 my %query_args;
248 my $search_id = $ARGS{'SavedSearchId'}
249             || $session{'CurrentSearchHash'}->{'SearchId'} || '';
250 my $chart_search_id = $ARGS{'SavedChartSearchId'} || '';
251
252 $has_query = 1 if ( $ARGS{'Query'} or $session{'CurrentSearchHash'}->{'Query'} );
253   
254 %query_args = (
255         SavedSearchId => ($search_id eq 'new') ? undef : $search_id,
256         SavedChartSearchId => $chart_search_id,
257         Query  => $ARGS{'Query'}  || $session{'CurrentSearchHash'}->{'Query'},
258         Format => $ARGS{'Format'} || $session{'CurrentSearchHash'}->{'Format'},
259         OrderBy => $ARGS{'OrderBy'}
260             || $session{'CurrentSearchHash'}->{'OrderBy'},
261         Order => $ARGS{'Order'} || $session{'CurrentSearchHash'}->{'Order'},
262         Page  => $ARGS{'Page'}  || $session{'CurrentSearchHash'}->{'Page'},
263         RowsPerPage  => $ARGS{'RowsPerPage'}  || $session{'CurrentSearchHash'}->{'RowsPerPage'},
264     );
265
266     $args = "?" . $m->comp( '/Elements/QueryString', %query_args );
267
268 $tabs->{"f"} = {
269     path  => "Search/Build.html?NewQuery=1",
270     title => loc('New Search')
271 };
272 $tabs->{"g"} = {
273     path  => "Search/Build.html" . (($has_query) ? $args : ''),
274     title => loc('Edit Search')
275 };
276 $tabs->{"h"} = {
277     path      => "Search/Edit.html$args",
278     title     => loc('Advanced'),
279     separator => 1
280 };
281 if ($has_query) {
282
283     if ( $current_tab =~ m{Search/Results.html} ) {
284         $current_tab = "Search/Results.html$args";
285
286         if ( $session{'CurrentUser'}
287             ->HasRight( Right => 'SuperUser', Object => $RT::System ) )
288         {
289             my $shred_args = $m->comp(
290                 '/Elements/QueryString',
291                 Search          => 1,
292                 Plugin          => 'Tickets',
293                 'Tickets:query' => $query_args{'Query'},
294                 'Tickets:limit' => $query_args{'Rows'}
295             );
296
297             $tabs->{"shredder"} = {
298                 path  => 'Admin/Tools/Shredder/?' . $shred_args,
299                 title => loc('Shredder')
300             };
301
302         }
303     }
304     if ( $current_tab =~ m{Search/(Bulk|Build|Edit)\.html} ) {
305         $current_tab = "Search/$1.html$args";
306     }
307
308     $tabs->{"i"} = {
309         path  => "Search/Results.html$args",
310         title => loc('Show Results'),
311     };
312
313     $tabs->{"j"} = {
314         path  => "Search/Bulk.html$args",
315         title => loc('Bulk Update'),
316     };
317
318     $tabs->{"k"} = {
319         path  => "Search/Chart.html$args",
320         title => loc('Graph'),
321     };
322
323 }
324
325 foreach my $searchtab ( keys %{$searchtabs} ) {
326     ( $searchtab =~ /^_/ )
327         ? $tabs->{ "s" . $searchtab } = $searchtabs->{$searchtab}
328         : $tabs->{ "z_" . $searchtab } = $searchtabs->{$searchtab};
329 }
330
331 </%INIT>
332
333   
334 <%ARGS>
335 $Ticket => undef
336 $subtabs => undef
337 $current_tab => ''
338 $current_subtab => ''
339 $Title => undef
340 $RowsPerPage => undef
341 </%ARGS>