@@ -56,62 +56,189 @@ use warnings;
5656sub Init {
5757 use RT::Config;
5858
59- RT-> Config-> AddOption(
60- Name => ' DisplayAfterEdit' ,
61- Section => ' Ticket display' ,
62- Overridable => 1,
63- Widget => ' /Widgets/Form/Boolean' ,
64- WidgetArguments => {
65- Description => ' Display RTIR ticket after edit (don\' t stay on the edit page)' ,
66- }
67- );
68-
69- RT-> Config-> AddOption(
70- Name => ' RTIR_DefaultQueue' ,
71- Section => ' General' ,
72- Overridable => 1,
73- SortOrder => 1.5,
74- Widget => ' /Widgets/Form/Select' ,
75- WidgetArguments => {
76- Description => ' Default RTIR queue' , # loc
77- Default => 1,
78- Callback => sub {
79- my $ret = { Values => [], ValuesLabel => {}};
80- my @queues = RT::IR-> Queues;
81- foreach my $queue_name ( @queues ) {
82- my $queue = RT::Queue-> new($HTML::Mason::Commands::session {' CurrentUser' });
83- $queue -> Load($queue_name );
84- next unless $queue -> CurrentUserHasRight(" CreateTicket" );
85- push @{$ret -> {Values }}, $queue -> Id;
86- $ret -> {ValuesLabel }{$queue -> Id} = $queue -> Name;
59+ RT-> Config-> RegisterPluginConfig(
60+ Plugin => ' RTIR' ,
61+ Content => [
62+ { Name => ' rtirname' ,
63+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#rtirname' ,
64+ },
65+ { Name => ' RTIR_IncidentChildren' ,
66+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#RTIR_IncidentChildren' ,
67+ },
68+ { Name => ' RTIR_RedirectOnLogin' ,
69+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#RTIR_RedirectOnLogin' ,
70+ },
71+ { Name => ' RTIR_RedirectOnSearch' ,
72+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#RTIR_RedirectOnSearch' ,
73+ },
74+ { Name => ' RTIR_DefaultQueue' ,
75+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#RTIR_DefaultQueue' ,
76+ },
77+ { Name => ' RTIR_StrictConstituencyLinking' ,
78+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#RTIR_StrictConstituencyLinking' ,
79+ },
80+ { Name => ' OverdueAfter' ,
81+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#OverdueAfter' ,
82+ },
83+ { Name => ' ReplyString' ,
84+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#ReplyString' ,
85+ },
86+ { Name => ' RTIR_OldestRelatedTickets' ,
87+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#RTIR_OldestRelatedTickets' ,
88+ },
89+ { Name => ' RTIRSearchResultFormats' ,
90+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#RTIRSearchResultFormats' ,
91+ },
92+ { Name => ' DisplayAfterEdit' ,
93+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#DisplayAfterEdit' ,
94+ },
95+ { Name => ' RTIR_HomepageComponents' ,
96+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#RTIR_HomepageComponents' ,
97+ },
98+ { Name => ' RTIR_CustomFieldsDefaults' ,
99+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#RTIR_CustomFieldsDefaults' ,
100+ },
101+ { Name => ' RTIR_StrictDomainTLD' ,
102+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#RTIR_StrictDomainTLD' ,
103+ },
104+ { Name => ' RTIR_DisableCountermeasures' ,
105+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#RTIR_DisableCountermeasures' ,
106+ },
107+ { Name => ' RTIR_CountermeasureApproveActionRegexp' ,
108+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#RTIR_CountermeasureApproveActionRegexp' ,
109+ },
110+ { Name => ' RTIRResearchTools' ,
111+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#RTIRResearchTools' ,
112+ },
113+ { Name => ' TracerouteCommand' ,
114+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#TracerouteCommand' ,
115+ },
116+ { Name => ' whois' ,
117+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#whois' ,
118+ },
119+ { Name => ' RunWhoisRequestByDefault' ,
120+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#RunWhoisRequestByDefault' ,
121+ },
122+ { Name => ' LookupIPinfoToken' ,
123+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#LookupIPinfoToken' ,
124+ },
125+ { Name => ' ExternalFeeds' ,
126+ Help => ' https://docs.bestpractical.com/rtir/latest/RTIR_Config.html#ExternalFeeds' ,
127+ },
128+ ],
129+ Meta => {
130+ rtirname => {
131+ Type => ' SCALAR' ,
132+ Widget => ' /Widgets/Form/String' ,
133+ },
134+ RTIR_IncidentChildren => { Type => ' HASH' , },
135+ RTIR_RedirectOnLogin => {
136+ Type => ' SCALAR' ,
137+ Widget => ' /Widgets/Form/Boolean' ,
138+ },
139+ RTIR_RedirectOnSearch => {
140+ Type => ' SCALAR' ,
141+ Widget => ' /Widgets/Form/Boolean' ,
142+ },
143+ RTIR_DefaultQueue => {
144+ Type => ' SCALAR' ,
145+ Widget => ' /Widgets/Form/Select' ,
146+ Section => ' General' ,
147+ Overridable => 1,
148+ SortOrder => 1.5,
149+ WidgetArguments => {
150+ Description => ' Default RTIR queue' , # loc
151+ Default => 1,
152+ Callback => sub {
153+ my $ret = { Values => [], ValuesLabel => {}};
154+ my @queues = RT::IR-> Queues;
155+ foreach my $queue_name ( @queues ) {
156+ my $queue = RT::Queue-> new($HTML::Mason::Commands::session {' CurrentUser' });
157+ $queue -> Load($queue_name );
158+ next unless $queue -> CurrentUserHasRight(" CreateTicket" );
159+ push @{$ret -> {Values }}, $queue -> Id;
160+ $ret -> {ValuesLabel }{$queue -> Id} = $queue -> Name;
161+ }
162+ return $ret ;
163+ },
164+ }
165+ },
166+ RTIR_StrictConstituencyLinking => {
167+ Type => ' SCALAR' ,
168+ Widget => ' /Widgets/Form/Boolean' ,
169+ },
170+ OverdueAfter => {
171+ Type => ' SCALAR' ,
172+ Widget => ' /Widgets/Form/Integer' ,
173+ },
174+ ReplyString => {
175+ Type => ' SCALAR' ,
176+ Widget => ' /Widgets/Form/String' ,
177+ },
178+ RTIR_OldestRelatedTickets => {
179+ Type => ' SCALAR' ,
180+ Widget => ' /Widgets/Form/Integer' ,
181+ },
182+ RTIRSearchResultFormats => {
183+ Type => ' HASH' ,
184+ PostLoadCheck => sub {
185+ my ( $self , %value ) = @_ ;
186+ foreach my $format ( keys %value ) {
187+ if ( $format =~ / ^HASH/ && !defined $value {$format } ) {
188+ RT-> Logger-> warning(
189+ ' You appear to have $RTIRSearchResultFormats in your configuration, this has been renamed to %RTIRSearchResultFormats see docs/UPGRADING-3.2'
190+ );
191+ }
192+ CheckObsoleteCFSyntax( $value {$format },
193+ $RT::Config::META {RTIRSearchResultFormats }{Source }{File } );
194+ }
195+ },
196+ },
197+ DisplayAfterEdit => {
198+ Type => ' SCALAR' ,
199+ Widget => ' /Widgets/Form/Boolean' ,
200+ Section => ' Ticket display' ,
201+ Overridable => 1,
202+ Widget => ' /Widgets/Form/Boolean' ,
203+ WidgetArguments => {
204+ Description => ' Display RTIR ticket after edit (don\' t stay on the edit page)' ,
87205 }
88- return $ret ;
89206 },
207+ RTIR_HomepageComponents => { Type => ' ARRAY' , },
208+ RTIR_CustomFieldsDefaults => { Type => ' HASH' , },
209+ RTIR_StrictDomainTLD => {
210+ Type => ' SCALAR' ,
211+ Widget => ' /Widgets/Form/Boolean' ,
212+ },
213+ RTIR_DisableCountermeasures => {
214+ Type => ' SCALAR' ,
215+ Widget => ' /Widgets/Form/Boolean' ,
216+ },
217+ RTIR_CountermeasureApproveActionRegexp => {
218+ Type => ' SCALAR' ,
219+ Immutable => 1,
220+ },
221+ RTIRResearchTools => { Type => ' ARRAY' , },
222+ TracerouteCommand => {
223+ Type => ' SCALAR' ,
224+ Immutable => 1,
225+ },
226+ whois => { Type => ' HASH' , },
227+ RunWhoisRequestByDefault => {
228+ Type => ' SCALAR' ,
229+ Widget => ' /Widgets/Form/Boolean' ,
230+ },
231+ LookupIPinfoToken => {
232+ Type => ' SCALAR' ,
233+ Obfuscate => sub {
234+ my ($config , $sources , $user ) = @_ ;
235+ return $user -> loc(' Token not printed' );
236+ },
237+ },
238+ ExternalFeeds => { Type => ' HASH' , },
90239 }
91240 );
92241
93- my %meta = (
94- ' RTIR_HomepageComponents' => {
95- Type => ' ARRAY' ,
96- },
97- );
98- %RT::Config::META = (%meta , %RT::Config::META );
99-
100- # Tack on the PostLoadCheck here so it runs no matter where
101- # RTIRSearchResultFormats gets loaded from. It will still
102- # squash any other PostLoadChecks for this config entry, but those
103- # should go here.
104- $RT::Config::META {RTIRSearchResultFormats }{PostLoadCheck } =
105- sub {
106- my ($self , %value ) = @_ ;
107- foreach my $format ( keys %value ){
108- if ($format =~ / ^HASH/ && !defined $value {$format }) {
109- RT-> Logger-> warning(' You appear to have $RTIRSearchResultFormats in your configuration, this has been renamed to %RTIRSearchResultFormats see docs/UPGRADING-3.2' );
110- }
111- CheckObsoleteCFSyntax($value {$format },
112- $RT::Config::META {RTIRSearchResultFormats }{Source }{File });
113- }
114- };
115242
116243 my @homepage_components = @{RT-> Config-> Get(' HomepageComponents' )};
117244
0 commit comments