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