|
| 1 | +%# BEGIN BPS TAGGED BLOCK {{{ |
| 2 | +%# |
| 3 | +%# COPYRIGHT: |
| 4 | +%# |
| 5 | +%# This software is Copyright (c) 1996-2024 Best Practical Solutions, LLC |
| 6 | +%# <sales@bestpractical.com> |
| 7 | +%# |
| 8 | +%# (Except where explicitly superseded by other copyright notices) |
| 9 | +%# |
| 10 | +%# |
| 11 | +%# LICENSE: |
| 12 | +%# |
| 13 | +%# This work is made available to you under the terms of Version 2 of |
| 14 | +%# the GNU General Public License. A copy of that license should have |
| 15 | +%# been provided with this software, but in any event can be snarfed |
| 16 | +%# from www.gnu.org. |
| 17 | +%# |
| 18 | +%# This work is distributed in the hope that it will be useful, but |
| 19 | +%# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | +%# General Public License for more details. |
| 22 | +%# |
| 23 | +%# You should have received a copy of the GNU General Public License |
| 24 | +%# along with this program; if not, write to the Free Software |
| 25 | +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 26 | +%# 02110-1301 or visit their web page on the internet at |
| 27 | +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. |
| 28 | +%# |
| 29 | +%# |
| 30 | +%# CONTRIBUTION SUBMISSION POLICY: |
| 31 | +%# |
| 32 | +%# (The following paragraph is not intended to limit the rights granted |
| 33 | +%# to you to modify and distribute this software under the terms of |
| 34 | +%# the GNU General Public License and is only of importance to you if |
| 35 | +%# you choose to contribute your changes and enhancements to the |
| 36 | +%# community by submitting them to Best Practical Solutions, LLC.) |
| 37 | +%# |
| 38 | +%# By intentionally submitting any modifications, corrections or |
| 39 | +%# derivatives to this work, or any other work intended for use with |
| 40 | +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that |
| 41 | +%# you are the copyright holder for those contributions and you grant |
| 42 | +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, |
| 43 | +%# royalty-free, perpetual, license to use, copy, create derivative |
| 44 | +%# works based on those contributions, and sublicense and distribute |
| 45 | +%# those contributions and any derivatives thereof. |
| 46 | +%# |
| 47 | +%# END BPS TAGGED BLOCK }}} |
| 48 | +<%INIT> |
| 49 | + |
| 50 | +my $query_string = sub { |
| 51 | + my %args = @_; |
| 52 | + my $u = URI->new(); |
| 53 | + $u->query_form(map { $_ => $args{$_} } sort keys %args); |
| 54 | + return $u->query || ''; |
| 55 | +}; |
| 56 | + |
| 57 | +if ( my $admin = Menu->child('admin') ) { |
| 58 | + if ( my $global = $admin->child('global') ) { |
| 59 | + $global->child( |
| 60 | + 'my-rtir' => title => 'RTIR at a glance', |
| 61 | + path => '/Admin/Global/MyRT.html?' |
| 62 | + . $query_string->( |
| 63 | + Title => loc('Customize Global RTIR at a glance'), |
| 64 | + WidgetTitle => loc('Set RTIR Homepage'), |
| 65 | + AttributeName => 'RTIRDefaultDashboard', |
| 66 | + AttributeDescription => 'RTIR Default Dashboard', |
| 67 | + ), |
| 68 | + sort_order => 8.1, |
| 69 | + ); |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | +my $args = $DECODED_ARGS; |
| 74 | + |
| 75 | +my @query_fields = qw(Query Format RowsPerPage Page OrderBy Order ExtraQueryParams); |
| 76 | + |
| 77 | +my $search_arguments = sub { |
| 78 | + my %res = (); |
| 79 | + my $caller_args = $m->caller_args(1); |
| 80 | + if ( $caller_args->{'SearchArgs'} ) { |
| 81 | + @res{ @query_fields } = @{ $caller_args->{'SearchArgs'} }{ @query_fields }; |
| 82 | + if ( $res{ExtraQueryParams} ) { |
| 83 | + $res{$_} = $caller_args->{'SearchArgs'}{$_} |
| 84 | + for ref $res{ExtraQueryParams} ? @{ $res{ExtraQueryParams} } : $res{ExtraQueryParams}; |
| 85 | + } |
| 86 | + } else { |
| 87 | + @res{ @query_fields } = @{ $args }{ @query_fields }; |
| 88 | + if ( $res{ExtraQueryParams} ) { |
| 89 | + $res{$_} = $args->{$_} |
| 90 | + for ref $res{ExtraQueryParams} ? @{ $res{ExtraQueryParams} } : $res{ExtraQueryParams}; |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + delete $res{$_} foreach grep !defined $res{$_}, keys %res; |
| 95 | + return %res; |
| 96 | +}; |
| 97 | + |
| 98 | +my $root = Menu->child( rtir => title => loc('RTIR'), path => '/RTIR/', sort_order => '1.5' ); |
| 99 | + |
| 100 | +my $search = $root->child( search => title => loc('Search'), path => RT::IR->HREFTo('', IncludeWebPath => 0) ); |
| 101 | +$search->child( new => title => loc('New Search'), path => '/Search/Build.html?NewQuery=1&ExtraQueryParams=RTIR&RTIR=1' ); |
| 102 | + |
| 103 | +$root->child( |
| 104 | + incidents => title => loc('Incidents'), |
| 105 | + path => '/Search/Results.html?ExtraQueryParams=RTIR&RTIR=1&Lifecycle='.RT::IR->lifecycle_incident, |
| 106 | +)->child( |
| 107 | + create => title => loc('Create'), |
| 108 | + path => RT::IR->HREFTo('Incident/Create.html?Lifecycle='.RT::IR->lifecycle_incident, IncludeWebPath => 0), |
| 109 | +); |
| 110 | +$root->child( |
| 111 | + reports => title => loc('Incident Reports'), |
| 112 | + path => '/Search/Results.html?ExtraQueryParams=RTIR&RTIR=1&Lifecycle='. RT::IR->lifecycle_report, |
| 113 | +)->child( |
| 114 | + create => title => loc('Create'), |
| 115 | + path => RT::IR->HREFTo('Create.html?Lifecycle='.RT::IR->lifecycle_report, IncludeWebPath => 0), |
| 116 | +); |
| 117 | +$root->child( |
| 118 | + investigations => title => loc('Investigations'), |
| 119 | + path => '/Search/Results.html?ExtraQueryParams=RTIR&RTIR=1&Lifecycle='.RT::IR->lifecycle_investigation, |
| 120 | +)->child( |
| 121 | + launch => title => loc('Launch'), |
| 122 | + path => RT::IR->HREFTo('Create.html?Lifecycle='.RT::IR->lifecycle_investigation, IncludeWebPath => 0), |
| 123 | +); |
| 124 | +unless ( RT->Config->Get('RTIR_DisableCountermeasures') ) { |
| 125 | + $root->child( |
| 126 | + countermeasures => title => loc('Countermeasures'), |
| 127 | + path => '/Search/Results.html?ExtraQueryParams=RTIR&RTIR=1&Lifecycle='.RT::IR->lifecycle_countermeasure, |
| 128 | + )->child( |
| 129 | + create => title => loc('Create'), |
| 130 | + path => RT::IR->HREFTo('Create.html?Lifecycle='.RT::IR->lifecycle_countermeasure, IncludeWebPath => 0), |
| 131 | + ); |
| 132 | +} |
| 133 | + |
| 134 | +my $tools = $root->child( tools => title => loc('Tools'), path => RT::IR->HREFTo('Tools/', IncludeWebPath => 0) ); |
| 135 | +$tools->child( lookup => title => loc('Lookup'), path => RT::IR->HREFTo('Tools/Lookup.html', IncludeWebPath => 0)); |
| 136 | +$tools->child( reporting => title => loc('Reporting'), path => RT::IR->HREFTo('Reporting/', IncludeWebPath => 0) ); |
| 137 | +my $scripted_actions = $tools->child( scripted_actions => title => loc('Scripted Action') ); |
| 138 | +$scripted_actions->child( email => title => loc('By Email address'), path => RT::IR->HREFTo('Tools/ScriptedAction.html', IncludeWebPath => 0) ); |
| 139 | +$scripted_actions->child( ip => title => loc('By IP address'), path => RT::IR->HREFTo('Tools/ScriptedAction.html?loop=IP', IncludeWebPath => 0) ); |
| 140 | +my $external_feeds = $tools->child( 'external_feeds', title => loc('External Feeds'), path => RT::IR->HREFTo('Tools/ExternalFeeds.html', IncludeWebPath => 0) ); |
| 141 | + |
| 142 | +my $request_path = $HTML::Mason::Commands::r->path_info; |
| 143 | +$request_path =~ s!/{2,}!/!g; |
| 144 | + |
| 145 | +my $re_rtir_path = qr'^/RTIR/(?:c/[^/]*/?)?'; |
| 146 | +my $re_rtir_types = '(?:'. join( '|', map "\Q$_\E", RT::IR->Types ) .')'; |
| 147 | + |
| 148 | +if ( $session{'CurrentUser'}->HasRight(Right => 'ModifySelf', Object => $RT::System) ) { |
| 149 | + if ( $request_path =~ m{(?:$re_rtir_path)(?:index\.html|)$} ) { |
| 150 | + PageMenu()->child( edit => raw_html => q[<a id="page-edit" class="menu-item" href="] . RT::IR->HREFTo("Prefs/Home.html") . qq["><span class="fas fa-cog" alt="].loc('Edit').q[" data-toggle="tooltip" data-placement="top" data-original-title="].loc('Edit').q["></span></a>]); |
| 151 | + } |
| 152 | + Menu->child('preferences')->child('settings')->child( |
| 153 | + rtir_home_page => title => loc('RTIR at a glance'), |
| 154 | + path => RT::IR->HREFTo('Prefs/Home.html', IncludeWebPath => 0), |
| 155 | + ); |
| 156 | +} |
| 157 | + |
| 158 | +</%INIT> |
0 commit comments