1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
6 %# <sales@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
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
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.
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.
30 %# CONTRIBUTION SUBMISSION POLICY:
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.)
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.
47 %# END BPS TAGGED BLOCK }}}
48 <& /Elements/PageLayout, show_menu => $show_menu &>
49 <a name="skipnav" id="skipnav" accesskey="8"></a>
52 #my $request_path = $HTML::Mason::Commands::r->path_info;
53 my $request_path = $m->request_comp->path;
54 $request_path =~ s!/{2,}!/!g;
56 my $query_string = sub {
59 $u->query_form(map { $_ => $args{$_} } sort keys %args);
63 my $build_admin_menu = sub {
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/',
72 $users->child( select => title => loc('Select'), path => "/Admin/Users/" );
73 $users->child( create => title => loc('Create'), path => "/Admin/Users/Modify.html?Create=1" );
75 my $groups = $admin->child( groups =>
76 title => loc('Groups'),
77 description => loc('Manage groups and group membership'),
78 path => '/Admin/Groups/',
80 $groups->child( select => title => loc('Select'), path => "/Admin/Groups/" );
81 $groups->child( create => title => loc('Create'), path => "/Admin/Groups/Modify.html?Create=1" );
83 my $queues = $admin->child( queues =>
84 title => loc('Queues'),
85 description => loc('Manage queues and queue-specific properties'),
86 path => '/Admin/Queues/',
88 $queues->child( select => title => loc('Select'), path => "/Admin/Queues/" );
89 $queues->child( create => title => loc('Create'), path => "/Admin/Queues/Modify.html?Create=1" );
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/',
97 $cfs->child( select => title => loc('Select'), path => "/Admin/CustomFields/" );
98 $cfs->child( create => title => loc('Create'), path => "/Admin/CustomFields/Modify.html?Create=1" );
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/',
107 $scrips->child( select => title => loc('Select'), path => "/Admin/Scrips/" );
108 $scrips->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html" );
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/',
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',
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" );
125 my $templates = $admin_global->child( templates =>
126 title => loc('Templates'),
127 description => loc('Edit system templates'),
128 path => '/Admin/Global/Templates.html',
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" );
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',
138 $cfadmin->child( users =>
139 title => loc('Users'),
140 description => loc('Select custom fields for all users'),
141 path => '/Admin/Global/CustomFields/Users.html',
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',
148 $cfadmin->child( queues =>
149 title => loc('Queues'),
150 description => loc('Select custom fields for all queues'),
151 path => '/Admin/Global/CustomFields/Queues.html',
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',
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',
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',
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/',
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',
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'),
187 $cfs->child( select =>
188 title => loc('Select'),
189 path => '/Admin/CustomFields/index.html?'.$m->comp('/Elements/QueryString', Type => 'RT::Class-RT::Article'),
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" ),
196 $admin_global->child( 'group-rights' =>
197 title => loc('Group Rights'),
198 description => loc('Modify global group rights'),
199 path => '/Admin/Global/GroupRights.html',
201 $admin_global->child( 'user-rights' =>
202 title => loc('User Rights'),
203 description => loc('Modify global user rights'),
204 path => '/Admin/Global/UserRights.html',
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',
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',
216 $admin_global->child( 'topics' =>
217 title => loc('Topics'),
218 description => loc('Modify global article topics'),
219 path => '/Admin/Global/Topics.html',
222 my $admin_tools = $admin->child( tools =>
223 title => loc('Tools'),
224 description => loc('Use other RT administrative tools'),
225 path => '/Admin/Tools/',
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',
232 $admin_tools->child( theme =>
233 title => loc('Theme'),
234 description => loc('Customize the look of your RT'),
235 path => '/Admin/Tools/Theme.html',
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',
245 $admin_tools->child( shredder =>
246 title => loc('Shredder'),
247 description => loc('Permanently wipeout data from RT'),
248 path => '/Admin/Tools/Shredder',
251 if ( $request_path =~ m{^/Admin/(Queues|Users|Groups|CustomFields)} ) {
253 my $tabs = PageMenu();
256 Queues => loc("Queues"),
257 Users => loc("Users"),
258 Groups => loc("Groups"),
259 CustomFields => loc("Custom Fields"),
263 if ( $request_path =~ m|^/Admin/$type/?(?:index.html)?$|
264 || ( $request_path =~ m|^/Admin/$type/(?:Modify.html)$|
265 && $DECODED_ARGS->{'Create'} )
271 $section = $tabs->child( select => title => $labels{$type},
272 path => "/Admin/$type/" );
275 $section->child( select => title => loc('Select'), path => "/Admin/$type/" );
276 $section->child( create => title => loc('Create'), path => "/Admin/$type/Modify.html?Create=1" );
279 if ( $request_path =~ m{^/Admin/Queues} ) {
280 if ( $DECODED_ARGS->{'id'} && $DECODED_ARGS->{'id'} =~ /^\d+$/
282 $DECODED_ARGS->{'Queue'} && $DECODED_ARGS->{'Queue'} =~ /^\d+$/
284 my $id = $DECODED_ARGS->{'Queue'} || $DECODED_ARGS->{'id'};
285 my $queue_obj = RT::Queue->new( $session{'CurrentUser'} );
286 $queue_obj->Load($id);
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 );
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);
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);
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 );
305 my $txn_cfs = $cfs->child( 'transactions' => title => loc('Transactions'),
306 path => '/Admin/Queues/CustomFields.html?SubType=RT::Ticket-RT::Transaction&id='.$id );
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 );
312 $m->callback( CallbackName => 'PrivilegedQueue', queue_id => $id, page_menu => $queue);
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'} );
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,
332 if ( RT->Config->Get('Crypt')->{'Enable'} ) {
333 $tabs->child( keys => title => loc('Private keys'), path => "/Admin/Users/Keys.html?id=" . $id );
335 $tabs->child( 'summary' => title => loc('User Summary'), path => "/User/Summary.html?id=" . $id );
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'} );
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 );
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'} );
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 );
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'} );
383 my $tabs = PageMenu();
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+)$/;
389 $admin_cat = "Queues/Scrips.html?id=$from_queue";
390 $create_path_arg = "?Queue=$from_queue";
391 $from_query_param = "&From=$from_queue";
393 elsif ( $from_arg eq 'Global' ) {
394 $admin_cat = 'Global/Scrips.html';
395 $create_path_arg = '?Global=1';
396 $from_query_param = '&From=Global';
399 $admin_cat = 'Scrips';
400 $from_query_param = $create_path_arg = q{};
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}" );
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 );
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" );
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'};
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" );
423 PageMenu->child( select => title => loc('Select') => path => "/Admin/Scrips" );
424 PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html" );
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" );
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" );
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'} );
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" );
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" );
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" );
466 my $build_main_nav = sub {
468 PageWidgets()->child( simple_search => raw_html => $m->scomp('SimpleSearch') );
469 PageWidgets()->child( create_ticket => raw_html => $m->scomp('CreateTicket') );
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(
478 unless ($dashboards_in_menu->{dashboards}) {
479 my ($default_dashboards) =
480 RT::System->new( $session{'CurrentUser'} )
482 ->Named('DashboardsInMenu');
483 if ($default_dashboards) {
484 $dashboards_in_menu = $default_dashboards->Content;
488 $session{'dashboards_in_menu'} = $dashboards_in_menu->{dashboards} || [];
492 for my $id ( @{$session{'dashboards_in_menu'}} ) {
493 my $dash = RT::Dashboard->new( $session{CurrentUser} );
494 my ( $status, $msg ) = $dash->LoadById($id);
496 push @dashboards, $dash;
498 $RT::Logger->warning( "Failed to load dashboard $id: $msg" );
502 my $dashes = Menu()->child('home');
504 for my $dash (@dashboards) {
505 $home->child( 'dashboard-' . $dash->id,
506 title => $dash->Name,
507 path => '/Dashboards/' . $dash->id . '/' . $dash->Name
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" );
518 my $search = Menu->child( search => title => loc('Search'), path => '/Search/Simple.html' );
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" );
524 $search->child( articles => title => loc('Articles'), path => "/Articles/Article/Search.html" )
525 if $session{CurrentUser}->HasRight( Right => 'ShowArticlesMenu', Object => RT->System );
527 $search->child( users => title => loc('Users'), path => "/User/Search.html" );
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" );
537 my $tools = Menu->child( tools => title => loc('Tools'), path => '/Tools/index.html' );
539 $tools->child( my_day =>
540 title => loc('My Day'),
541 description => loc('Easy updating of your open tickets'),
542 path => '/Tools/MyDay.html',
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',
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/',
561 if ( $session{'CurrentUser'}->HasRight( Right => 'ShowConfigTab', Object => RT->System ) )
563 $build_admin_menu->(Menu());
566 my $username = '<span class="current-user">'
567 . $m->interp->apply_escapes($session{'CurrentUser'}->Name, 'h')
569 my $about_me = Menu->child( 'preferences' =>
570 title => loc('Logged in as [_1]', $username),
572 path => '/User/Summary.html?id=' . $session{CurrentUser}->id,
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',
588 $settings->child( quicksearch => title => loc('Quick search'), path => '/Prefs/Quicksearch.html' );
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'} )) ];
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 ),
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' );
609 if ( $request_path =~ m{^/Dashboards/(\d+)?}) {
610 if ( my $id = ( $1 || $DECODED_ARGS->{'id'} ) ) {
611 my $obj = RT::Dashboard->new( $session{'CurrentUser'} );
613 if ( $obj and $obj->id ) {
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)
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");
630 if ( $request_path =~ m{^/Ticket/} ) {
631 if ( ( $DECODED_ARGS->{'id'} || '' ) =~ /^(\d+)$/ ) {
633 my $obj = RT::Ticket->new( $session{'CurrentUser'} );
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 );
643 my %can = %{ $obj->CurrentUser->PrincipalObj->HasRights( Object => $obj ) };
644 $can{'_ModifyOwner'} = $obj->CurrentUserCanSetOwner();
646 unless ($_[0] eq 'ExecuteCode') {
647 return $can{$_[0]} || $can{'SuperUser'};
649 return !RT->Config->Get('DisallowExecuteCode')
650 && ( $can{'ExecuteCode'} || $can{'SuperUser'} );
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 );
661 $tabs->child( customers => title => loc('Customers'), path => "/Ticket/ModifyCustomers.html?id=" . $id );
663 if ( $can->('ModifyTicket') || $can->('_ModifyOwner') || $can->('Watch') || $can->('WatchAsAdminCc') ) {
664 $tabs->child( people => title => loc('People'), path => "/Ticket/ModifyPeople.html?id=" . $id );
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 );
672 #if ( $can->('ModifyTicket') || $can->('ModifyCustomField') || $can->('_ModifyOwner') ) {
673 $tabs->child( jumbo => title => loc('Jumbo'), path => "/Ticket/ModifyAll.html?id=" . $id );
676 if ( RT->Config->Get('EnableReminders') ) {
677 $tabs->child( reminders => title => loc('Reminders'), path => "/Ticket/Reminders.html?id=" . $id );
680 if ( $can->('ModifyTicket') or $can->('ReplyToTicket') ) {
681 $actions->child( reply => title => loc('Reply'), path => "/Ticket/Update.html?Action=Respond;id=" . $id );
684 if ( $can->('ModifyTicket') or $can->('CommentOnTicket') ) {
685 $actions->child( comment => title => loc('Comment'), path => "/Ticket/Update.html?Action=Comment;id=" . $id );
688 if ( $can->('ForwardMessage') ) {
689 $actions->child( forward => title => loc('Forward'), path => "/Ticket/Forward.html?id=" . $id );
692 my $hide_resolve_with_deps = RT->Config->Get('HideResolveActionsWithDependencies')
693 && $obj->HasUnresolvedDependencies;
695 my $current = $obj->Status;
696 my $lifecycle = $obj->LifecycleObj;
698 foreach my $info ( $lifecycle->Actions($current) ) {
699 my $next = $info->{'to'};
700 next unless $lifecycle->IsTransition( $current => $next );
702 my $check = $lifecycle->CheckRight( $current => $next );
703 next unless $can->($check);
705 next if $hide_resolve_with_deps
706 && $lifecycle->IsInactive($next)
707 && !$lifecycle->IsInactive($current);
709 my $action = $info->{'update'} || '';
710 my $url = '/Ticket/';
711 $url .= "Update.html?". $query_string->(
713 ? (Action => $action)
714 : (SubmitTicket => 1, Status => $next),
715 DefaultStatus => $next,
718 my $key = $info->{'label'} || ucfirst($next);
719 $actions->child( $key => title => loc( $key ), path => $url);
722 my ($can_take, $tmsg) = $obj->CurrentUserCanSetOwner( Type => 'Take' );
723 my ($can_steal, $smsg) = $obj->CurrentUserCanSetOwner( Type => 'Steal' );
725 $actions->child( take => title => loc('Take'), path => "/Ticket/Display.html?Action=Take;id=" . $id );
727 elsif ( $can_steal ){
728 $actions->child( steal => title => loc('Steal'), path => "/Ticket/Display.html?Action=Steal;id=" . $id );
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 );
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'} );
741 my $item_map = $session{"tickets"}->ItemMap;
743 if ($updatesession) {
744 $session{"tickets"}->PrepForSerialization();
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});
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});
771 $request_path =~ m{^/(?:Ticket|Search)/}
772 && $request_path !~ m{^/Search/Simple\.html}
774 || ( $request_path =~ m{^/Search/Simple\.html}
775 && $DECODED_ARGS->{'q'} )
778 my $search = Menu()->child('search')->child('tickets');
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};
785 $has_query = 1 if ( $DECODED_ARGS->{'Query'} or $current_search->{'Query'} );
788 my %fallback_query_args = (
789 SavedSearchId => ( $search_id eq 'new' ) ? undef : $search_id,
790 SavedChartSearchId => $chart_id,
794 $p => $DECODED_ARGS->{$p} || $current_search->{$p}
795 } qw(Query Format OrderBy Order Page)
798 defined $DECODED_ARGS->{'RowsPerPage'}
799 ? $DECODED_ARGS->{'RowsPerPage'}
800 : $current_search->{'RowsPerPage'}
805 $args = '?' . $QueryString;
808 my %final_query_args = ();
809 # key => callback to avoid unnecessary work
811 for my $param (keys %fallback_query_args) {
812 $final_query_args{$param} = defined($QueryArgs->{$param})
813 ? $QueryArgs->{$param}
814 : $fallback_query_args{$param};
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};
824 $final_query_args{$field} ||= '';
828 $args = '?' . $query_string->(%final_query_args);
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;
836 $current_search_menu = PageMenu();
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" );
844 $current_search_menu->child( results => title => loc('Show Results'), path => "/Search/Results.html$args" );
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" );
851 #formerly Callbacks/RTx-Calendar/Ticket/Element/Tabs/Default
852 $current_search_menu->child( calendar => title => loc('Calendar'), path => "/Search/Calendar.html$args" );
854 my $more = $current_search_menu->child( more => title => loc('Feeds') );
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" );
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}
868 my $RSSPath = join '/', map $m->interp->apply_escapes( $_, 'u' ),
869 $session{'CurrentUser'}->UserObj->Name,
870 $session{'CurrentUser'}
871 ->UserObj->GenerateAuthString( $rss_data{Query}
873 . $rss_data{OrderBy} );
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} ),
880 $more->child( ical => title => loc('iCal'), path => '/NoAuth/iCal/'.$ical_path);
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->(
888 'Tickets:query' => $rss_data{'Query'},
889 'Tickets:limit' => $QueryArgs->{'Rows'},
892 $more->child( shredder => title => loc('Shredder'), path => '/Admin/Tools/Shredder/?' . $shred_args);
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();
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 );
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');
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+)$/ ) {
920 my $obj = RT::Article->new( $session{'CurrentUser'} );
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 );
927 if ( $obj->CurrentUserHasRight('ModifyArticle') ) {
928 $tabs->child(modify => title => loc('Modify'), path => '/Articles/Article/Edit.html?id=' . $id );
930 if ( $obj->CurrentUserHasRight('DeleteArticle') ) {
931 $tabs->child(delete => title => loc('Delete'), path => '/Articles/Article/Delete.html?id=' . $id );
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'} );
949 if ( $request_path =~ /^\/(?:index.html|$)/ ) {
950 PageMenu()->child( edit => title => loc('Edit'), path => '/Prefs/MyRT.html' );
953 $m->callback( CallbackName => 'Privileged', Path => $request_path );
956 my $build_selfservice_nav = sub {
957 my $queues = RT::Queues->new( $session{'CurrentUser'} );
963 while ( my $queue = $queues->Next ) {
964 next unless $queue->CurrentUserHasRight('CreateTicket');
965 $queue_id = $queue->id;
967 last if ( $queue_count > 1 );
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 );
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' );
981 my $username = '<span class="current-user">'
982 . $m->interp->apply_escapes($session{'CurrentUser'}->Name, 'h')
984 my $about_me = Menu->child( preferences =>
985 title => loc('Logged in as [_1]', $username),
990 if ( $session{'CurrentUser'}->HasRight( Right => 'ModifySelf', Object => RT->System ) ) {
991 $about_me->child( prefs => title => loc('Preferences'), path => '/SelfService/Prefs.html' );
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' );
1000 if ($session{'CurrentUser'}->HasRight( Right => 'ShowArticle', Object => RT->System )) {
1001 PageWidgets->child( 'goto-article' => raw_html => $m->scomp('/SelfService/Elements/SearchArticle') );
1004 PageWidgets->child( goto => raw_html => $m->scomp('/SelfService/Elements/GotoTicket') );
1006 $m->callback( CallbackName => 'SelfService', Path => $request_path );
1011 if ( $request_path !~ m{^/SelfService/} ) {
1012 $build_main_nav->();
1014 $build_selfservice_nav->();