Merge branch 'master' of git.uio.no:usit-rt
[usit-rt.git] / share / html / Elements / Tabs
CommitLineData
84fb5b46
MKG
1%# BEGIN BPS TAGGED BLOCK {{{
2%#
3%# COPYRIGHT:
4%#
320f0092 5%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
84fb5b46
MKG
6%# <sales@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<& /Elements/PageLayout, show_menu => $show_menu &>
49<a name="skipnav" id="skipnav" accesskey="8"></a>
50<%INIT>
51
52my $request_path = $HTML::Mason::Commands::r->path_info;
dab09ea8 53$request_path =~ s!/{2,}!/!g;
84fb5b46
MKG
54
55my $query_string = sub {
56 my %args = @_;
57 my $u = URI->new();
01e3b242 58 $u->query_form(map { $_ => $args{$_} } sort keys %args);
84fb5b46
MKG
59 return $u->query;
60};
61
62my $build_admin_menu = sub {
63 my $top = shift;
af59614d 64 my $admin = $top->child( admin => title => loc('Admin'), path => '/Admin/' );
84fb5b46
MKG
65 if ( $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'AdminUsers' ) ) {
66 my $users = $admin->child( users =>
67 title => loc('Users'),
68 description => loc('Manage users and passwords'),
69 path => '/Admin/Users/',
70 );
71 $users->child( select => title => loc('Select'), path => "/Admin/Users/" );
72 $users->child( create => title => loc('Create'), path => "/Admin/Users/Modify.html?Create=1" );
73 }
74 my $groups = $admin->child( groups =>
75 title => loc('Groups'),
76 description => loc('Manage groups and group membership'),
77 path => '/Admin/Groups/',
78 );
79 $groups->child( select => title => loc('Select'), path => "/Admin/Groups/" );
80 $groups->child( create => title => loc('Create'), path => "/Admin/Groups/Modify.html?Create=1" );
81
82 my $queues = $admin->child( queues =>
83 title => loc('Queues'),
84 description => loc('Manage queues and queue-specific properties'),
85 path => '/Admin/Queues/',
86 );
87 $queues->child( select => title => loc('Select'), path => "/Admin/Queues/" );
88 $queues->child( create => title => loc('Create'), path => "/Admin/Queues/Modify.html?Create=1" );
89
90 if ( $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'AdminCustomField' ) ) {
91 my $cfs = $admin->child( 'custom-fields' =>
92 title => loc('Custom Fields'),
93 description => loc('Manage custom fields and custom field values'),
94 path => '/Admin/CustomFields/',
95 );
96 $cfs->child( select => title => loc('Select'), path => "/Admin/CustomFields/" );
97 $cfs->child( create => title => loc('Create'), path => "/Admin/CustomFields/Modify.html?Create=1" );
98 }
99
af59614d
MKG
100 if ( $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'ModifyScrips' ) ) {
101 my $scrips = $admin->child( 'scrips' =>
102 title => loc('Scrips'),
103 description => loc('Manage scrips'),
104 path => '/Admin/Scrips/',
105 );
106 $scrips->child( select => title => loc('Select'), path => "/Admin/Scrips/" );
107 $scrips->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html" );
108 }
109
84fb5b46
MKG
110 my $admin_global = $admin->child( global =>
111 title => loc('Global'),
112 description => loc('Manage properties and configuration which apply to all queues'),
113 path => '/Admin/Global/',
114 );
115
116 my $scrips = $admin_global->child( scrips =>
117 title => loc('Scrips'),
118 description => loc('Modify scrips which apply to all queues'),
119 path => '/Admin/Global/Scrips.html',
120 );
121 $scrips->child( select => title => loc('Select'), path => "/Admin/Global/Scrips.html" );
c33a4027 122 $scrips->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html?Global=1" );
84fb5b46
MKG
123
124 my $templates = $admin_global->child( templates =>
125 title => loc('Templates'),
126 description => loc('Edit system templates'),
127 path => '/Admin/Global/Templates.html',
128 );
129 $templates->child( select => title => loc('Select'), path => "/Admin/Global/Templates.html" );
130 $templates->child( create => title => loc('Create'), path => "/Admin/Global/Template.html?Create=1" );
131
132 my $cfadmin = $admin_global->child( 'custom-fields' =>
133 title => loc('Custom Fields'),
134 description => loc('Modify global custom fields'),
135 path => '/Admin/Global/CustomFields/index.html',
136 );
137 $cfadmin->child( users =>
138 title => loc('Users'),
139 description => loc('Select custom fields for all users'),
140 path => '/Admin/Global/CustomFields/Users.html',
141 );
142 $cfadmin->child( groups =>
143 title => loc('Groups'),
144 description => loc('Select custom fields for all user groups'),
145 path => '/Admin/Global/CustomFields/Groups.html',
146 );
147 $cfadmin->child( queues =>
148 title => loc('Queues'),
149 description => loc('Select custom fields for all queues'),
150 path => '/Admin/Global/CustomFields/Queues.html',
151 );
152 $cfadmin->child( tickets =>
153 title => loc('Tickets'),
154 description => loc('Select custom fields for tickets in all queues'),
155 path => '/Admin/Global/CustomFields/Queue-Tickets.html',
156 );
157 $cfadmin->child( transactions =>
158 title => loc('Ticket Transactions'),
159 description => loc('Select custom fields for transactions on tickets in all queues'),
160 path => '/Admin/Global/CustomFields/Queue-Transactions.html',
161 );
162 $cfadmin->child( 'custom-fields' =>
163 title => loc('Articles'),
164 description => loc('Select Custom Fields for Articles in all Classes'),
165 path => '/Admin/Global/CustomFields/Class-Article.html',
166 );
167
168 my $article_admin = $admin->child( articles => title => loc('Articles'), path => "/Admin/Articles/index.html" );
169 my $class_admin = $article_admin->child(classes => title => loc('Classes'), path => '/Admin/Articles/Classes/' );
170 $class_admin->child( select =>
171 title => loc('Select'),
172 description => loc('Modify and Create Classes'),
173 path => '/Admin/Articles/Classes/',
174 );
175 $class_admin->child( create =>
176 title => loc('Create'),
177 description => loc('Modify and Create Custom Fields for Articles'),
178 path => '/Admin/Articles/Classes/Modify.html?Create=1',
179 );
180
181
182 my $cfs = $article_admin->child( 'custom-fields' =>
183 title => loc('Custom Fields'),
af59614d 184 path => '/Admin/CustomFields/index.html?'.$m->comp('/Elements/QueryString', Type => 'RT::Class-RT::Article'),
84fb5b46
MKG
185 );
186 $cfs->child( select =>
187 title => loc('Select'),
af59614d 188 path => '/Admin/CustomFields/index.html?'.$m->comp('/Elements/QueryString', Type => 'RT::Class-RT::Article'),
84fb5b46
MKG
189 );
190 $cfs->child( create =>
191 title => loc('Create'),
192 path => '/Admin/CustomFields/Modify.html?'.$m->comp("/Elements/QueryString", Create=>1, LookupType=> "RT::Class-RT::Article" ),
193 );
194
195 $admin_global->child( 'group-rights' =>
196 title => loc('Group Rights'),
197 description => loc('Modify global group rights'),
198 path => '/Admin/Global/GroupRights.html',
199 );
200 $admin_global->child( 'user-rights' =>
201 title => loc('User Rights'),
202 description => loc('Modify global user rights'),
203 path => '/Admin/Global/UserRights.html',
204 );
205 $admin_global->child( 'my-rt' =>
206 title => loc('RT at a glance'),
207 description => loc('Modify the default "RT at a glance" view'),
208 path => '/Admin/Global/MyRT.html',
209 );
af59614d
MKG
210 $admin_global->child( 'dashboards-in-menu' =>
211 title => loc('Dashboards in menu'),
212 description => loc('Customize dashboards in menu'),
213 path => '/Admin/Global/DashboardsInMenu.html',
214 );
84fb5b46
MKG
215 $admin_global->child( 'topics' =>
216 title => loc('Topics'),
217 description => loc('Modify global article topics'),
218 path => '/Admin/Global/Topics.html',
219 );
220
221 my $admin_tools = $admin->child( tools =>
222 title => loc('Tools'),
223 description => loc('Use other RT administrative tools'),
224 path => '/Admin/Tools/',
225 );
226 $admin_tools->child( configuration =>
227 title => loc('System Configuration'),
228 description => loc('Detailed information about your RT setup'),
229 path => '/Admin/Tools/Configuration.html',
230 );
231 $admin_tools->child( theme =>
232 title => loc('Theme'),
233 description => loc('Customize the look of your RT'),
234 path => '/Admin/Tools/Theme.html',
235 );
236 if (RT->Config->Get('StatementLog')
237 && $session{'CurrentUser'}->HasRight( Right => 'SuperUser', Object => RT->System )) {
238 $admin_tools->child( 'sql-queries' =>
239 title => loc('SQL Queries'),
240 description => loc('Browse the SQL queries made in this process'),
241 path => '/Admin/Tools/Queries.html',
242 );
243 }
244 $admin_tools->child( shredder =>
245 title => loc('Shredder'),
246 description => loc('Permanently wipeout data from RT'),
247 path => '/Admin/Tools/Shredder',
248 );
249
250 if ( $request_path =~ m{^/Admin/(Queues|Users|Groups|CustomFields)} ) {
251 my $type = $1;
252 my $tabs = PageMenu();
253
254 my %labels = (
255 Queues => loc("Queues"),
256 Users => loc("Users"),
257 Groups => loc("Groups"),
258 CustomFields => loc("Custom Fields"),
259 );
260
261 my $section;
262 if ( $request_path =~ m|^/Admin/$type/?(?:index.html)?$|
263 || ( $request_path =~ m|^/Admin/$type/(?:Modify.html)$|
b5747ff2 264 && $DECODED_ARGS->{'Create'} )
84fb5b46
MKG
265 )
266 {
267 $section = $tabs;
268
269 } else {
270 $section = $tabs->child( select => title => $labels{$type},
271 path => "/Admin/$type/" );
272 }
273
274 $section->child( select => title => loc('Select'), path => "/Admin/$type/" );
275 $section->child( create => title => loc('Create'), path => "/Admin/$type/Modify.html?Create=1" );
276 }
277
278 if ( $request_path =~ m{^/Admin/Queues} ) {
b5747ff2 279 if ( $DECODED_ARGS->{'id'} && $DECODED_ARGS->{'id'} =~ /^\d+$/
84fb5b46 280 ||
b5747ff2 281 $DECODED_ARGS->{'Queue'} && $DECODED_ARGS->{'Queue'} =~ /^\d+$/
84fb5b46 282 ) {
b5747ff2 283 my $id = $DECODED_ARGS->{'Queue'} || $DECODED_ARGS->{'id'};
84fb5b46
MKG
284 my $queue_obj = RT::Queue->new( $session{'CurrentUser'} );
285 $queue_obj->Load($id);
286
403d7b0b
MKG
287 if ( $queue_obj and $queue_obj->id ) {
288 my $queue = PageMenu();
289 $queue->child( basics => title => loc('Basics'), path => "/Admin/Queues/Modify.html?id=" . $id );
290 $queue->child( people => title => loc('Watchers'), path => "/Admin/Queues/People.html?id=" . $id );
84fb5b46 291
403d7b0b
MKG
292 my $templates = $queue->child(templates => title => loc('Templates'), path => "/Admin/Queues/Templates.html?id=" . $id);
293 $templates->child( select => title => loc('Select'), path => "/Admin/Queues/Templates.html?id=".$id);
294 $templates->child( create => title => loc('Create'), path => "/Admin/Queues/Template.html?Create=1;Queue=".$id);
84fb5b46 295
403d7b0b
MKG
296 my $scrips = $queue->child( scrips => title => loc('Scrips'), path => "/Admin/Queues/Scrips.html?id=" . $id);
297 $scrips->child( select => title => loc('Select'), path => "/Admin/Queues/Scrips.html?id=" . $id );
af59614d 298 $scrips->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html?Queue=" . $id);
84fb5b46 299
af59614d
MKG
300 my $cfs = $queue->child( 'custom-fields' => title => loc('Custom Fields') );
301 my $ticket_cfs = $cfs->child( 'tickets' => title => loc('Tickets'),
403d7b0b 302 path => '/Admin/Queues/CustomFields.html?SubType=RT::Ticket&id=' . $id );
84fb5b46 303
af59614d 304 my $txn_cfs = $cfs->child( 'transactions' => title => loc('Transactions'),
403d7b0b 305 path => '/Admin/Queues/CustomFields.html?SubType=RT::Ticket-RT::Transaction&id='.$id );
84fb5b46 306
403d7b0b
MKG
307 $queue->child( 'group-rights' => title => loc('Group Rights'), path => "/Admin/Queues/GroupRights.html?id=".$id );
308 $queue->child( 'user-rights' => title => loc('User Rights'), path => "/Admin/Queues/UserRights.html?id=" . $id );
309 $queue->child( 'history' => title => loc('History'), path => "/Admin/Queues/History.html?id=" . $id );
84fb5b46 310
403d7b0b
MKG
311 $m->callback( CallbackName => 'PrivilegedQueue', queue_id => $id, page_menu => $queue);
312 }
84fb5b46
MKG
313 }
314 }
af59614d 315 if ( $request_path =~ m{^(/Admin/Users|/User/(Summary|History)\.html)} and $admin->child("users") ) {
b5747ff2
MKG
316 if ( $DECODED_ARGS->{'id'} && $DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
317 my $id = $DECODED_ARGS->{'id'};
84fb5b46
MKG
318 my $obj = RT::User->new( $session{'CurrentUser'} );
319 $obj->Load($id);
320
403d7b0b
MKG
321 if ( $obj and $obj->id ) {
322 my $tabs = PageMenu();
323 $tabs->child( basics => title => loc('Basics'), path => "/Admin/Users/Modify.html?id=" . $id );
324 $tabs->child( memberships => title => loc('Memberships'), path => "/Admin/Users/Memberships.html?id=" . $id );
325 $tabs->child( history => title => loc('History'), path => "/Admin/Users/History.html?id=" . $id );
326 $tabs->child( 'my-rt' => title => loc('RT at a glance'), path => "/Admin/Users/MyRT.html?id=" . $id );
af59614d
MKG
327 $tabs->child( 'dashboards-in-menu' =>
328 title => loc('Dashboards in menu'),
329 path => '/Admin/Users/DashboardsInMenu.html?id=' . $id,
330 );
331 if ( RT->Config->Get('Crypt')->{'Enable'} ) {
332 $tabs->child( keys => title => loc('Private keys'), path => "/Admin/Users/Keys.html?id=" . $id );
403d7b0b 333 }
af59614d 334 $tabs->child( 'summary' => title => loc('User Summary'), path => "/User/Summary.html?id=" . $id );
84fb5b46
MKG
335 }
336 }
337
338 }
339
340 if ( $request_path =~ m{^/Admin/Groups} ) {
b5747ff2
MKG
341 if ( $DECODED_ARGS->{'id'} && $DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
342 my $id = $DECODED_ARGS->{'id'};
84fb5b46
MKG
343 my $obj = RT::Group->new( $session{'CurrentUser'} );
344 $obj->Load($id);
345
af59614d 346 if ( $obj and $obj->id ) {
403d7b0b
MKG
347 my $tabs = PageMenu();
348 $tabs->child( basics => title => loc('Basics'), path => "/Admin/Groups/Modify.html?id=" . $obj->id );
349 $tabs->child( members => title => loc('Members'), path => "/Admin/Groups/Members.html?id=" . $obj->id );
af59614d 350 $tabs->child( memberships => title => loc('Memberships'), path => "/Admin/Groups/Memberships.html?id=" . $obj->id );
403d7b0b
MKG
351 $tabs->child( 'group-rights' => title => loc('Group Rights'), path => "/Admin/Groups/GroupRights.html?id=" . $obj->id );
352 $tabs->child( 'user-rights' => title => loc('User Rights'), path => "/Admin/Groups/UserRights.html?id=" . $obj->id );
353 $tabs->child( history => title => loc('History'), path => "/Admin/Groups/History.html?id=" . $obj->id );
354 }
84fb5b46
MKG
355 }
356 }
357
358 if ( $request_path =~ m{^/Admin/CustomFields/} ) {
b5747ff2
MKG
359 if ( $DECODED_ARGS->{'id'} && $DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
360 my $id = $DECODED_ARGS->{'id'};
84fb5b46
MKG
361 my $obj = RT::CustomField->new( $session{'CurrentUser'} );
362 $obj->Load($id);
363
403d7b0b
MKG
364 if ( $obj and $obj->id ) {
365 my $tabs = PageMenu();
af59614d
MKG
366 $tabs->child( basics => title => loc('Basics'), path => "/Admin/CustomFields/Modify.html?id=".$id );
367 $tabs->child( 'group-rights' => title => loc('Group Rights'), path => "/Admin/CustomFields/GroupRights.html?id=" . $id );
368 $tabs->child( 'user-rights' => title => loc('User Rights'), path => "/Admin/CustomFields/UserRights.html?id=" . $id );
369 unless ( $obj->IsOnlyGlobal ) {
370 $tabs->child( 'applies-to' => title => loc('Applies to'), path => "/Admin/CustomFields/Objects.html?id=" . $id );
371 }
403d7b0b 372 }
84fb5b46
MKG
373 }
374 }
375
af59614d
MKG
376 if ( $request_path =~ m{^/Admin/Scrips/} ) {
377 if ( $m->request_args->{'id'} && $m->request_args->{'id'} =~ /^\d+$/ ) {
378 my $id = $m->request_args->{'id'};
379 my $obj = RT::Scrip->new( $session{'CurrentUser'} );
380 $obj->Load($id);
381
382 my $tabs = PageMenu();
c33a4027
MKG
383
384 my ( $admin_cat, $create_path_arg, $from_query_param );
385 my $from_arg = $DECODED_ARGS->{'From'} || q{};
386 my ($from_queue) = $from_arg =~ /^(\d+)$/;
387 if ( $from_queue ) {
388 $admin_cat = "Queues/Scrips.html?id=$from_queue";
389 $create_path_arg = "?Queue=$from_queue";
390 $from_query_param = "&From=$from_queue";
391 }
392 elsif ( $from_arg eq 'Global' ) {
393 $admin_cat = 'Global/Scrips.html';
394 $create_path_arg = '?Global=1';
395 $from_query_param = '&From=Global';
396 }
397 else {
398 $admin_cat = 'Scrips';
399 $from_query_param = $create_path_arg = q{};
400 }
401 my $scrips = $tabs->child( scrips => title => loc('Scrips'), path => "/Admin/${admin_cat}" );
402 $scrips->child( select => title => loc('Select'), path => "/Admin/${admin_cat}" );
403 $scrips->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html${create_path_arg}" );
404
405 $tabs->child( basics => title => loc('Basics') => path => "/Admin/Scrips/Modify.html?id=" . $id . $from_query_param );
406 $tabs->child( 'applies-to' => title => loc('Applies to'), path => "/Admin/Scrips/Objects.html?id=" . $id . $from_query_param );
af59614d
MKG
407 }
408 elsif ( $request_path =~ m{^/Admin/Scrips/(index\.html)?$} ) {
409 PageMenu->child( select => title => loc('Select') => path => "/Admin/Scrips/" );
410 PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html" );
411 }
412 elsif ( $request_path =~ m{^/Admin/Scrips/Create\.html$} ) {
413 my ($queue) = $DECODED_ARGS->{'Queue'} && $DECODED_ARGS->{'Queue'} =~ /^(\d+)$/;
c33a4027 414 my $global_arg = $DECODED_ARGS->{'Global'};
af59614d
MKG
415 if ($queue) {
416 PageMenu->child( select => title => loc('Select') => path => "/Admin/Queues/Scrips.html?id=$queue" );
417 PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html?Queue=$queue" );
c33a4027 418 } elsif ($global_arg) {
af59614d 419 PageMenu->child( select => title => loc('Select') => path => "/Admin/Global/Scrips.html" );
c33a4027
MKG
420 PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html?Global=1" );
421 } else {
422 PageMenu->child( select => title => loc('Select') => path => "/Admin/Scrips" );
af59614d
MKG
423 PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html" );
424 }
425 }
426 }
84fb5b46 427
af59614d
MKG
428 if ( $request_path =~ m{^/Admin/Global/Scrips\.html} ) {
429 my $tabs = PageMenu();
430 $tabs->child( select => title => loc('Select'), path => "/Admin/Global/Scrips.html" );
c33a4027 431 $tabs->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html?Global=1" );
af59614d 432 }
84fb5b46 433
af59614d
MKG
434 if ( $request_path =~ m{^/Admin/Global/Templates?\.html} ) {
435 my $tabs = PageMenu();
436 $tabs->child( select => title => loc('Select'), path => "/Admin/Global/Templates.html" );
437 $tabs->child( create => title => loc('Create'), path => "/Admin/Global/Template.html?Create=1" );
84fb5b46
MKG
438 }
439
440 if ( $request_path =~ m{^/Admin/Articles/Classes/} ) {
441 my $tabs = PageMenu();
b5747ff2 442 if ( my $id = $DECODED_ARGS->{'id'} ) {
c36a7e1d 443 my $obj = RT::Class->new( $session{'CurrentUser'} );
84fb5b46
MKG
444 $obj->Load($id);
445
403d7b0b
MKG
446 if ( $obj and $obj->id ) {
447 my $section = $tabs->child( select => title => loc("Classes"), path => "/Admin/Articles/Classes/" );
448 $section->child( select => title => loc('Select'), path => "/Admin/Articles/Classes/" );
449 $section->child( create => title => loc('Create'), path => "/Admin/Articles/Classes/Modify.html?Create=1" );
450
451 $tabs->child( basics => title => loc('Basics'), path => "/Admin/Articles/Classes/Modify.html?id=".$id );
452 $tabs->child( topics => title => loc('Topics'), path => "/Admin/Articles/Classes/Topics.html?id=".$id );
453 $tabs->child( 'custom-fields' => title => loc('Custom Fields'), path => "/Admin/Articles/Classes/CustomFields.html?id=".$id );
454 $tabs->child( 'group-rights' => title => loc('Group Rights'), path => "/Admin/Articles/Classes/GroupRights.html?id=".$id );
455 $tabs->child( 'user-rights' => title => loc('User Rights'), path => "/Admin/Articles/Classes/UserRights.html?id=".$id );
456 $tabs->child( 'applies-to' => title => loc('Applies to'), path => "/Admin/Articles/Classes/Objects.html?id=$id" );
457 }
84fb5b46
MKG
458 } else {
459 $tabs->child( select => title => loc('Select'), path => "/Admin/Articles/Classes/" );
460 $tabs->child( create => title => loc('Create'), path => "/Admin/Articles/Classes/Modify.html?Create=1" );
461 }
462 }
463};
464
84fb5b46
MKG
465my $build_main_nav = sub {
466
c36a7e1d
MKG
467 PageWidgets()->child( simple_search => raw_html => $m->scomp('SimpleSearch') );
468 PageWidgets()->child( create_ticket => raw_html => $m->scomp('CreateTicket') );
469
84fb5b46 470 my $home = Menu->child( home => title => loc('Homepage'), path => '/' );
af59614d
MKG
471 unless ($session{'dashboards_in_menu'}) {
472 my $dashboards_in_menu = $session{CurrentUser}->UserObj->Preferences(
473 'DashboardsInMenu',
474 {},
475 );
84fb5b46 476
af59614d
MKG
477 unless ($dashboards_in_menu->{dashboards}) {
478 my ($default_dashboards) =
479 RT::System->new( $session{'CurrentUser'} )
480 ->Attributes
481 ->Named('DashboardsInMenu');
482 if ($default_dashboards) {
483 $dashboards_in_menu = $default_dashboards->Content;
484 }
485 }
486
487 $session{'dashboards_in_menu'} = $dashboards_in_menu->{dashboards} || [];
488 }
489
490 my @dashboards;
491 for my $id ( @{$session{'dashboards_in_menu'}} ) {
492 my $dash = RT::Dashboard->new( $session{CurrentUser} );
493 my ( $status, $msg ) = $dash->LoadById($id);
494 if ( $status ) {
495 push @dashboards, $dash;
496 } else {
497 $RT::Logger->warning( "Failed to load dashboard $id: $msg" );
498 }
84fb5b46
MKG
499 }
500
501 my $dashes = Menu()->child('home');
502 if (@dashboards) {
503 for my $dash (@dashboards) {
504 $home->child( 'dashboard-' . $dash->id,
505 title => $dash->Name,
506 path => '/Dashboards/' . $dash->id . '/' . $dash->Name
507 );
508 }
84fb5b46 509 }
af59614d
MKG
510 $dashes->child( edit => title => loc('Update This Menu'), path => 'Prefs/DashboardsInMenu.html' );
511 $dashes->child( more => title => loc('All Dashboards'), path => 'Dashboards/index.html' );
84fb5b46
MKG
512 my $dashboard = RT::Dashboard->new( $session{CurrentUser} );
513 if ( $dashboard->CurrentUserCanCreateAny ) {
514 $dashes->child('dashboard_create' => title => loc('New Dashboard'), path => "/Dashboards/Modify.html?Create=1" );
515 }
516
af59614d
MKG
517 my $search = Menu->child( search => title => loc('Search'), path => '/Search/Simple.html' );
518
519 my $tickets = $search->child( tickets => title => loc('Tickets'), path => '/Search/Build.html' );
84fb5b46
MKG
520 $tickets->child( simple => title => loc('Simple Search'), path => "/Search/Simple.html" );
521 $tickets->child( new => title => loc('New Search'), path => "/Search/Build.html?NewQuery=1" );
522
af59614d
MKG
523 $search->child( articles => title => loc('Articles'), path => "/Articles/Article/Search.html" )
524 if $session{CurrentUser}->HasRight( Right => 'ShowArticlesMenu', Object => RT->System );
525
526 $search->child( users => title => loc('Users'), path => "/User/Search.html" );
527
528 if ($session{CurrentUser}->HasRight( Right => 'ShowArticlesMenu', Object => RT->System )) {
529 my $articles = Menu->child( articles => title => loc('Articles'), path => "/Articles/index.html");
530 $articles->child( articles => title => loc('Overview'), path => "/Articles/index.html" );
531 $articles->child( topics => title => loc('Topics'), path => "/Articles/Topics.html" );
532 $articles->child( create => title => loc('Create'), path => "/Articles/Article/PreCreate.html" );
533 $articles->child( search => title => loc('Search'), path => "/Articles/Article/Search.html" );
534 }
84fb5b46
MKG
535
536 my $tools = Menu->child( tools => title => loc('Tools'), path => '/Tools/index.html' );
84fb5b46
MKG
537
538 $tools->child( my_day =>
539 title => loc('My Day'),
540 description => loc('Easy updating of your open tickets'),
541 path => '/Tools/MyDay.html',
542 );
543
544 if ( RT->Config->Get('EnableReminders') ) {
545 $tools->child( my_reminders =>
546 title => loc('My Reminders'),
547 description => loc('Easy viewing of your reminders'),
548 path => '/Tools/MyReminders.html',
549 );
550 }
551
84fb5b46
MKG
552 if ( $session{'CurrentUser'}->HasRight( Right => 'ShowApprovalsTab', Object => RT->System ) ) {
553 $tools->child( approval =>
554 title => loc('Approval'),
555 description => loc('My Approvals'),
556 path => '/Approvals/',
557 );
558 }
559
560 if ( $session{'CurrentUser'}->HasRight( Right => 'ShowConfigTab', Object => RT->System ) )
561 {
af59614d 562 $build_admin_menu->(Menu());
84fb5b46
MKG
563 }
564
565 my $username = '<span class="current-user">'
566 . $m->interp->apply_escapes($session{'CurrentUser'}->Name, 'h')
567 . '</span>';
568 my $about_me = Menu->child( 'preferences' =>
569 title => loc('Logged in as [_1]', $username),
570 escape_title => 0,
af59614d 571 path => '/User/Summary.html?id=' . $session{CurrentUser}->id,
84fb5b46
MKG
572 sort_order => 99,
573 );
574
575
576 if ( $session{'CurrentUser'}->UserObj
577 && $session{'CurrentUser'}->HasRight( Right => 'ModifySelf', Object => RT->System )) {
578 my $settings = $about_me->child( settings => title => loc('Settings'), path => '/Prefs/Other.html' );
af59614d 579 $settings->child( options => title => loc('Preferences'), path => '/Prefs/Other.html' );
84fb5b46
MKG
580 $settings->child( about_me => title => loc('About me'), path => '/User/Prefs.html' );
581 $settings->child( search_options => title => loc('Search options'), path => '/Prefs/SearchOptions.html' );
582 $settings->child( myrt => title => loc('RT at a glance'), path => '/Prefs/MyRT.html' );
af59614d
MKG
583 $settings->child( dashboards_in_menu =>
584 title => loc('Dashboards in menu'),
585 path => '/Prefs/DashboardsInMenu.html',
586 );
84fb5b46
MKG
587 $settings->child( quicksearch => title => loc('Quick search'), path => '/Prefs/Quicksearch.html' );
588
589 my $search_menu = $settings->child( 'saved-searches' => title => loc('Saved Searches') );
590 my $searches = [ $m->comp( "/Search/Elements/SearchesForObject",
591 Object => RT::System->new( $session{'CurrentUser'} )) ];
592 my $i = 0;
593
594 for my $search (@$searches) {
595 $search_menu->child( "search-" . $i++ =>
5b0d0914 596 title => $search->[1],
84fb5b46 597 path => "/Prefs/Search.html?"
5b0d0914 598 . $query_string->( name => ref( $search->[2] ) . '-' . $search->[2]->Id ),
84fb5b46
MKG
599 );
600
601 }
602 }
603 if ( $session{'CurrentUser'}->Name
af59614d
MKG
604 && ( !RT->Config->Get('WebRemoteUserAuth')
605 || RT->Config->Get('WebFallbackToRTLogin') )) {
84fb5b46
MKG
606 $about_me->child( logout => title => loc('Logout'), path => '/NoAuth/Logout.html' );
607 }
608 if ( $request_path =~ m{^/Dashboards/(\d+)?}) {
b5747ff2 609 if ( my $id = ( $1 || $DECODED_ARGS->{'id'} ) ) {
84fb5b46
MKG
610 my $obj = RT::Dashboard->new( $session{'CurrentUser'} );
611 $obj->LoadById($id);
612 if ( $obj and $obj->id ) {
613 my $tabs = PageMenu;
614 $tabs->child( basics => title => loc('Basics'), path => "/Dashboards/Modify.html?id=" . $obj->id);
615 $tabs->child( content => title => loc('Content'), path => "/Dashboards/Queries.html?id=" . $obj->id);
616 $tabs->child( subscription => title => loc('Subscription'), path => "/Dashboards/Subscription.html?id=" . $obj->id)
617 if $obj->CurrentUserCanSubscribe;
618 $tabs->child( show => title => loc('Show'), path => "/Dashboards/" . $obj->id . "/" . $obj->Name)
619 }
620 }
621 }
622
623
624 if ( $request_path =~ m{^/Ticket/} ) {
b5747ff2 625 if ( ( $DECODED_ARGS->{'id'} || '' ) =~ /^(\d+)$/ ) {
84fb5b46
MKG
626 my $id = $1;
627 my $obj = RT::Ticket->new( $session{'CurrentUser'} );
628 $obj->Load($id);
629
403d7b0b
MKG
630 if ( $obj and $obj->id ) {
631 my $actions = PageMenu()->child( actions => title => loc('Actions'), sort_order => 95 );
632 my $tabs = PageMenu();
633 $tabs->child( bookmark => raw_html => $m->scomp( '/Ticket/Elements/Bookmark', id => $id ), sort_order => 99 );
634 $tabs->child( display => title => loc('Display'), path => "/Ticket/Display.html?id=" . $id );
635 $tabs->child( history => title => loc('History'), path => "/Ticket/History.html?id=" . $id );
636
637 my %can = %{ $obj->CurrentUser->PrincipalObj->HasRights( Object => $obj ) };
af59614d 638 $can{'_ModifyOwner'} = $obj->CurrentUserCanSetOwner();
403d7b0b
MKG
639 my $can = sub {
640 unless ($_[0] eq 'ExecuteCode') {
641 return $can{$_[0]} || $can{'SuperUser'};
642 } else {
643 return !RT->Config->Get('DisallowExecuteCode')
644 && ( $can{'ExecuteCode'} || $can{'SuperUser'} );
645 }
646 };
647
648 # comment out until we can do it for an individual custom field
649 #if ( $can->('ModifyTicket') || $can->('ModifyCustomField') ) {
650 $tabs->child( basics => title => loc('Basics'), path => "/Ticket/Modify.html?id=" . $id );
651
652 #}
653
654 if ( $can->('ModifyTicket') || $can->('_ModifyOwner') || $can->('Watch') || $can->('WatchAsAdminCc') ) {
655 $tabs->child( people => title => loc('People'), path => "/Ticket/ModifyPeople.html?id=" . $id );
84fb5b46 656 }
84fb5b46 657
403d7b0b
MKG
658 if ( $can->('ModifyTicket') ) {
659 $tabs->child( dates => title => loc('Dates'), path => "/Ticket/ModifyDates.html?id=" . $id );
660 $tabs->child( links => title => loc('Links'), path => "/Ticket/ModifyLinks.html?id=" . $id );
661 }
84fb5b46 662
403d7b0b
MKG
663 #if ( $can->('ModifyTicket') || $can->('ModifyCustomField') || $can->('_ModifyOwner') ) {
664 $tabs->child( jumbo => title => loc('Jumbo'), path => "/Ticket/ModifyAll.html?id=" . $id );
665 #}
84fb5b46 666
403d7b0b
MKG
667 if ( RT->Config->Get('EnableReminders') ) {
668 $tabs->child( reminders => title => loc('Reminders'), path => "/Ticket/Reminders.html?id=" . $id );
84fb5b46 669 }
84fb5b46 670
403d7b0b
MKG
671 if ( $can->('ModifyTicket') or $can->('ReplyToTicket') ) {
672 $actions->child( reply => title => loc('Reply'), path => "/Ticket/Update.html?Action=Respond;id=" . $id );
84fb5b46
MKG
673 }
674
403d7b0b
MKG
675 if ( $can->('ModifyTicket') or $can->('CommentOnTicket') ) {
676 $actions->child( comment => title => loc('Comment'), path => "/Ticket/Update.html?Action=Comment;id=" . $id );
84fb5b46 677 }
84fb5b46 678
403d7b0b
MKG
679 if ( $can->('ForwardMessage') ) {
680 $actions->child( forward => title => loc('Forward'), path => "/Ticket/Forward.html?id=" . $id );
681 }
84fb5b46 682
403d7b0b
MKG
683 my $hide_resolve_with_deps = RT->Config->Get('HideResolveActionsWithDependencies')
684 && $obj->HasUnresolvedDependencies;
685
686 my $current = $obj->Status;
af59614d 687 my $lifecycle = $obj->LifecycleObj;
403d7b0b
MKG
688 my $i = 1;
689 foreach my $info ( $lifecycle->Actions($current) ) {
690 my $next = $info->{'to'};
691 next unless $lifecycle->IsTransition( $current => $next );
692
693 my $check = $lifecycle->CheckRight( $current => $next );
694 next unless $can->($check);
695
696 next if $hide_resolve_with_deps
697 && $lifecycle->IsInactive($next)
698 && !$lifecycle->IsInactive($current);
699
700 my $action = $info->{'update'} || '';
701 my $url = '/Ticket/';
af59614d
MKG
702 $url .= "Update.html?". $query_string->(
703 $action
704 ? (Action => $action)
705 : (SubmitTicket => 1, Status => $next),
706 DefaultStatus => $next,
707 id => $id,
708 );
403d7b0b
MKG
709 my $key = $info->{'label'} || ucfirst($next);
710 $actions->child( $key => title => loc( $key ), path => $url);
84fb5b46
MKG
711 }
712
af59614d
MKG
713 my ($can_take, $tmsg) = $obj->CurrentUserCanSetOwner( Type => 'Take' );
714 my ($can_steal, $smsg) = $obj->CurrentUserCanSetOwner( Type => 'Steal' );
715 if ( $can_take ){
716 $actions->child( take => title => loc('Take'), path => "/Ticket/Display.html?Action=Take;id=" . $id );
717 }
718 elsif ( $can_steal ){
719 $actions->child( steal => title => loc('Steal'), path => "/Ticket/Display.html?Action=Steal;id=" . $id );
84fb5b46 720 }
403d7b0b
MKG
721
722 # TODO needs a "Can extract article into a class applied to this queue" check
723 $actions->child( 'extract-article' =>
724 title => loc('Extract Article'),
725 path => "/Articles/Article/ExtractIntoClass.html?Ticket=".$obj->id,
af59614d 726 ) if $session{CurrentUser}->HasRight( Right => 'ShowArticlesMenu', Object => RT->System );
403d7b0b
MKG
727
728 if ( defined $session{"tickets"} ) {
729 # we have to update session data if we get new ItemMap
730 my $updatesession = 1 unless ( $session{"tickets"}->{'item_map'} );
731
732 my $item_map = $session{"tickets"}->ItemMap;
733
734 if ($updatesession) {
735 $session{"tickets"}->PrepForSerialization();
736 }
737
af59614d 738 my $search = Menu()->child('search')->child('tickets');
403d7b0b
MKG
739 # Don't display prev links if we're on the first ticket
740 if ( $item_map->{$id}->{prev} ) {
741 $search->child( first =>
742 title => '<< ' . loc('First'), class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{first});
743 $search->child( prev =>
744 title => '< ' . loc('Prev'), class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{$id}->{prev});
745 }
746 # Don't display next links if we're on the last ticket
747 if ( $item_map->{$id}->{next} ) {
748 $search->child( next =>
749 title => loc('Next') . ' >', class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{$id}->{next});
320f0092
MKG
750 if ( $item_map->{last} ) {
751 $search->child( last =>
752 title => loc('Last') . ' >>', class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{last});
753 }
403d7b0b 754 }
84fb5b46
MKG
755 }
756 }
757 }
758 }
759
760 if (
761 (
762 $request_path =~ m{^/(?:Ticket|Search)/}
763 && $request_path !~ m{^/Search/Simple\.html}
764 )
765 || ( $request_path =~ m{^/Search/Simple\.html}
b5747ff2 766 && $DECODED_ARGS->{'q'} )
84fb5b46
MKG
767 )
768 {
af59614d 769 my $search = Menu()->child('search')->child('tickets');
84fb5b46
MKG
770 my $args = '';
771 my $has_query = '';
772 my $current_search = $session{"CurrentSearchHash"} || {};
b5747ff2
MKG
773 my $search_id = $DECODED_ARGS->{'SavedSearchLoad'} || $DECODED_ARGS->{'SavedSearchId'} || $current_search->{'SearchId'} || '';
774 my $chart_id = $DECODED_ARGS->{'SavedChartSearchId'} || $current_search->{SavedChartSearchId};
84fb5b46 775
b5747ff2 776 $has_query = 1 if ( $DECODED_ARGS->{'Query'} or $current_search->{'Query'} );
84fb5b46
MKG
777
778 my %query_args;
779 my %fallback_query_args = (
780 SavedSearchId => ( $search_id eq 'new' ) ? undef : $search_id,
781 SavedChartSearchId => $chart_id,
782 (
783 map {
784 my $p = $_;
b5747ff2 785 $p => $DECODED_ARGS->{$p} || $current_search->{$p}
84fb5b46
MKG
786 } qw(Query Format OrderBy Order Page)
787 ),
788 RowsPerPage => (
b5747ff2
MKG
789 defined $DECODED_ARGS->{'RowsPerPage'}
790 ? $DECODED_ARGS->{'RowsPerPage'}
84fb5b46
MKG
791 : $current_search->{'RowsPerPage'}
792 ),
793 );
794
795 if ($QueryString) {
796 $args = '?' . $QueryString;
797 }
798 else {
799 my %final_query_args = ();
800 # key => callback to avoid unnecessary work
801
802 for my $param (keys %fallback_query_args) {
803 $final_query_args{$param} = defined($QueryArgs->{$param})
804 ? $QueryArgs->{$param}
805 : $fallback_query_args{$param};
806 }
807
808 for my $field (qw(Order OrderBy)) {
809 if ( ref( $final_query_args{$field} ) eq 'ARRAY' ) {
810 $final_query_args{$field} = join( "|", @{ $final_query_args{$field} } );
811 } elsif (not defined $final_query_args{$field}) {
812 delete $final_query_args{$field};
813 }
814 else {
815 $final_query_args{$field} ||= '';
816 }
817 }
818
819 $args = '?' . $query_string->(%final_query_args);
820 }
821
822 my $current_search_menu;
823 if ( $request_path =~ m{^/Ticket} ) {
824 $current_search_menu = $search->child( current_search => title => loc('Current Search') );
825 $current_search_menu->path("/Search/Results.html$args") if $has_query;
826 } else {
827 $current_search_menu = PageMenu();
828 }
829
830 $current_search_menu->child( edit_search =>
831 title => loc('Edit Search'), path => "/Search/Build.html" . ( ($has_query) ? $args : '' ) );
832 $current_search_menu->child( advanced =>
833 title => loc('Advanced'), path => "/Search/Edit.html$args" );
834 if ($has_query) {
835 $current_search_menu->child( results => title => loc('Show Results'), path => "/Search/Results.html$args" );
836 }
837
838 if ( $has_query ) {
839 $current_search_menu->child( bulk => title => loc('Bulk Update'), path => "/Search/Bulk.html$args" );
840 $current_search_menu->child( chart => title => loc('Chart'), path => "/Search/Chart.html$args" );
841
842 my $more = $current_search_menu->child( more => title => loc('Feeds') );
843
844 $more->child( spreadsheet => title => loc('Spreadsheet'), path => "/Search/Results.tsv$args" );
845
846 my %rss_data = map {
847 $_ => $QueryArgs->{$_} || $fallback_query_args{$_} || '' }
848 qw(Query Order OrderBy);
849 my $RSSQueryString = "?"
850 . $query_string->( Query => $rss_data{Query},
851 Order => $rss_data{Order},
852 OrderBy => $rss_data{OrderBy}
853 );
854 my $RSSPath = join '/', map $m->interp->apply_escapes( $_, 'u' ),
855 $session{'CurrentUser'}->UserObj->Name,
856 $session{'CurrentUser'}
857 ->UserObj->GenerateAuthString( $rss_data{Query}
858 . $rss_data{Order}
859 . $rss_data{OrderBy} );
860
861 $more->child( rss => title => loc('RSS'), path => "/NoAuth/rss/$RSSPath/$RSSQueryString");
862 my $ical_path = join '/', map $m->interp->apply_escapes($_, 'u'),
863 $session{'CurrentUser'}->UserObj->Name,
864 $session{'CurrentUser'}->UserObj->GenerateAuthString( $rss_data{Query} ),
865 $rss_data{Query};
866 $more->child( ical => title => loc('iCal'), path => '/NoAuth/iCal/'.$ical_path);
867
868 if ($request_path =~ m{^/Search/Results.html}
869 && #XXX TODO better abstraction
870 $session{'CurrentUser'}->HasRight( Right => 'SuperUser', Object => RT->System )) {
871 my $shred_args = $query_string->(
c36a7e1d
MKG
872 Search => 1,
873 Plugin => 'Tickets',
84fb5b46
MKG
874 'Tickets:query' => $rss_data{'Query'},
875 'Tickets:limit' => $QueryArgs->{'Rows'},
876 );
877
878 $more->child( shredder => title => loc('Shredder'), path => '/Admin/Tools/Shredder/?' . $shred_args);
879 }
880
881 }
882 }
883
884 if ( $request_path =~ m{^/Article/} ) {
b5747ff2
MKG
885 if ( $DECODED_ARGS->{'id'} && $DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
886 my $id = $DECODED_ARGS->{'id'};
84fb5b46
MKG
887 my $tabs = PageMenu();
888
889 $tabs->child( display => title => loc('Display'), path => "/Articles/Article/Display.html?id=".$id );
890 $tabs->child( history => title => loc('History'), path => "/Articles/Article/History.html?id=".$id );
891 $tabs->child( modify => title => loc('Modify'), path => "/Articles/Article/Edit.html?id=".$id );
892 $tabs->child( delete => title => loc('Delete'), path => "/Articles/Article/Delete.html?id=".$id );
893 }
894 }
895
896 if ( $request_path =~ m{^/Articles/} ) {
c36a7e1d
MKG
897 PageWidgets()->child( article_search => raw_html => $m->scomp('/Articles/Elements/GotoArticle') );
898 PageWidgets()->delete('create_ticket');
899 PageWidgets()->delete('simple_search');
900
84fb5b46
MKG
901 my $tabs = PageMenu();
902 $tabs->child( search => title => loc("Search"), path => "/Articles/Article/Search.html" );
903 $tabs->child( create => title => loc("New Article" ), path => "/Articles/Article/PreCreate.html" );
b5747ff2 904 if ( $request_path =~ m{^/Articles/Article/} and ( $DECODED_ARGS->{'id'} || '' ) =~ /^(\d+)$/ ) {
84fb5b46
MKG
905 my $id = $1;
906 my $obj = RT::Article->new( $session{'CurrentUser'} );
907 $obj->Load($id);
908
403d7b0b
MKG
909 if ( $obj and $obj->id ) {
910 $tabs->child( display => title => loc("Display"), path => "/Articles/Article/Display.html?id=" . $id );
911 $tabs->child( history => title => loc('History'), path => '/Articles/Article/History.html?id=' . $id );
84fb5b46 912
403d7b0b
MKG
913 if ( $obj->CurrentUserHasRight('ModifyArticle') ) {
914 $tabs->child(modify => title => loc('Modify'), path => '/Articles/Article/Edit.html?id=' . $id );
915 }
916 if ( $obj->CurrentUserHasRight('DeleteArticle') ) {
917 $tabs->child(delete => title => loc('Delete'), path => '/Articles/Article/Delete.html?id=' . $id );
918 }
84fb5b46
MKG
919 }
920 }
921
922 }
923
af59614d
MKG
924 if ( $request_path =~ m{^/User/(Summary|History)\.html} ) {
925 if (PageMenu()->child('summary')) {
926 # Already set up from having AdminUser and ShowConfigTab;
927 # but rename "Basics" to "Edit" in this context
928 PageMenu()->child( 'basics' )->title( loc('Edit') );
929 } elsif ( $session{'CurrentUser'}->HasRight( Object => $RT::System, Right => 'ShowUserHistory' ) ) {
930 PageMenu()->child( display => title => loc('Summary'), path => '/User/Summary.html?id=' . $DECODED_ARGS->{'id'} );
931 PageMenu()->child( history => title => loc('History'), path => '/User/History.html?id=' . $DECODED_ARGS->{'id'} );
932 }
933 }
934
84fb5b46
MKG
935 if ( $request_path =~ /^\/(?:index.html|$)/ ) {
936 PageMenu()->child( edit => title => loc('Edit'), path => '/Prefs/MyRT.html' );
937 }
938
af59614d 939 $m->callback( CallbackName => 'Privileged', Path => $request_path );
84fb5b46
MKG
940};
941
942my $build_selfservice_nav = sub {
943 my $queues = RT::Queues->new( $session{'CurrentUser'} );
944 $queues->UnLimit;
945
946 my $queue_count = 0;
b5747ff2 947 my $queue_id;
84fb5b46
MKG
948
949 while ( my $queue = $queues->Next ) {
950 next unless $queue->CurrentUserHasRight('CreateTicket');
951 $queue_id = $queue->id;
952 $queue_count++;
953 last if ( $queue_count > 1 );
954 }
955
956
b5747ff2
MKG
957 if ( $queue_count > 1 ) {
958 Menu->child( new => title => loc('New ticket'), path => '/SelfService/CreateTicketInQueue.html' );
959 } elsif ( $queue_id ) {
960 Menu->child( new => title => loc('New ticket'), path => '/SelfService/Create.html?Queue=' . $queue_id );
961 }
dab09ea8 962 my $tickets = Menu->child( tickets => title => loc('Tickets'), path => '/SelfService/' );
84fb5b46
MKG
963 $tickets->child( open => title => loc('Open tickets'), path => '/SelfService/' );
964 $tickets->child( closed => title => loc('Closed tickets'), path => '/SelfService/Closed.html' );
84fb5b46
MKG
965
966
967 my $username = '<span class="current-user">'
968 . $m->interp->apply_escapes($session{'CurrentUser'}->Name, 'h')
969 . '</span>';
970 my $about_me = Menu->child( preferences =>
971 title => loc('Logged in as [_1]', $username),
972 escape_title => 0,
973 sort_order => 99,
974 );
975
976 if ( $session{'CurrentUser'}->HasRight( Right => 'ModifySelf', Object => RT->System ) ) {
977 $about_me->child( prefs => title => loc('Preferences'), path => '/SelfService/Prefs.html' );
978 }
979
980 if ( $session{'CurrentUser'}->Name
af59614d
MKG
981 && ( !RT->Config->Get('WebRemoteUserAuth')
982 || RT->Config->Get('WebFallbackToRTLogin') )) {
84fb5b46
MKG
983 $about_me->child( logout => title => loc('Logout'), path => '/NoAuth/Logout.html' );
984 }
985
986 if ($session{'CurrentUser'}->HasRight( Right => 'ShowArticle', Object => RT->System )) {
987 PageWidgets->child( 'goto-article' => raw_html => $m->scomp('/SelfService/Elements/SearchArticle') );
988 }
989
990 PageWidgets->child( goto => raw_html => $m->scomp('/SelfService/Elements/GotoTicket') );
991
af59614d 992 $m->callback( CallbackName => 'SelfService', Path => $request_path );
84fb5b46
MKG
993};
994
995
996
997if ( $request_path !~ m{^/SelfService/} ) {
998 $build_main_nav->();
999} else {
1000 $build_selfservice_nav->();
1001}
1002
1003
1004
1005
1006</%INIT>
1007<%ARGS>
1008$show_menu => 1
1009$QueryString => ''
1010$QueryArgs => {}
1011</%ARGS>