1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2014 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 $request_path =~ s!/{2,}!/!g;
55 my $query_string = sub {
58 $u->query_form(map { $_ => $args{$_} } sort keys %args);
62 my $build_admin_menu = sub {
64 my $admin = $top->child( admin => title => loc('Admin'), path => '/Admin/' );
65 if ( $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'AdminUsers' ) ) {
66 my $users = $admin->child( users =>
67 title => loc('Users'),
68 description => loc('Manage users and passwords'),
69 path => '/Admin/Users/',
71 $users->child( select => title => loc('Select'), path => "/Admin/Users/" );
72 $users->child( create => title => loc('Create'), path => "/Admin/Users/Modify.html?Create=1" );
74 my $groups = $admin->child( groups =>
75 title => loc('Groups'),
76 description => loc('Manage groups and group membership'),
77 path => '/Admin/Groups/',
79 $groups->child( select => title => loc('Select'), path => "/Admin/Groups/" );
80 $groups->child( create => title => loc('Create'), path => "/Admin/Groups/Modify.html?Create=1" );
82 my $queues = $admin->child( queues =>
83 title => loc('Queues'),
84 description => loc('Manage queues and queue-specific properties'),
85 path => '/Admin/Queues/',
87 $queues->child( select => title => loc('Select'), path => "/Admin/Queues/" );
88 $queues->child( create => title => loc('Create'), path => "/Admin/Queues/Modify.html?Create=1" );
90 if ( $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'AdminCustomField' ) ) {
91 my $cfs = $admin->child( 'custom-fields' =>
92 title => loc('Custom Fields'),
93 description => loc('Manage custom fields and custom field values'),
94 path => '/Admin/CustomFields/',
96 $cfs->child( select => title => loc('Select'), path => "/Admin/CustomFields/" );
97 $cfs->child( create => title => loc('Create'), path => "/Admin/CustomFields/Modify.html?Create=1" );
100 if ( $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'ModifyScrips' ) ) {
101 my $scrips = $admin->child( 'scrips' =>
102 title => loc('Scrips'),
103 description => loc('Manage scrips'),
104 path => '/Admin/Scrips/',
106 $scrips->child( select => title => loc('Select'), path => "/Admin/Scrips/" );
107 $scrips->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html" );
110 my $admin_global = $admin->child( global =>
111 title => loc('Global'),
112 description => loc('Manage properties and configuration which apply to all queues'),
113 path => '/Admin/Global/',
116 my $scrips = $admin_global->child( scrips =>
117 title => loc('Scrips'),
118 description => loc('Modify scrips which apply to all queues'),
119 path => '/Admin/Global/Scrips.html',
121 $scrips->child( select => title => loc('Select'), path => "/Admin/Global/Scrips.html" );
122 $scrips->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html?Global=1" );
124 my $templates = $admin_global->child( templates =>
125 title => loc('Templates'),
126 description => loc('Edit system templates'),
127 path => '/Admin/Global/Templates.html',
129 $templates->child( select => title => loc('Select'), path => "/Admin/Global/Templates.html" );
130 $templates->child( create => title => loc('Create'), path => "/Admin/Global/Template.html?Create=1" );
132 my $cfadmin = $admin_global->child( 'custom-fields' =>
133 title => loc('Custom Fields'),
134 description => loc('Modify global custom fields'),
135 path => '/Admin/Global/CustomFields/index.html',
137 $cfadmin->child( users =>
138 title => loc('Users'),
139 description => loc('Select custom fields for all users'),
140 path => '/Admin/Global/CustomFields/Users.html',
142 $cfadmin->child( groups =>
143 title => loc('Groups'),
144 description => loc('Select custom fields for all user groups'),
145 path => '/Admin/Global/CustomFields/Groups.html',
147 $cfadmin->child( queues =>
148 title => loc('Queues'),
149 description => loc('Select custom fields for all queues'),
150 path => '/Admin/Global/CustomFields/Queues.html',
152 $cfadmin->child( tickets =>
153 title => loc('Tickets'),
154 description => loc('Select custom fields for tickets in all queues'),
155 path => '/Admin/Global/CustomFields/Queue-Tickets.html',
157 $cfadmin->child( transactions =>
158 title => loc('Ticket Transactions'),
159 description => loc('Select custom fields for transactions on tickets in all queues'),
160 path => '/Admin/Global/CustomFields/Queue-Transactions.html',
162 $cfadmin->child( 'custom-fields' =>
163 title => loc('Articles'),
164 description => loc('Select Custom Fields for Articles in all Classes'),
165 path => '/Admin/Global/CustomFields/Class-Article.html',
168 my $article_admin = $admin->child( articles => title => loc('Articles'), path => "/Admin/Articles/index.html" );
169 my $class_admin = $article_admin->child(classes => title => loc('Classes'), path => '/Admin/Articles/Classes/' );
170 $class_admin->child( select =>
171 title => loc('Select'),
172 description => loc('Modify and Create Classes'),
173 path => '/Admin/Articles/Classes/',
175 $class_admin->child( create =>
176 title => loc('Create'),
177 description => loc('Modify and Create Custom Fields for Articles'),
178 path => '/Admin/Articles/Classes/Modify.html?Create=1',
182 my $cfs = $article_admin->child( 'custom-fields' =>
183 title => loc('Custom Fields'),
184 path => '/Admin/CustomFields/index.html?'.$m->comp('/Elements/QueryString', Type => 'RT::Class-RT::Article'),
186 $cfs->child( select =>
187 title => loc('Select'),
188 path => '/Admin/CustomFields/index.html?'.$m->comp('/Elements/QueryString', Type => 'RT::Class-RT::Article'),
190 $cfs->child( create =>
191 title => loc('Create'),
192 path => '/Admin/CustomFields/Modify.html?'.$m->comp("/Elements/QueryString", Create=>1, LookupType=> "RT::Class-RT::Article" ),
195 $admin_global->child( 'group-rights' =>
196 title => loc('Group Rights'),
197 description => loc('Modify global group rights'),
198 path => '/Admin/Global/GroupRights.html',
200 $admin_global->child( 'user-rights' =>
201 title => loc('User Rights'),
202 description => loc('Modify global user rights'),
203 path => '/Admin/Global/UserRights.html',
205 $admin_global->child( 'my-rt' =>
206 title => loc('RT at a glance'),
207 description => loc('Modify the default "RT at a glance" view'),
208 path => '/Admin/Global/MyRT.html',
210 $admin_global->child( 'dashboards-in-menu' =>
211 title => loc('Dashboards in menu'),
212 description => loc('Customize dashboards in menu'),
213 path => '/Admin/Global/DashboardsInMenu.html',
215 $admin_global->child( 'topics' =>
216 title => loc('Topics'),
217 description => loc('Modify global article topics'),
218 path => '/Admin/Global/Topics.html',
221 my $admin_tools = $admin->child( tools =>
222 title => loc('Tools'),
223 description => loc('Use other RT administrative tools'),
224 path => '/Admin/Tools/',
226 $admin_tools->child( configuration =>
227 title => loc('System Configuration'),
228 description => loc('Detailed information about your RT setup'),
229 path => '/Admin/Tools/Configuration.html',
231 $admin_tools->child( theme =>
232 title => loc('Theme'),
233 description => loc('Customize the look of your RT'),
234 path => '/Admin/Tools/Theme.html',
236 if (RT->Config->Get('StatementLog')
237 && $session{'CurrentUser'}->HasRight( Right => 'SuperUser', Object => RT->System )) {
238 $admin_tools->child( 'sql-queries' =>
239 title => loc('SQL Queries'),
240 description => loc('Browse the SQL queries made in this process'),
241 path => '/Admin/Tools/Queries.html',
244 $admin_tools->child( shredder =>
245 title => loc('Shredder'),
246 description => loc('Permanently wipeout data from RT'),
247 path => '/Admin/Tools/Shredder',
250 if ( $request_path =~ m{^/Admin/(Queues|Users|Groups|CustomFields)} ) {
252 my $tabs = PageMenu();
255 Queues => loc("Queues"),
256 Users => loc("Users"),
257 Groups => loc("Groups"),
258 CustomFields => loc("Custom Fields"),
262 if ( $request_path =~ m|^/Admin/$type/?(?:index.html)?$|
263 || ( $request_path =~ m|^/Admin/$type/(?:Modify.html)$|
264 && $DECODED_ARGS->{'Create'} )
270 $section = $tabs->child( select => title => $labels{$type},
271 path => "/Admin/$type/" );
274 $section->child( select => title => loc('Select'), path => "/Admin/$type/" );
275 $section->child( create => title => loc('Create'), path => "/Admin/$type/Modify.html?Create=1" );
278 if ( $request_path =~ m{^/Admin/Queues} ) {
279 if ( $DECODED_ARGS->{'id'} && $DECODED_ARGS->{'id'} =~ /^\d+$/
281 $DECODED_ARGS->{'Queue'} && $DECODED_ARGS->{'Queue'} =~ /^\d+$/
283 my $id = $DECODED_ARGS->{'Queue'} || $DECODED_ARGS->{'id'};
284 my $queue_obj = RT::Queue->new( $session{'CurrentUser'} );
285 $queue_obj->Load($id);
287 if ( $queue_obj and $queue_obj->id ) {
288 my $queue = PageMenu();
289 $queue->child( basics => title => loc('Basics'), path => "/Admin/Queues/Modify.html?id=" . $id );
290 $queue->child( people => title => loc('Watchers'), path => "/Admin/Queues/People.html?id=" . $id );
292 my $templates = $queue->child(templates => title => loc('Templates'), path => "/Admin/Queues/Templates.html?id=" . $id);
293 $templates->child( select => title => loc('Select'), path => "/Admin/Queues/Templates.html?id=".$id);
294 $templates->child( create => title => loc('Create'), path => "/Admin/Queues/Template.html?Create=1;Queue=".$id);
296 my $scrips = $queue->child( scrips => title => loc('Scrips'), path => "/Admin/Queues/Scrips.html?id=" . $id);
297 $scrips->child( select => title => loc('Select'), path => "/Admin/Queues/Scrips.html?id=" . $id );
298 $scrips->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html?Queue=" . $id);
300 my $cfs = $queue->child( 'custom-fields' => title => loc('Custom Fields') );
301 my $ticket_cfs = $cfs->child( 'tickets' => title => loc('Tickets'),
302 path => '/Admin/Queues/CustomFields.html?SubType=RT::Ticket&id=' . $id );
304 my $txn_cfs = $cfs->child( 'transactions' => title => loc('Transactions'),
305 path => '/Admin/Queues/CustomFields.html?SubType=RT::Ticket-RT::Transaction&id='.$id );
307 $queue->child( 'group-rights' => title => loc('Group Rights'), path => "/Admin/Queues/GroupRights.html?id=".$id );
308 $queue->child( 'user-rights' => title => loc('User Rights'), path => "/Admin/Queues/UserRights.html?id=" . $id );
309 $queue->child( 'history' => title => loc('History'), path => "/Admin/Queues/History.html?id=" . $id );
311 $m->callback( CallbackName => 'PrivilegedQueue', queue_id => $id, page_menu => $queue);
315 if ( $request_path =~ m{^(/Admin/Users|/User/(Summary|History)\.html)} and $admin->child("users") ) {
316 if ( $DECODED_ARGS->{'id'} && $DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
317 my $id = $DECODED_ARGS->{'id'};
318 my $obj = RT::User->new( $session{'CurrentUser'} );
321 if ( $obj and $obj->id ) {
322 my $tabs = PageMenu();
323 $tabs->child( basics => title => loc('Basics'), path => "/Admin/Users/Modify.html?id=" . $id );
324 $tabs->child( memberships => title => loc('Memberships'), path => "/Admin/Users/Memberships.html?id=" . $id );
325 $tabs->child( history => title => loc('History'), path => "/Admin/Users/History.html?id=" . $id );
326 $tabs->child( 'my-rt' => title => loc('RT at a glance'), path => "/Admin/Users/MyRT.html?id=" . $id );
327 $tabs->child( 'dashboards-in-menu' =>
328 title => loc('Dashboards in menu'),
329 path => '/Admin/Users/DashboardsInMenu.html?id=' . $id,
331 if ( RT->Config->Get('Crypt')->{'Enable'} ) {
332 $tabs->child( keys => title => loc('Private keys'), path => "/Admin/Users/Keys.html?id=" . $id );
334 $tabs->child( 'summary' => title => loc('User Summary'), path => "/User/Summary.html?id=" . $id );
340 if ( $request_path =~ m{^/Admin/Groups} ) {
341 if ( $DECODED_ARGS->{'id'} && $DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
342 my $id = $DECODED_ARGS->{'id'};
343 my $obj = RT::Group->new( $session{'CurrentUser'} );
346 if ( $obj and $obj->id ) {
347 my $tabs = PageMenu();
348 $tabs->child( basics => title => loc('Basics'), path => "/Admin/Groups/Modify.html?id=" . $obj->id );
349 $tabs->child( members => title => loc('Members'), path => "/Admin/Groups/Members.html?id=" . $obj->id );
350 $tabs->child( memberships => title => loc('Memberships'), path => "/Admin/Groups/Memberships.html?id=" . $obj->id );
351 $tabs->child( 'group-rights' => title => loc('Group Rights'), path => "/Admin/Groups/GroupRights.html?id=" . $obj->id );
352 $tabs->child( 'user-rights' => title => loc('User Rights'), path => "/Admin/Groups/UserRights.html?id=" . $obj->id );
353 $tabs->child( history => title => loc('History'), path => "/Admin/Groups/History.html?id=" . $obj->id );
358 if ( $request_path =~ m{^/Admin/CustomFields/} ) {
359 if ( $DECODED_ARGS->{'id'} && $DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
360 my $id = $DECODED_ARGS->{'id'};
361 my $obj = RT::CustomField->new( $session{'CurrentUser'} );
364 if ( $obj and $obj->id ) {
365 my $tabs = PageMenu();
366 $tabs->child( basics => title => loc('Basics'), path => "/Admin/CustomFields/Modify.html?id=".$id );
367 $tabs->child( 'group-rights' => title => loc('Group Rights'), path => "/Admin/CustomFields/GroupRights.html?id=" . $id );
368 $tabs->child( 'user-rights' => title => loc('User Rights'), path => "/Admin/CustomFields/UserRights.html?id=" . $id );
369 unless ( $obj->IsOnlyGlobal ) {
370 $tabs->child( 'applies-to' => title => loc('Applies to'), path => "/Admin/CustomFields/Objects.html?id=" . $id );
376 if ( $request_path =~ m{^/Admin/Scrips/} ) {
377 if ( $m->request_args->{'id'} && $m->request_args->{'id'} =~ /^\d+$/ ) {
378 my $id = $m->request_args->{'id'};
379 my $obj = RT::Scrip->new( $session{'CurrentUser'} );
382 my $tabs = PageMenu();
384 my ( $admin_cat, $create_path_arg, $from_query_param );
385 my $from_arg = $DECODED_ARGS->{'From'} || q{};
386 my ($from_queue) = $from_arg =~ /^(\d+)$/;
388 $admin_cat = "Queues/Scrips.html?id=$from_queue";
389 $create_path_arg = "?Queue=$from_queue";
390 $from_query_param = "&From=$from_queue";
392 elsif ( $from_arg eq 'Global' ) {
393 $admin_cat = 'Global/Scrips.html';
394 $create_path_arg = '?Global=1';
395 $from_query_param = '&From=Global';
398 $admin_cat = 'Scrips';
399 $from_query_param = $create_path_arg = q{};
401 my $scrips = $tabs->child( scrips => title => loc('Scrips'), path => "/Admin/${admin_cat}" );
402 $scrips->child( select => title => loc('Select'), path => "/Admin/${admin_cat}" );
403 $scrips->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html${create_path_arg}" );
405 $tabs->child( basics => title => loc('Basics') => path => "/Admin/Scrips/Modify.html?id=" . $id . $from_query_param );
406 $tabs->child( 'applies-to' => title => loc('Applies to'), path => "/Admin/Scrips/Objects.html?id=" . $id . $from_query_param );
408 elsif ( $request_path =~ m{^/Admin/Scrips/(index\.html)?$} ) {
409 PageMenu->child( select => title => loc('Select') => path => "/Admin/Scrips/" );
410 PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html" );
412 elsif ( $request_path =~ m{^/Admin/Scrips/Create\.html$} ) {
413 my ($queue) = $DECODED_ARGS->{'Queue'} && $DECODED_ARGS->{'Queue'} =~ /^(\d+)$/;
414 my $global_arg = $DECODED_ARGS->{'Global'};
416 PageMenu->child( select => title => loc('Select') => path => "/Admin/Queues/Scrips.html?id=$queue" );
417 PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html?Queue=$queue" );
418 } elsif ($global_arg) {
419 PageMenu->child( select => title => loc('Select') => path => "/Admin/Global/Scrips.html" );
420 PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html?Global=1" );
422 PageMenu->child( select => title => loc('Select') => path => "/Admin/Scrips" );
423 PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html" );
428 if ( $request_path =~ m{^/Admin/Global/Scrips\.html} ) {
429 my $tabs = PageMenu();
430 $tabs->child( select => title => loc('Select'), path => "/Admin/Global/Scrips.html" );
431 $tabs->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html?Global=1" );
434 if ( $request_path =~ m{^/Admin/Global/Templates?\.html} ) {
435 my $tabs = PageMenu();
436 $tabs->child( select => title => loc('Select'), path => "/Admin/Global/Templates.html" );
437 $tabs->child( create => title => loc('Create'), path => "/Admin/Global/Template.html?Create=1" );
440 if ( $request_path =~ m{^/Admin/Articles/Classes/} ) {
441 my $tabs = PageMenu();
442 if ( my $id = $DECODED_ARGS->{'id'} ) {
443 my $obj = RT::Class->new( $session{'CurrentUser'} );
446 if ( $obj and $obj->id ) {
447 my $section = $tabs->child( select => title => loc("Classes"), path => "/Admin/Articles/Classes/" );
448 $section->child( select => title => loc('Select'), path => "/Admin/Articles/Classes/" );
449 $section->child( create => title => loc('Create'), path => "/Admin/Articles/Classes/Modify.html?Create=1" );
451 $tabs->child( basics => title => loc('Basics'), path => "/Admin/Articles/Classes/Modify.html?id=".$id );
452 $tabs->child( topics => title => loc('Topics'), path => "/Admin/Articles/Classes/Topics.html?id=".$id );
453 $tabs->child( 'custom-fields' => title => loc('Custom Fields'), path => "/Admin/Articles/Classes/CustomFields.html?id=".$id );
454 $tabs->child( 'group-rights' => title => loc('Group Rights'), path => "/Admin/Articles/Classes/GroupRights.html?id=".$id );
455 $tabs->child( 'user-rights' => title => loc('User Rights'), path => "/Admin/Articles/Classes/UserRights.html?id=".$id );
456 $tabs->child( 'applies-to' => title => loc('Applies to'), path => "/Admin/Articles/Classes/Objects.html?id=$id" );
459 $tabs->child( select => title => loc('Select'), path => "/Admin/Articles/Classes/" );
460 $tabs->child( create => title => loc('Create'), path => "/Admin/Articles/Classes/Modify.html?Create=1" );
465 my $build_main_nav = sub {
467 PageWidgets()->child( simple_search => raw_html => $m->scomp('SimpleSearch') );
468 PageWidgets()->child( create_ticket => raw_html => $m->scomp('CreateTicket') );
470 my $home = Menu->child( home => title => loc('Homepage'), path => '/' );
471 unless ($session{'dashboards_in_menu'}) {
472 my $dashboards_in_menu = $session{CurrentUser}->UserObj->Preferences(
477 unless ($dashboards_in_menu->{dashboards}) {
478 my ($default_dashboards) =
479 RT::System->new( $session{'CurrentUser'} )
481 ->Named('DashboardsInMenu');
482 if ($default_dashboards) {
483 $dashboards_in_menu = $default_dashboards->Content;
487 $session{'dashboards_in_menu'} = $dashboards_in_menu->{dashboards} || [];
491 for my $id ( @{$session{'dashboards_in_menu'}} ) {
492 my $dash = RT::Dashboard->new( $session{CurrentUser} );
493 my ( $status, $msg ) = $dash->LoadById($id);
495 push @dashboards, $dash;
497 $RT::Logger->warning( "Failed to load dashboard $id: $msg" );
501 my $dashes = Menu()->child('home');
503 for my $dash (@dashboards) {
504 $home->child( 'dashboard-' . $dash->id,
505 title => $dash->Name,
506 path => '/Dashboards/' . $dash->id . '/' . $dash->Name
510 $dashes->child( edit => title => loc('Update This Menu'), path => 'Prefs/DashboardsInMenu.html' );
511 $dashes->child( more => title => loc('All Dashboards'), path => 'Dashboards/index.html' );
512 my $dashboard = RT::Dashboard->new( $session{CurrentUser} );
513 if ( $dashboard->CurrentUserCanCreateAny ) {
514 $dashes->child('dashboard_create' => title => loc('New Dashboard'), path => "/Dashboards/Modify.html?Create=1" );
517 my $search = Menu->child( search => title => loc('Search'), path => '/Search/Simple.html' );
519 my $tickets = $search->child( tickets => title => loc('Tickets'), path => '/Search/Build.html' );
520 $tickets->child( simple => title => loc('Simple Search'), path => "/Search/Simple.html" );
521 $tickets->child( new => title => loc('New Search'), path => "/Search/Build.html?NewQuery=1" );
523 $search->child( articles => title => loc('Articles'), path => "/Articles/Article/Search.html" )
524 if $session{CurrentUser}->HasRight( Right => 'ShowArticlesMenu', Object => RT->System );
526 $search->child( users => title => loc('Users'), path => "/User/Search.html" );
528 if ($session{CurrentUser}->HasRight( Right => 'ShowArticlesMenu', Object => RT->System )) {
529 my $articles = Menu->child( articles => title => loc('Articles'), path => "/Articles/index.html");
530 $articles->child( articles => title => loc('Overview'), path => "/Articles/index.html" );
531 $articles->child( topics => title => loc('Topics'), path => "/Articles/Topics.html" );
532 $articles->child( create => title => loc('Create'), path => "/Articles/Article/PreCreate.html" );
533 $articles->child( search => title => loc('Search'), path => "/Articles/Article/Search.html" );
536 my $tools = Menu->child( tools => title => loc('Tools'), path => '/Tools/index.html' );
538 $tools->child( my_day =>
539 title => loc('My Day'),
540 description => loc('Easy updating of your open tickets'),
541 path => '/Tools/MyDay.html',
544 if ( RT->Config->Get('EnableReminders') ) {
545 $tools->child( my_reminders =>
546 title => loc('My Reminders'),
547 description => loc('Easy viewing of your reminders'),
548 path => '/Tools/MyReminders.html',
552 if ( $session{'CurrentUser'}->HasRight( Right => 'ShowApprovalsTab', Object => RT->System ) ) {
553 $tools->child( approval =>
554 title => loc('Approval'),
555 description => loc('My Approvals'),
556 path => '/Approvals/',
560 if ( $session{'CurrentUser'}->HasRight( Right => 'ShowConfigTab', Object => RT->System ) )
562 $build_admin_menu->(Menu());
565 my $username = '<span class="current-user">'
566 . $m->interp->apply_escapes($session{'CurrentUser'}->Name, 'h')
568 my $about_me = Menu->child( 'preferences' =>
569 title => loc('Logged in as [_1]', $username),
571 path => '/User/Summary.html?id=' . $session{CurrentUser}->id,
576 if ( $session{'CurrentUser'}->UserObj
577 && $session{'CurrentUser'}->HasRight( Right => 'ModifySelf', Object => RT->System )) {
578 my $settings = $about_me->child( settings => title => loc('Settings'), path => '/Prefs/Other.html' );
579 $settings->child( options => title => loc('Preferences'), path => '/Prefs/Other.html' );
580 $settings->child( about_me => title => loc('About me'), path => '/User/Prefs.html' );
581 $settings->child( search_options => title => loc('Search options'), path => '/Prefs/SearchOptions.html' );
582 $settings->child( myrt => title => loc('RT at a glance'), path => '/Prefs/MyRT.html' );
583 $settings->child( dashboards_in_menu =>
584 title => loc('Dashboards in menu'),
585 path => '/Prefs/DashboardsInMenu.html',
587 $settings->child( quicksearch => title => loc('Quick search'), path => '/Prefs/Quicksearch.html' );
589 my $search_menu = $settings->child( 'saved-searches' => title => loc('Saved Searches') );
590 my $searches = [ $m->comp( "/Search/Elements/SearchesForObject",
591 Object => RT::System->new( $session{'CurrentUser'} )) ];
594 for my $search (@$searches) {
595 $search_menu->child( "search-" . $i++ =>
596 title => $search->[1],
597 path => "/Prefs/Search.html?"
598 . $query_string->( name => ref( $search->[2] ) . '-' . $search->[2]->Id ),
603 if ( $session{'CurrentUser'}->Name
604 && ( !RT->Config->Get('WebRemoteUserAuth')
605 || RT->Config->Get('WebFallbackToRTLogin') )) {
606 $about_me->child( logout => title => loc('Logout'), path => '/NoAuth/Logout.html' );
608 if ( $request_path =~ m{^/Dashboards/(\d+)?}) {
609 if ( my $id = ( $1 || $DECODED_ARGS->{'id'} ) ) {
610 my $obj = RT::Dashboard->new( $session{'CurrentUser'} );
612 if ( $obj and $obj->id ) {
614 $tabs->child( basics => title => loc('Basics'), path => "/Dashboards/Modify.html?id=" . $obj->id);
615 $tabs->child( content => title => loc('Content'), path => "/Dashboards/Queries.html?id=" . $obj->id);
616 $tabs->child( subscription => title => loc('Subscription'), path => "/Dashboards/Subscription.html?id=" . $obj->id)
617 if $obj->CurrentUserCanSubscribe;
618 $tabs->child( show => title => loc('Show'), path => "/Dashboards/" . $obj->id . "/" . $obj->Name)
624 if ( $request_path =~ m{^/Ticket/} ) {
625 if ( ( $DECODED_ARGS->{'id'} || '' ) =~ /^(\d+)$/ ) {
627 my $obj = RT::Ticket->new( $session{'CurrentUser'} );
630 if ( $obj and $obj->id ) {
631 my $actions = PageMenu()->child( actions => title => loc('Actions'), sort_order => 95 );
632 my $tabs = PageMenu();
633 $tabs->child( bookmark => raw_html => $m->scomp( '/Ticket/Elements/Bookmark', id => $id ), sort_order => 99 );
634 $tabs->child( display => title => loc('Display'), path => "/Ticket/Display.html?id=" . $id );
635 $tabs->child( history => title => loc('History'), path => "/Ticket/History.html?id=" . $id );
637 my %can = %{ $obj->CurrentUser->PrincipalObj->HasRights( Object => $obj ) };
638 $can{'_ModifyOwner'} = $obj->CurrentUserCanSetOwner();
640 unless ($_[0] eq 'ExecuteCode') {
641 return $can{$_[0]} || $can{'SuperUser'};
643 return !RT->Config->Get('DisallowExecuteCode')
644 && ( $can{'ExecuteCode'} || $can{'SuperUser'} );
648 # comment out until we can do it for an individual custom field
649 #if ( $can->('ModifyTicket') || $can->('ModifyCustomField') ) {
650 $tabs->child( basics => title => loc('Basics'), path => "/Ticket/Modify.html?id=" . $id );
654 if ( $can->('ModifyTicket') || $can->('_ModifyOwner') || $can->('Watch') || $can->('WatchAsAdminCc') ) {
655 $tabs->child( people => title => loc('People'), path => "/Ticket/ModifyPeople.html?id=" . $id );
658 if ( $can->('ModifyTicket') ) {
659 $tabs->child( dates => title => loc('Dates'), path => "/Ticket/ModifyDates.html?id=" . $id );
660 $tabs->child( links => title => loc('Links'), path => "/Ticket/ModifyLinks.html?id=" . $id );
663 #if ( $can->('ModifyTicket') || $can->('ModifyCustomField') || $can->('_ModifyOwner') ) {
664 $tabs->child( jumbo => title => loc('Jumbo'), path => "/Ticket/ModifyAll.html?id=" . $id );
667 if ( RT->Config->Get('EnableReminders') ) {
668 $tabs->child( reminders => title => loc('Reminders'), path => "/Ticket/Reminders.html?id=" . $id );
671 if ( $can->('ModifyTicket') or $can->('ReplyToTicket') ) {
672 $actions->child( reply => title => loc('Reply'), path => "/Ticket/Update.html?Action=Respond;id=" . $id );
675 if ( $can->('ModifyTicket') or $can->('CommentOnTicket') ) {
676 $actions->child( comment => title => loc('Comment'), path => "/Ticket/Update.html?Action=Comment;id=" . $id );
679 if ( $can->('ForwardMessage') ) {
680 $actions->child( forward => title => loc('Forward'), path => "/Ticket/Forward.html?id=" . $id );
683 my $hide_resolve_with_deps = RT->Config->Get('HideResolveActionsWithDependencies')
684 && $obj->HasUnresolvedDependencies;
686 my $current = $obj->Status;
687 my $lifecycle = $obj->LifecycleObj;
689 foreach my $info ( $lifecycle->Actions($current) ) {
690 my $next = $info->{'to'};
691 next unless $lifecycle->IsTransition( $current => $next );
693 my $check = $lifecycle->CheckRight( $current => $next );
694 next unless $can->($check);
696 next if $hide_resolve_with_deps
697 && $lifecycle->IsInactive($next)
698 && !$lifecycle->IsInactive($current);
700 my $action = $info->{'update'} || '';
701 my $url = '/Ticket/';
702 $url .= "Update.html?". $query_string->(
704 ? (Action => $action)
705 : (SubmitTicket => 1, Status => $next),
706 DefaultStatus => $next,
709 my $key = $info->{'label'} || ucfirst($next);
710 $actions->child( $key => title => loc( $key ), path => $url);
713 my ($can_take, $tmsg) = $obj->CurrentUserCanSetOwner( Type => 'Take' );
714 my ($can_steal, $smsg) = $obj->CurrentUserCanSetOwner( Type => 'Steal' );
716 $actions->child( take => title => loc('Take'), path => "/Ticket/Display.html?Action=Take;id=" . $id );
718 elsif ( $can_steal ){
719 $actions->child( steal => title => loc('Steal'), path => "/Ticket/Display.html?Action=Steal;id=" . $id );
722 # TODO needs a "Can extract article into a class applied to this queue" check
723 $actions->child( 'extract-article' =>
724 title => loc('Extract Article'),
725 path => "/Articles/Article/ExtractIntoClass.html?Ticket=".$obj->id,
726 ) if $session{CurrentUser}->HasRight( Right => 'ShowArticlesMenu', Object => RT->System );
728 if ( defined $session{"tickets"} ) {
729 # we have to update session data if we get new ItemMap
730 my $updatesession = 1 unless ( $session{"tickets"}->{'item_map'} );
732 my $item_map = $session{"tickets"}->ItemMap;
734 if ($updatesession) {
735 $session{"tickets"}->PrepForSerialization();
738 my $search = Menu()->child('search')->child('tickets');
739 # Don't display prev links if we're on the first ticket
740 if ( $item_map->{$id}->{prev} ) {
741 $search->child( first =>
742 title => '<< ' . loc('First'), class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{first});
743 $search->child( prev =>
744 title => '< ' . loc('Prev'), class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{$id}->{prev});
746 # Don't display next links if we're on the last ticket
747 if ( $item_map->{$id}->{next} ) {
748 $search->child( next =>
749 title => loc('Next') . ' >', class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{$id}->{next});
750 if ( $item_map->{last} ) {
751 $search->child( last =>
752 title => loc('Last') . ' >>', class => "nav", path => "/Ticket/Display.html?id=" . $item_map->{last});
762 $request_path =~ m{^/(?:Ticket|Search)/}
763 && $request_path !~ m{^/Search/Simple\.html}
765 || ( $request_path =~ m{^/Search/Simple\.html}
766 && $DECODED_ARGS->{'q'} )
769 my $search = Menu()->child('search')->child('tickets');
772 my $current_search = $session{"CurrentSearchHash"} || {};
773 my $search_id = $DECODED_ARGS->{'SavedSearchLoad'} || $DECODED_ARGS->{'SavedSearchId'} || $current_search->{'SearchId'} || '';
774 my $chart_id = $DECODED_ARGS->{'SavedChartSearchId'} || $current_search->{SavedChartSearchId};
776 $has_query = 1 if ( $DECODED_ARGS->{'Query'} or $current_search->{'Query'} );
779 my %fallback_query_args = (
780 SavedSearchId => ( $search_id eq 'new' ) ? undef : $search_id,
781 SavedChartSearchId => $chart_id,
785 $p => $DECODED_ARGS->{$p} || $current_search->{$p}
786 } qw(Query Format OrderBy Order Page)
789 defined $DECODED_ARGS->{'RowsPerPage'}
790 ? $DECODED_ARGS->{'RowsPerPage'}
791 : $current_search->{'RowsPerPage'}
796 $args = '?' . $QueryString;
799 my %final_query_args = ();
800 # key => callback to avoid unnecessary work
802 for my $param (keys %fallback_query_args) {
803 $final_query_args{$param} = defined($QueryArgs->{$param})
804 ? $QueryArgs->{$param}
805 : $fallback_query_args{$param};
808 for my $field (qw(Order OrderBy)) {
809 if ( ref( $final_query_args{$field} ) eq 'ARRAY' ) {
810 $final_query_args{$field} = join( "|", @{ $final_query_args{$field} } );
811 } elsif (not defined $final_query_args{$field}) {
812 delete $final_query_args{$field};
815 $final_query_args{$field} ||= '';
819 $args = '?' . $query_string->(%final_query_args);
822 my $current_search_menu;
823 if ( $request_path =~ m{^/Ticket} ) {
824 $current_search_menu = $search->child( current_search => title => loc('Current Search') );
825 $current_search_menu->path("/Search/Results.html$args") if $has_query;
827 $current_search_menu = PageMenu();
830 $current_search_menu->child( edit_search =>
831 title => loc('Edit Search'), path => "/Search/Build.html" . ( ($has_query) ? $args : '' ) );
832 $current_search_menu->child( advanced =>
833 title => loc('Advanced'), path => "/Search/Edit.html$args" );
835 $current_search_menu->child( results => title => loc('Show Results'), path => "/Search/Results.html$args" );
839 $current_search_menu->child( bulk => title => loc('Bulk Update'), path => "/Search/Bulk.html$args" );
840 $current_search_menu->child( chart => title => loc('Chart'), path => "/Search/Chart.html$args" );
842 my $more = $current_search_menu->child( more => title => loc('Feeds') );
844 $more->child( spreadsheet => title => loc('Spreadsheet'), path => "/Search/Results.tsv$args" );
847 $_ => $QueryArgs->{$_} || $fallback_query_args{$_} || '' }
848 qw(Query Order OrderBy);
849 my $RSSQueryString = "?"
850 . $query_string->( Query => $rss_data{Query},
851 Order => $rss_data{Order},
852 OrderBy => $rss_data{OrderBy}
854 my $RSSPath = join '/', map $m->interp->apply_escapes( $_, 'u' ),
855 $session{'CurrentUser'}->UserObj->Name,
856 $session{'CurrentUser'}
857 ->UserObj->GenerateAuthString( $rss_data{Query}
859 . $rss_data{OrderBy} );
861 $more->child( rss => title => loc('RSS'), path => "/NoAuth/rss/$RSSPath/$RSSQueryString");
862 my $ical_path = join '/', map $m->interp->apply_escapes($_, 'u'),
863 $session{'CurrentUser'}->UserObj->Name,
864 $session{'CurrentUser'}->UserObj->GenerateAuthString( $rss_data{Query} ),
866 $more->child( ical => title => loc('iCal'), path => '/NoAuth/iCal/'.$ical_path);
868 if ($request_path =~ m{^/Search/Results.html}
869 && #XXX TODO better abstraction
870 $session{'CurrentUser'}->HasRight( Right => 'SuperUser', Object => RT->System )) {
871 my $shred_args = $query_string->(
874 'Tickets:query' => $rss_data{'Query'},
875 'Tickets:limit' => $QueryArgs->{'Rows'},
878 $more->child( shredder => title => loc('Shredder'), path => '/Admin/Tools/Shredder/?' . $shred_args);
884 if ( $request_path =~ m{^/Article/} ) {
885 if ( $DECODED_ARGS->{'id'} && $DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
886 my $id = $DECODED_ARGS->{'id'};
887 my $tabs = PageMenu();
889 $tabs->child( display => title => loc('Display'), path => "/Articles/Article/Display.html?id=".$id );
890 $tabs->child( history => title => loc('History'), path => "/Articles/Article/History.html?id=".$id );
891 $tabs->child( modify => title => loc('Modify'), path => "/Articles/Article/Edit.html?id=".$id );
892 $tabs->child( delete => title => loc('Delete'), path => "/Articles/Article/Delete.html?id=".$id );
896 if ( $request_path =~ m{^/Articles/} ) {
897 PageWidgets()->child( article_search => raw_html => $m->scomp('/Articles/Elements/GotoArticle') );
898 PageWidgets()->delete('create_ticket');
899 PageWidgets()->delete('simple_search');
901 my $tabs = PageMenu();
902 $tabs->child( search => title => loc("Search"), path => "/Articles/Article/Search.html" );
903 $tabs->child( create => title => loc("New Article" ), path => "/Articles/Article/PreCreate.html" );
904 if ( $request_path =~ m{^/Articles/Article/} and ( $DECODED_ARGS->{'id'} || '' ) =~ /^(\d+)$/ ) {
906 my $obj = RT::Article->new( $session{'CurrentUser'} );
909 if ( $obj and $obj->id ) {
910 $tabs->child( display => title => loc("Display"), path => "/Articles/Article/Display.html?id=" . $id );
911 $tabs->child( history => title => loc('History'), path => '/Articles/Article/History.html?id=' . $id );
913 if ( $obj->CurrentUserHasRight('ModifyArticle') ) {
914 $tabs->child(modify => title => loc('Modify'), path => '/Articles/Article/Edit.html?id=' . $id );
916 if ( $obj->CurrentUserHasRight('DeleteArticle') ) {
917 $tabs->child(delete => title => loc('Delete'), path => '/Articles/Article/Delete.html?id=' . $id );
924 if ( $request_path =~ m{^/User/(Summary|History)\.html} ) {
925 if (PageMenu()->child('summary')) {
926 # Already set up from having AdminUser and ShowConfigTab;
927 # but rename "Basics" to "Edit" in this context
928 PageMenu()->child( 'basics' )->title( loc('Edit') );
929 } elsif ( $session{'CurrentUser'}->HasRight( Object => $RT::System, Right => 'ShowUserHistory' ) ) {
930 PageMenu()->child( display => title => loc('Summary'), path => '/User/Summary.html?id=' . $DECODED_ARGS->{'id'} );
931 PageMenu()->child( history => title => loc('History'), path => '/User/History.html?id=' . $DECODED_ARGS->{'id'} );
935 if ( $request_path =~ /^\/(?:index.html|$)/ ) {
936 PageMenu()->child( edit => title => loc('Edit'), path => '/Prefs/MyRT.html' );
939 $m->callback( CallbackName => 'Privileged', Path => $request_path );
942 my $build_selfservice_nav = sub {
943 my $queues = RT::Queues->new( $session{'CurrentUser'} );
949 while ( my $queue = $queues->Next ) {
950 next unless $queue->CurrentUserHasRight('CreateTicket');
951 $queue_id = $queue->id;
953 last if ( $queue_count > 1 );
957 if ( $queue_count > 1 ) {
958 Menu->child( new => title => loc('New ticket'), path => '/SelfService/CreateTicketInQueue.html' );
959 } elsif ( $queue_id ) {
960 Menu->child( new => title => loc('New ticket'), path => '/SelfService/Create.html?Queue=' . $queue_id );
962 my $tickets = Menu->child( tickets => title => loc('Tickets'), path => '/SelfService/' );
963 $tickets->child( open => title => loc('Open tickets'), path => '/SelfService/' );
964 $tickets->child( closed => title => loc('Closed tickets'), path => '/SelfService/Closed.html' );
967 my $username = '<span class="current-user">'
968 . $m->interp->apply_escapes($session{'CurrentUser'}->Name, 'h')
970 my $about_me = Menu->child( preferences =>
971 title => loc('Logged in as [_1]', $username),
976 if ( $session{'CurrentUser'}->HasRight( Right => 'ModifySelf', Object => RT->System ) ) {
977 $about_me->child( prefs => title => loc('Preferences'), path => '/SelfService/Prefs.html' );
980 if ( $session{'CurrentUser'}->Name
981 && ( !RT->Config->Get('WebRemoteUserAuth')
982 || RT->Config->Get('WebFallbackToRTLogin') )) {
983 $about_me->child( logout => title => loc('Logout'), path => '/NoAuth/Logout.html' );
986 if ($session{'CurrentUser'}->HasRight( Right => 'ShowArticle', Object => RT->System )) {
987 PageWidgets->child( 'goto-article' => raw_html => $m->scomp('/SelfService/Elements/SearchArticle') );
990 PageWidgets->child( goto => raw_html => $m->scomp('/SelfService/Elements/GotoTicket') );
992 $m->callback( CallbackName => 'SelfService', Path => $request_path );
997 if ( $request_path !~ m{^/SelfService/} ) {
1000 $build_selfservice_nav->();