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( 'tasks' => title => loc('Subtasks'), path => "Admin/Queues/Tasks.html?Queue=".$id );
310 $queue->child( 'group-rights' => title => loc('Group Rights'), path => "/Admin/Queues/GroupRights.html?id=".$id );
311 $queue->child( 'user-rights' => title => loc('User Rights'), path => "/Admin/Queues/UserRights.html?id=" . $id );
312 $queue->child( 'history' => title => loc('History'), path => "/Admin/Queues/History.html?id=" . $id );
314 $m->callback( CallbackName => 'PrivilegedQueue', queue_id => $id, page_menu => $queue);
318 if ( $request_path =~ m{^(/Admin/Users|/User/(Summary|History)\.html)} and $admin->child("users") ) {
319 if ( $DECODED_ARGS->{'id'} && $DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
320 my $id = $DECODED_ARGS->{'id'};
321 my $obj = RT::User->new( $session{'CurrentUser'} );
324 if ( $obj and $obj->id ) {
325 my $tabs = PageMenu();
326 $tabs->child( basics => title => loc('Basics'), path => "/Admin/Users/Modify.html?id=" . $id );
327 $tabs->child( memberships => title => loc('Memberships'), path => "/Admin/Users/Memberships.html?id=" . $id );
328 $tabs->child( history => title => loc('History'), path => "/Admin/Users/History.html?id=" . $id );
329 $tabs->child( 'my-rt' => title => loc('RT at a glance'), path => "/Admin/Users/MyRT.html?id=" . $id );
330 $tabs->child( 'dashboards-in-menu' =>
331 title => loc('Dashboards in menu'),
332 path => '/Admin/Users/DashboardsInMenu.html?id=' . $id,
334 if ( RT->Config->Get('Crypt')->{'Enable'} ) {
335 $tabs->child( keys => title => loc('Private keys'), path => "/Admin/Users/Keys.html?id=" . $id );
337 $tabs->child( 'summary' => title => loc('User Summary'), path => "/User/Summary.html?id=" . $id );
343 if ( $request_path =~ m{^/Admin/Groups} ) {
344 if ( $DECODED_ARGS->{'id'} && $DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
345 my $id = $DECODED_ARGS->{'id'};
346 my $obj = RT::Group->new( $session{'CurrentUser'} );
349 if ( $obj and $obj->id ) {
350 my $tabs = PageMenu();
351 $tabs->child( basics => title => loc('Basics'), path => "/Admin/Groups/Modify.html?id=" . $obj->id );
352 $tabs->child( members => title => loc('Members'), path => "/Admin/Groups/Members.html?id=" . $obj->id );
353 $tabs->child( memberships => title => loc('Memberships'), path => "/Admin/Groups/Memberships.html?id=" . $obj->id );
354 $tabs->child( 'group-rights' => title => loc('Group Rights'), path => "/Admin/Groups/GroupRights.html?id=" . $obj->id );
355 $tabs->child( 'user-rights' => title => loc('User Rights'), path => "/Admin/Groups/UserRights.html?id=" . $obj->id );
356 $tabs->child( history => title => loc('History'), path => "/Admin/Groups/History.html?id=" . $obj->id );
361 if ( $request_path =~ m{^/Admin/CustomFields/} ) {
362 if ( $DECODED_ARGS->{'id'} && $DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
363 my $id = $DECODED_ARGS->{'id'};
364 my $obj = RT::CustomField->new( $session{'CurrentUser'} );
367 if ( $obj and $obj->id ) {
368 my $tabs = PageMenu();
369 $tabs->child( basics => title => loc('Basics'), path => "/Admin/CustomFields/Modify.html?id=".$id );
370 $tabs->child( 'group-rights' => title => loc('Group Rights'), path => "/Admin/CustomFields/GroupRights.html?id=" . $id );
371 $tabs->child( 'user-rights' => title => loc('User Rights'), path => "/Admin/CustomFields/UserRights.html?id=" . $id );
372 unless ( $obj->IsOnlyGlobal ) {
373 $tabs->child( 'applies-to' => title => loc('Applies to'), path => "/Admin/CustomFields/Objects.html?id=" . $id );
379 if ( $request_path =~ m{^/Admin/Scrips/} ) {
380 if ( $m->request_args->{'id'} && $m->request_args->{'id'} =~ /^\d+$/ ) {
381 my $id = $m->request_args->{'id'};
382 my $obj = RT::Scrip->new( $session{'CurrentUser'} );
385 my $tabs = PageMenu();
387 my ( $admin_cat, $create_path_arg, $from_query_param );
388 my $from_arg = $DECODED_ARGS->{'From'} || q{};
389 my ($from_queue) = $from_arg =~ /^(\d+)$/;
391 $admin_cat = "Queues/Scrips.html?id=$from_queue";
392 $create_path_arg = "?Queue=$from_queue";
393 $from_query_param = "&From=$from_queue";
395 elsif ( $from_arg eq 'Global' ) {
396 $admin_cat = 'Global/Scrips.html';
397 $create_path_arg = '?Global=1';
398 $from_query_param = '&From=Global';
401 $admin_cat = 'Scrips';
402 $from_query_param = $create_path_arg = q{};
404 my $scrips = $tabs->child( scrips => title => loc('Scrips'), path => "/Admin/${admin_cat}" );
405 $scrips->child( select => title => loc('Select'), path => "/Admin/${admin_cat}" );
406 $scrips->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html${create_path_arg}" );
408 $tabs->child( basics => title => loc('Basics') => path => "/Admin/Scrips/Modify.html?id=" . $id . $from_query_param );
409 $tabs->child( 'applies-to' => title => loc('Applies to'), path => "/Admin/Scrips/Objects.html?id=" . $id . $from_query_param );
411 elsif ( $request_path =~ m{^/Admin/Scrips/(index\.html)?$} ) {
412 PageMenu->child( select => title => loc('Select') => path => "/Admin/Scrips/" );
413 PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html" );
415 elsif ( $request_path =~ m{^/Admin/Scrips/Create\.html$} ) {
416 my ($queue) = $DECODED_ARGS->{'Queue'} && $DECODED_ARGS->{'Queue'} =~ /^(\d+)$/;
417 my $global_arg = $DECODED_ARGS->{'Global'};
419 PageMenu->child( select => title => loc('Select') => path => "/Admin/Queues/Scrips.html?id=$queue" );
420 PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html?Queue=$queue" );
421 } elsif ($global_arg) {
422 PageMenu->child( select => title => loc('Select') => path => "/Admin/Global/Scrips.html" );
423 PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html?Global=1" );
425 PageMenu->child( select => title => loc('Select') => path => "/Admin/Scrips" );
426 PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html" );
431 if ( $request_path =~ m{^/Admin/Global/Scrips\.html} ) {
432 my $tabs = PageMenu();
433 $tabs->child( select => title => loc('Select'), path => "/Admin/Global/Scrips.html" );
434 $tabs->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html?Global=1" );
437 if ( $request_path =~ m{^/Admin/Global/Templates?\.html} ) {
438 my $tabs = PageMenu();
439 $tabs->child( select => title => loc('Select'), path => "/Admin/Global/Templates.html" );
440 $tabs->child( create => title => loc('Create'), path => "/Admin/Global/Template.html?Create=1" );
443 if ( $request_path =~ m{^/Admin/Articles/Classes/} ) {
444 my $tabs = PageMenu();
445 if ( my $id = $DECODED_ARGS->{'id'} ) {
446 my $obj = RT::Class->new( $session{'CurrentUser'} );
449 if ( $obj and $obj->id ) {
450 my $section = $tabs->child( select => title => loc("Classes"), path => "/Admin/Articles/Classes/" );
451 $section->child( select => title => loc('Select'), path => "/Admin/Articles/Classes/" );
452 $section->child( create => title => loc('Create'), path => "/Admin/Articles/Classes/Modify.html?Create=1" );
454 $tabs->child( basics => title => loc('Basics'), path => "/Admin/Articles/Classes/Modify.html?id=".$id );
455 $tabs->child( topics => title => loc('Topics'), path => "/Admin/Articles/Classes/Topics.html?id=".$id );
456 $tabs->child( 'custom-fields' => title => loc('Custom Fields'), path => "/Admin/Articles/Classes/CustomFields.html?id=".$id );
457 $tabs->child( 'group-rights' => title => loc('Group Rights'), path => "/Admin/Articles/Classes/GroupRights.html?id=".$id );
458 $tabs->child( 'user-rights' => title => loc('User Rights'), path => "/Admin/Articles/Classes/UserRights.html?id=".$id );
459 $tabs->child( 'applies-to' => title => loc('Applies to'), path => "/Admin/Articles/Classes/Objects.html?id=$id" );
462 $tabs->child( select => title => loc('Select'), path => "/Admin/Articles/Classes/" );
463 $tabs->child( create => title => loc('Create'), path => "/Admin/Articles/Classes/Modify.html?Create=1" );
468 my $build_main_nav = sub {
470 PageWidgets()->child( simple_search => raw_html => $m->scomp('SimpleSearch') );
471 PageWidgets()->child( create_ticket => raw_html => $m->scomp('CreateTicket') );
473 my $home = Menu->child( home => title => loc('Homepage'), path => '/' );
474 unless ($session{'dashboards_in_menu'}) {
475 my $dashboards_in_menu = $session{CurrentUser}->UserObj->Preferences(
480 unless ($dashboards_in_menu->{dashboards}) {
481 my ($default_dashboards) =
482 RT::System->new( $session{'CurrentUser'} )
484 ->Named('DashboardsInMenu');
485 if ($default_dashboards) {
486 $dashboards_in_menu = $default_dashboards->Content;
490 $session{'dashboards_in_menu'} = $dashboards_in_menu->{dashboards} || [];
494 for my $id ( @{$session{'dashboards_in_menu'}} ) {
495 my $dash = RT::Dashboard->new( $session{CurrentUser} );
496 my ( $status, $msg ) = $dash->LoadById($id);
498 push @dashboards, $dash;
500 $RT::Logger->warning( "Failed to load dashboard $id: $msg" );
504 my $dashes = Menu()->child('home');
506 for my $dash (@dashboards) {
507 $home->child( 'dashboard-' . $dash->id,
508 title => $dash->Name,
509 path => '/Dashboards/' . $dash->id . '/' . $dash->Name
513 $dashes->child( edit => title => loc('Update This Menu'), path => 'Prefs/DashboardsInMenu.html' );
514 $dashes->child( more => title => loc('All Dashboards'), path => 'Dashboards/index.html' );
515 my $dashboard = RT::Dashboard->new( $session{CurrentUser} );
516 if ( $dashboard->CurrentUserCanCreateAny ) {
517 $dashes->child('dashboard_create' => title => loc('New Dashboard'), path => "/Dashboards/Modify.html?Create=1" );
520 my $search = Menu->child( search => title => loc('Search'), path => '/Search/Simple.html' );
522 my $tickets = $search->child( tickets => title => loc('Tickets'), path => '/Search/Build.html' );
523 $tickets->child( simple => title => loc('Simple Search'), path => "/Search/Simple.html" );
524 $tickets->child( new => title => loc('New Search'), path => "/Search/Build.html?NewQuery=1" );
526 $search->child( articles => title => loc('Articles'), path => "/Articles/Article/Search.html" )
527 if $session{CurrentUser}->HasRight( Right => 'ShowArticlesMenu', Object => RT->System );
529 $search->child( users => title => loc('Users'), path => "/User/Search.html" );
531 if ($session{CurrentUser}->HasRight( Right => 'ShowArticlesMenu', Object => RT->System )) {
532 my $articles = Menu->child( articles => title => loc('Articles'), path => "/Articles/index.html");
533 $articles->child( articles => title => loc('Overview'), path => "/Articles/index.html" );
534 $articles->child( topics => title => loc('Topics'), path => "/Articles/Topics.html" );
535 $articles->child( create => title => loc('Create'), path => "/Articles/Article/PreCreate.html" );
536 $articles->child( search => title => loc('Search'), path => "/Articles/Article/Search.html" );
539 my $tools = Menu->child( tools => title => loc('Tools'), path => '/Tools/index.html' );
541 $tools->child( my_day =>
542 title => loc('My Day'),
543 description => loc('Easy updating of your open tickets'),
544 path => '/Tools/MyDay.html',
547 if ( RT->Config->Get('EnableReminders') ) {
548 $tools->child( my_reminders =>
549 title => loc('My Reminders'),
550 description => loc('Easy viewing of your reminders'),
551 path => '/Tools/MyReminders.html',
555 if ( $session{'CurrentUser'}->HasRight( Right => 'ShowApprovalsTab', Object => RT->System ) ) {
556 $tools->child( approval =>
557 title => loc('Approval'),
558 description => loc('My Approvals'),
559 path => '/Approvals/',
563 if ( $session{'CurrentUser'}->HasRight( Right => 'ShowConfigTab', Object => RT->System ) )
565 $build_admin_menu->(Menu());
568 my $username = '<span class="current-user">'
569 . $m->interp->apply_escapes($session{'CurrentUser'}->Name, 'h')
571 my $about_me = Menu->child( 'preferences' =>
572 title => loc('Logged in as [_1]', $username),
574 path => '/User/Summary.html?id=' . $session{CurrentUser}->id,
579 if ( $session{'CurrentUser'}->UserObj
580 && $session{'CurrentUser'}->HasRight( Right => 'ModifySelf', Object => RT->System )) {
581 my $settings = $about_me->child( settings => title => loc('Settings'), path => '/Prefs/Other.html' );
582 $settings->child( options => title => loc('Preferences'), path => '/Prefs/Other.html' );
583 $settings->child( about_me => title => loc('About me'), path => '/User/Prefs.html' );
584 $settings->child( search_options => title => loc('Search options'), path => '/Prefs/SearchOptions.html' );
585 $settings->child( myrt => title => loc('RT at a glance'), path => '/Prefs/MyRT.html' );
586 $settings->child( dashboards_in_menu =>
587 title => loc('Dashboards in menu'),
588 path => '/Prefs/DashboardsInMenu.html',
590 $settings->child( quicksearch => title => loc('Quick search'), path => '/Prefs/Quicksearch.html' );
592 my $search_menu = $settings->child( 'saved-searches' => title => loc('Saved Searches') );
593 my $searches = [ $m->comp( "/Search/Elements/SearchesForObject",
594 Object => RT::System->new( $session{'CurrentUser'} )) ];
597 for my $search (@$searches) {
598 $search_menu->child( "search-" . $i++ =>
599 title => $search->[1],
600 path => "/Prefs/Search.html?"
601 . $query_string->( name => ref( $search->[2] ) . '-' . $search->[2]->Id ),
606 if ( $session{'CurrentUser'}->Name
607 && ( !RT->Config->Get('WebRemoteUserAuth')
608 || RT->Config->Get('WebFallbackToRTLogin') )) {
609 $about_me->child( logout => title => loc('Logout'), path => '/NoAuth/Logout.html' );
611 if ( $request_path =~ m{^/Dashboards/(\d+)?}) {
612 if ( my $id = ( $1 || $DECODED_ARGS->{'id'} ) ) {
613 my $obj = RT::Dashboard->new( $session{'CurrentUser'} );
615 if ( $obj and $obj->id ) {
617 $tabs->child( basics => title => loc('Basics'), path => "/Dashboards/Modify.html?id=" . $obj->id);
618 $tabs->child( content => title => loc('Content'), path => "/Dashboards/Queries.html?id=" . $obj->id);
619 $tabs->child( subscription => title => loc('Subscription'), path => "/Dashboards/Subscription.html?id=" . $obj->id)
620 if $obj->CurrentUserCanSubscribe;
621 $tabs->child( show => title => loc('Show'), path => "/Dashboards/" . $obj->id . "/" . $obj->Name)
624 my $tabs = PageMenu();
625 if ( $dashboard->CurrentUserCanCreateAny ) {
626 # FREESIDE: provide a way to create dashboards
627 $tabs->child('dashboard_create' => title => loc('New Dashboard'), path => "/Dashboards/Modify.html?Create=1");
632 if ( $request_path =~ m{^/Ticket/} ) {
633 if ( ( $DECODED_ARGS->{'id'} || '' ) =~ /^(\d+)$/ ) {
635 my $obj = RT::Ticket->new( $session{'CurrentUser'} );
638 if ( $obj and $obj->id ) {
639 my $actions = PageMenu()->child( actions => title => loc('Actions'), sort_order => 95 );
640 my $tabs = PageMenu();
641 $tabs->child( bookmark => raw_html => $m->scomp( '/Ticket/Elements/Bookmark', id => $id ), sort_order => 99 );
642 $tabs->child( display => title => loc('Display'), path => "/Ticket/Display.html?id=" . $id );
643 $tabs->child( history => title => loc('History'), path => "/Ticket/History.html?id=" . $id );
645 my %can = %{ $obj->CurrentUser->PrincipalObj->HasRights( Object => $obj ) };
646 $can{'_ModifyOwner'} = $obj->CurrentUserCanSetOwner();
648 unless ($_[0] eq 'ExecuteCode') {
649 return $can{$_[0]} || $can{'SuperUser'};
651 return !RT->Config->Get('DisallowExecuteCode')
652 && ( $can{'ExecuteCode'} || $can{'SuperUser'} );
656 # comment out until we can do it for an individual custom field
657 #if ( $can->('ModifyTicket') || $can->('ModifyCustomField') ) {
658 $tabs->child( basics => title => loc('Basics'), path => "/Ticket/Modify.html?id=" . $id );
663 $tabs->child( customers => title => loc('Customers'), path => "/Ticket/ModifyCustomers.html?id=" . $id );
665 if ( $can->('ModifyTicket') || $can->('_ModifyOwner') || $can->('Watch') || $can->('WatchAsAdminCc') ) {
666 $tabs->child( people => title => loc('People'), path => "/Ticket/ModifyPeople.html?id=" . $id );
669 if ( $can->('ModifyTicket') ) {
670 $tabs->child( dates => title => loc('Dates'), path => "/Ticket/ModifyDates.html?id=" . $id );
671 $tabs->child( links => title => loc('Links'), path => "/Ticket/ModifyLinks.html?id=" . $id );
674 #if ( $can->('ModifyTicket') || $can->('ModifyCustomField') || $can->('_ModifyOwner') ) {
675 $tabs->child( jumbo => title => loc('Jumbo'), path => "/Ticket/ModifyAll.html?id=" . $id );
678 if ( RT->Config->Get('EnableReminders') ) {
679 $tabs->child( reminders => title => loc('Reminders'), path => "/Ticket/Reminders.html?id=" . $id );
682 if ( $can->('ModifyTicket') or $can->('ReplyToTicket') ) {
683 $actions->child( reply => title => loc('Reply'), path => "/Ticket/Update.html?Action=Respond;id=" . $id );
686 if ( $can->('ModifyTicket') or $can->('CommentOnTicket') ) {
687 $actions->child( comment => title => loc('Comment'), path => "/Ticket/Update.html?Action=Comment;id=" . $id );
690 if ( $can->('ForwardMessage') ) {
691 $actions->child( forward => title => loc('Forward'), path => "/Ticket/Forward.html?id=" . $id );
694 my $hide_resolve_with_deps = RT->Config->Get('HideResolveActionsWithDependencies')
695 && $obj->HasUnresolvedDependencies;
697 my $current = $obj->Status;
698 my $lifecycle = $obj->LifecycleObj;
700 foreach my $info ( $lifecycle->Actions($current) ) {
701 my $next = $info->{'to'};
702 next unless $lifecycle->IsTransition( $current => $next );
704 my $check = $lifecycle->CheckRight( $current => $next );
705 next unless $can->($check);
707 next if $hide_resolve_with_deps
708 && $lifecycle->IsInactive($next)
709 && !$lifecycle->IsInactive($current);
711 my $action = $info->{'update'} || '';
712 my $url = '/Ticket/';
713 $url .= "Update.html?". $query_string->(
715 ? (Action => $action)
716 : (SubmitTicket => 1, Status => $next),
717 DefaultStatus => $next,
720 my $key = $info->{'label'} || ucfirst($next);
721 $actions->child( $key => title => loc( $key ), path => $url);
724 my ($can_take, $tmsg) = $obj->CurrentUserCanSetOwner( Type => 'Take' );
725 my ($can_steal, $smsg) = $obj->CurrentUserCanSetOwner( Type => 'Steal' );
727 $actions->child( take => title => loc('Take'), path => "/Ticket/Display.html?Action=Take;id=" . $id );
729 elsif ( $can_steal ){
730 $actions->child( steal => title => loc('Steal'), path => "/Ticket/Display.html?Action=Steal;id=" . $id );
733 # TODO needs a "Can extract article into a class applied to this queue" check
734 $actions->child( 'extract-article' =>
735 title => loc('Extract Article'),
736 path => "/Articles/Article/ExtractIntoClass.html?Ticket=".$obj->id,
737 ) if $session{CurrentUser}->HasRight( Right => 'ShowArticlesMenu', Object => RT->System );
739 if ( defined $session{"tickets"} ) {
740 # we have to update session data if we get new ItemMap
741 my $updatesession = 1 unless ( $session{"tickets"}->{'item_map'} );
743 my $item_map = $session{"tickets"}->ItemMap;
745 if ($updatesession) {
746 $session{"tickets"}->PrepForSerialization();
749 my $search = Menu()->child('search')->child('tickets');
750 # Don't display prev links if we're on the first ticket
751 if ( $item_map->{$id}->{prev} ) {
752 $search->child( first =>
753 title => '<< ' . loc('First'), class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{first});
754 $search->child( prev =>
755 title => '< ' . loc('Prev'), class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{$id}->{prev});
757 # Don't display next links if we're on the last ticket
758 if ( $item_map->{$id}->{next} ) {
759 $search->child( next =>
760 title => loc('Next') . ' >', class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{$id}->{next});
761 if ( $item_map->{last} ) {
762 $search->child( last =>
763 title => loc('Last') . ' >>', class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{last});
773 $request_path =~ m{^/(?:Ticket|Search)/}
774 && $request_path !~ m{^/Search/Simple\.html}
776 || ( $request_path =~ m{^/Search/Simple\.html}
777 && $DECODED_ARGS->{'q'} )
780 my $search = Menu()->child('search')->child('tickets');
783 my $current_search = $session{"CurrentSearchHash"} || {};
784 my $search_id = $DECODED_ARGS->{'SavedSearchLoad'} || $DECODED_ARGS->{'SavedSearchId'} || $current_search->{'SearchId'} || '';
785 my $chart_id = $DECODED_ARGS->{'SavedChartSearchId'} || $current_search->{SavedChartSearchId};
787 $has_query = 1 if ( $DECODED_ARGS->{'Query'} or $current_search->{'Query'} );
790 my %fallback_query_args = (
791 SavedSearchId => ( $search_id eq 'new' ) ? undef : $search_id,
792 SavedChartSearchId => $chart_id,
796 $p => $DECODED_ARGS->{$p} || $current_search->{$p}
797 } qw(Query Format OrderBy Order Page)
800 defined $DECODED_ARGS->{'RowsPerPage'}
801 ? $DECODED_ARGS->{'RowsPerPage'}
802 : $current_search->{'RowsPerPage'}
807 $args = '?' . $QueryString;
810 my %final_query_args = ();
811 # key => callback to avoid unnecessary work
813 for my $param (keys %fallback_query_args) {
814 $final_query_args{$param} = defined($QueryArgs->{$param})
815 ? $QueryArgs->{$param}
816 : $fallback_query_args{$param};
819 for my $field (qw(Order OrderBy)) {
820 if ( ref( $final_query_args{$field} ) eq 'ARRAY' ) {
821 $final_query_args{$field} = join( "|", @{ $final_query_args{$field} } );
822 } elsif (not defined $final_query_args{$field}) {
823 delete $final_query_args{$field};
826 $final_query_args{$field} ||= '';
830 $args = '?' . $query_string->(%final_query_args);
833 my $current_search_menu;
834 if ( $request_path =~ m{^/Ticket} ) {
835 $current_search_menu = $search->child( current_search => title => loc('Current Search') );
836 $current_search_menu->path("/Search/Results.html$args") if $has_query;
838 $current_search_menu = PageMenu();
841 $current_search_menu->child( edit_search =>
842 title => loc('Edit Search'), path => "/Search/Build.html" . ( ($has_query) ? $args : '' ) );
843 $current_search_menu->child( advanced =>
844 title => loc('Advanced'), path => "/Search/Edit.html$args" );
846 $current_search_menu->child( results => title => loc('Show Results'), path => "/Search/Results.html$args" );
850 $current_search_menu->child( bulk => title => loc('Bulk Update'), path => "/Search/Bulk.html$args" );
851 $current_search_menu->child( chart => title => loc('Chart'), path => "/Search/Chart.html$args" );
853 #formerly Callbacks/RTx-Calendar/Ticket/Element/Tabs/Default
854 $current_search_menu->child( calendar => title => loc('Calendar'), path => "/Search/Calendar.html$args" );
856 my $more = $current_search_menu->child( more => title => loc('Feeds') );
858 $more->child( tsv => title => loc('TSV'), path => "/Search/Results.tsv$args" );
859 $more->child( csv => title => loc('CSV'), path => "/Search/Results.csv$args" );
860 $more->child( spreadsheet => title => loc('Spreadsheet'), path => "/Search/Results.xls$args" );
863 $_ => $QueryArgs->{$_} || $fallback_query_args{$_} || '' }
864 qw(Query Order OrderBy);
865 my $RSSQueryString = "?"
866 . $query_string->( Query => $rss_data{Query},
867 Order => $rss_data{Order},
868 OrderBy => $rss_data{OrderBy}
870 my $RSSPath = join '/', map $m->interp->apply_escapes( $_, 'u' ),
871 $session{'CurrentUser'}->UserObj->Name,
872 $session{'CurrentUser'}
873 ->UserObj->GenerateAuthString( $rss_data{Query}
875 . $rss_data{OrderBy} );
877 $more->child( rss => title => loc('RSS'), path => "/NoAuth/rss/$RSSPath/$RSSQueryString");
878 my $ical_path = join '/', map $m->interp->apply_escapes($_, 'u'),
879 $session{'CurrentUser'}->UserObj->Name,
880 $session{'CurrentUser'}->UserObj->GenerateAuthString( $rss_data{Query} ),
882 $more->child( ical => title => loc('iCal'), path => '/NoAuth/iCal/'.$ical_path);
884 if ($request_path =~ m{^/Search/Results.html}
885 && #XXX TODO better abstraction
886 $session{'CurrentUser'}->HasRight( Right => 'SuperUser', Object => RT->System )) {
887 my $shred_args = $query_string->(
890 'Tickets:query' => $rss_data{'Query'},
891 'Tickets:limit' => $QueryArgs->{'Rows'},
894 $more->child( shredder => title => loc('Shredder'), path => '/Admin/Tools/Shredder/?' . $shred_args);
900 if ( $request_path =~ m{^/Article/} ) {
901 if ( $DECODED_ARGS->{'id'} && $DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
902 my $id = $DECODED_ARGS->{'id'};
903 my $tabs = PageMenu();
905 $tabs->child( display => title => loc('Display'), path => "/Articles/Article/Display.html?id=".$id );
906 $tabs->child( history => title => loc('History'), path => "/Articles/Article/History.html?id=".$id );
907 $tabs->child( modify => title => loc('Modify'), path => "/Articles/Article/Edit.html?id=".$id );
908 $tabs->child( delete => title => loc('Delete'), path => "/Articles/Article/Delete.html?id=".$id );
912 if ( $request_path =~ m{^/Articles/} ) {
913 PageWidgets()->child( article_search => raw_html => $m->scomp('/Articles/Elements/GotoArticle') );
914 PageWidgets()->delete('create_ticket');
915 PageWidgets()->delete('simple_search');
917 my $tabs = PageMenu();
918 $tabs->child( search => title => loc("Search"), path => "/Articles/Article/Search.html" );
919 $tabs->child( create => title => loc("New Article" ), path => "/Articles/Article/PreCreate.html" );
920 if ( $request_path =~ m{^/Articles/Article/} and ( $DECODED_ARGS->{'id'} || '' ) =~ /^(\d+)$/ ) {
922 my $obj = RT::Article->new( $session{'CurrentUser'} );
925 if ( $obj and $obj->id ) {
926 $tabs->child( display => title => loc("Display"), path => "/Articles/Article/Display.html?id=" . $id );
927 $tabs->child( history => title => loc('History'), path => '/Articles/Article/History.html?id=' . $id );
929 if ( $obj->CurrentUserHasRight('ModifyArticle') ) {
930 $tabs->child(modify => title => loc('Modify'), path => '/Articles/Article/Edit.html?id=' . $id );
932 if ( $obj->CurrentUserHasRight('DeleteArticle') ) {
933 $tabs->child(delete => title => loc('Delete'), path => '/Articles/Article/Delete.html?id=' . $id );
940 if ( $request_path =~ m{^/User/(Summary|History)\.html} ) {
941 if (PageMenu()->child('summary')) {
942 # Already set up from having AdminUser and ShowConfigTab;
943 # but rename "Basics" to "Edit" in this context
944 PageMenu()->child( 'basics' )->title( loc('Edit') );
945 } elsif ( $session{'CurrentUser'}->HasRight( Object => $RT::System, Right => 'ShowUserHistory' ) ) {
946 PageMenu()->child( display => title => loc('Summary'), path => '/User/Summary.html?id=' . $DECODED_ARGS->{'id'} );
947 PageMenu()->child( history => title => loc('History'), path => '/User/History.html?id=' . $DECODED_ARGS->{'id'} );
951 if ( $request_path =~ /^\/(?:index.html|$)/ ) {
952 PageMenu()->child( edit => title => loc('Edit'), path => '/Prefs/MyRT.html' );
955 $m->callback( CallbackName => 'Privileged', Path => $request_path );
958 my $build_selfservice_nav = sub {
959 my $queues = RT::Queues->new( $session{'CurrentUser'} );
965 while ( my $queue = $queues->Next ) {
966 next unless $queue->CurrentUserHasRight('CreateTicket');
967 $queue_id = $queue->id;
969 last if ( $queue_count > 1 );
973 if ( $queue_count > 1 ) {
974 Menu->child( new => title => loc('New ticket'), path => '/SelfService/CreateTicketInQueue.html' );
975 } elsif ( $queue_id ) {
976 Menu->child( new => title => loc('New ticket'), path => '/SelfService/Create.html?Queue=' . $queue_id );
978 my $tickets = Menu->child( tickets => title => loc('Tickets'), path => '/SelfService/' );
979 $tickets->child( open => title => loc('Open tickets'), path => '/SelfService/' );
980 $tickets->child( closed => title => loc('Closed tickets'), path => '/SelfService/Closed.html' );
983 my $username = '<span class="current-user">'
984 . $m->interp->apply_escapes($session{'CurrentUser'}->Name, 'h')
986 my $about_me = Menu->child( preferences =>
987 title => loc('Logged in as [_1]', $username),
992 if ( $session{'CurrentUser'}->HasRight( Right => 'ModifySelf', Object => RT->System ) ) {
993 $about_me->child( prefs => title => loc('Preferences'), path => '/SelfService/Prefs.html' );
996 if ( $session{'CurrentUser'}->Name
997 && ( !RT->Config->Get('WebRemoteUserAuth')
998 || RT->Config->Get('WebFallbackToRTLogin') )) {
999 $about_me->child( logout => title => loc('Logout'), path => '/NoAuth/Logout.html' );
1002 if ($session{'CurrentUser'}->HasRight( Right => 'ShowArticle', Object => RT->System )) {
1003 PageWidgets->child( 'goto-article' => raw_html => $m->scomp('/SelfService/Elements/SearchArticle') );
1006 PageWidgets->child( goto => raw_html => $m->scomp('/SelfService/Elements/GotoTicket') );
1008 $m->callback( CallbackName => 'SelfService', Path => $request_path );
1013 if ( $request_path !~ m{^/SelfService/} ) {
1014 $build_main_nav->();
1016 $build_selfservice_nav->();