-
Notifications
You must be signed in to change notification settings - Fork 252
/
Config.pm
3125 lines (2841 loc) · 107 KB
/
Config.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# BEGIN BPS TAGGED BLOCK {{{
#
# COPYRIGHT:
#
# This software is Copyright (c) 1996-2023 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
#
#
# LICENSE:
#
# This work is made available to you under the terms of Version 2 of
# the GNU General Public License. A copy of that license should have
# been provided with this software, but in any event can be snarfed
# from www.gnu.org.
#
# This work is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 or visit their web page on the internet at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
#
#
# CONTRIBUTION SUBMISSION POLICY:
#
# (The following paragraph is not intended to limit the rights granted
# to you to modify and distribute this software under the terms of
# the GNU General Public License and is only of importance to you if
# you choose to contribute your changes and enhancements to the
# community by submitting them to Best Practical Solutions, LLC.)
#
# By intentionally submitting any modifications, corrections or
# derivatives to this work, or any other work intended for use with
# Request Tracker, to Best Practical Solutions, LLC, you confirm that
# you are the copyright holder for those contributions and you grant
# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
# royalty-free, perpetual, license to use, copy, create derivative
# works based on those contributions, and sublicense and distribute
# those contributions and any derivatives thereof.
#
# END BPS TAGGED BLOCK }}}
package RT::Config;
use strict;
use warnings;
use 5.010;
use File::Spec ();
use Symbol::Global::Name;
use List::MoreUtils 'uniq';
use Clone ();
# Store log messages generated before RT::Logger is available
our @PreInitLoggerMessages;
=head1 NAME
RT::Config - RT's config
=head1 SYNOPSIS
# get config object
use RT::Config;
my $config = RT::Config->new;
$config->LoadConfigs;
# get or set option
my $rt_web_path = $config->Get('WebPath');
$config->Set(EmailOutputEncoding => 'latin1');
# get config object from RT package
use RT;
RT->LoadConfig;
my $config = RT->Config;
=head1 DESCRIPTION
C<RT::Config> class provide access to RT's and RT extensions' config files.
RT uses two files for site configuring:
First file is F<RT_Config.pm> - core config file. This file is shipped
with RT distribution and contains default values for all available options.
B<You should never edit this file.>
Second file is F<RT_SiteConfig.pm> - site config file. You can use it
to customize your RT instance. In this file you can override any option
listed in core config file.
You may also split settings into separate files under the
F<etc/RT_SiteConfig.d/> directory. All files ending in C<.pm> will be parsed,
in alphabetical order, after F<RT_SiteConfig.pm> is loaded.
RT extensions could also provide their config files. Extensions should
use F<< <NAME>_Config.pm >> and F<< <NAME>_SiteConfig.pm >> names for
config files, where <NAME> is extension name.
B<NOTE>: All options from RT's config and extensions' configs are saved
in one place and thus extension could override RT's options, but it is not
recommended.
=cut
=head2 %META
Hash of Config options that may be user overridable
or may require more logic than should live in RT_*Config.pm
Keyed by config name, there are several properties that
can be set for each config optin:
Section - What header this option should be grouped
under on the user Preferences page
Overridable - Can users change this option
SortOrder - Within a Section, how should the options be sorted
for display to the user
Widget - Mason component path to widget that should be used
to display this config option
WidgetArguments - An argument hash passed to the Widget
Description - Friendly description to show the user
Values - Arrayref of options (for select Widget)
ValuesLabel - Hashref, key is the Value from the Values
list, value is a user friendly description
of the value
Callback - subref that receives no arguments. It returns
a hashref of items that are added to the rest
of the WidgetArguments
PostSet - subref passed the RT::Config object and the current and
previous setting of the config option. This is called well
before much of RT's subsystems are initialized, so what you
can do here is pretty limited. It's mostly useful for
effecting the value of other config options early.
PostLoadCheck - subref passed the RT::Config object and the current
setting of the config option. Can make further checks
(such as seeing if a library is installed) and then change
the setting of this or other options in the Config using
the RT::Config option.
Obfuscate - subref passed the RT::Config object, current setting of the config option
and a user object, can return obfuscated value. it's called in
RT->Config->GetObfuscated()
=cut
our %META;
%META = (
# General user overridable options
RestrictReferrerLogin => {
PostLoadCheck => sub {
my $self = shift;
if (defined($self->Get('RestrictReferrerLogin'))) {
RT::Logger->error("The config option 'RestrictReferrerLogin' is incorrect, and should be 'RestrictLoginReferrer' instead.");
}
},
},
DefaultQueue => {
Section => 'General',
Overridable => 1,
SortOrder => 1,
Widget => '/Widgets/Form/Select',
WidgetArguments => {
Description => 'Default queue', #loc
Default => 1, # allow user to unset it on EditConfig.html
Callback => sub {
my $ret = { Values => [], ValuesLabel => {}};
my $q = RT::Queues->new($HTML::Mason::Commands::session{'CurrentUser'});
$q->UnLimit;
while (my $queue = $q->Next) {
next unless $queue->CurrentUserHasRight("CreateTicket");
push @{$ret->{Values}}, $queue->Id;
$ret->{ValuesLabel}{$queue->Id} = $queue->Name;
}
return $ret;
},
}
},
RememberDefaultQueue => {
Section => 'General',
Overridable => 1,
SortOrder => 2,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Remember default queue' # loc
}
},
UsernameFormat => {
Section => 'General',
Overridable => 1,
SortOrder => 3,
Widget => '/Widgets/Form/Select',
WidgetArguments => {
Description => 'Username format', # loc
Values => [qw(role concise verbose)],
ValuesLabel => {
role => 'Privileged: usernames; Unprivileged: names and email addresses', # loc
concise => 'Short usernames', # loc
verbose => 'Name and email address', # loc
},
},
},
AutocompleteOwners => {
Section => 'General',
Overridable => 1,
SortOrder => 3.1,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Use autocomplete to find owners?', # loc
Hints => 'Replaces the owner dropdowns with textboxes' #loc
}
},
AutocompleteQueues => {
Section => 'General',
Overridable => 1,
SortOrder => 3.2,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Use autocomplete to find queues?', # loc
Hints => 'Replaces the queue dropdowns with textboxes' #loc
}
},
WebDefaultStylesheet => {
Section => 'General', #loc
Overridable => 1,
SortOrder => 4,
Widget => '/Widgets/Form/Select',
WidgetArguments => {
Description => 'Theme', #loc
Callback => sub {
state @stylesheets;
unless (@stylesheets) {
for my $static_path ( RT::Interface::Web->StaticRoots ) {
my $css_path =
File::Spec->catdir( $static_path, 'css' );
next unless -d $css_path;
if ( opendir my $dh, $css_path ) {
push @stylesheets, grep {
-e File::Spec->catfile( $css_path, $_, 'main.css' )
} readdir $dh;
}
else {
RT->Logger->error("Can't read $css_path: $!");
}
}
@stylesheets = sort { lc $a cmp lc $b } uniq @stylesheets;
}
return { Values => \@stylesheets };
},
},
PostLoadCheck => sub {
my $self = shift;
my $value = $self->Get('WebDefaultStylesheet');
my @roots = RT::Interface::Web->StaticRoots;
for my $root (@roots) {
return if -d "$root/css/$value";
}
$RT::Logger->warning(
"The default stylesheet ($value) does not exist in this instance of RT. "
. "Defaulting to elevator-light."
);
$self->Set('WebDefaultStylesheet', 'elevator-light');
},
},
TimeInICal => {
Section => 'General',
Overridable => 1,
SortOrder => 5,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Include time in iCal feed events?', # loc
Hints => 'Formats iCal feed events with date and time' #loc
}
},
UseSideBySideLayout => {
Section => 'Ticket composition',
Overridable => 1,
SortOrder => 5,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Use a two column layout for create and update forms?' # loc
}
},
MessageBoxRichText => {
Section => 'Ticket composition',
Overridable => 1,
SortOrder => 5.1,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'WYSIWYG message composer' # loc
}
},
MessageBoxRichTextHeight => {
Section => 'Ticket composition',
Overridable => 1,
SortOrder => 6,
Widget => '/Widgets/Form/Integer',
WidgetArguments => {
Description => 'WYSIWYG composer height', # loc
}
},
MessageBoxWidth => {
Section => 'Ticket composition',
Overridable => 1,
SortOrder => 7,
Widget => '/Widgets/Form/Integer',
WidgetArguments => {
Description => 'Message box width', #loc
},
},
MessageBoxHeight => {
Section => 'Ticket composition',
Overridable => 1,
SortOrder => 8,
Widget => '/Widgets/Form/Integer',
WidgetArguments => {
Description => 'Message box height', #loc
},
},
DefaultTimeUnitsToHours => {
Section => 'Ticket composition', #loc
Overridable => 1,
SortOrder => 9,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Enter time in hours by default', #loc
Hints => 'Only for entry, not display', #loc
},
},
SignatureAboveQuote => {
Section => 'Ticket composition', #loc
Overridable => 1,
SortOrder => 10,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Place signature above quote', #loc
},
},
PreferDropzone => {
Section => 'Ticket composition', #loc
Overridable => 1,
SortOrder => 11,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Use dropzone if available', #loc
},
},
RefreshIntervals => {
Type => 'ARRAY',
PostLoadCheck => sub {
my $self = shift;
my @intervals = $self->Get('RefreshIntervals');
if (grep { $_ == 0 } @intervals) {
$RT::Logger->warning("Please do not include a 0 value in RefreshIntervals, as that default is already added for you.");
}
},
},
SearchResultsRefreshInterval => {
Section => 'General', #loc
Overridable => 1,
SortOrder => 9,
Widget => '/Widgets/Form/Select',
WidgetArguments => {
Description => 'Search results refresh interval', #loc
Callback => sub {
my @values = RT->Config->Get('RefreshIntervals');
my %labels = (
0 => "Don't refresh search results.", # loc
);
for my $value (@values) {
if ($value % 60 == 0) {
$labels{$value} = [
'Refresh search results every [quant,_1,minute,minutes].', #loc
$value / 60
];
}
else {
$labels{$value} = [
'Refresh search results every [quant,_1,second,seconds].', #loc
$value
];
}
}
unshift @values, 0;
return { Values => \@values, ValuesLabel => \%labels };
},
},
},
EnableJSChart => {
Section => 'General', #loc
Overridable => 1,
SortOrder => 10,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Use JavaScript to render charts', #loc
},
},
JSChartColorScheme => {
Section => 'General', #loc
Overridable => 1,
SortOrder => 11,
Widget => '/Widgets/Form/String',
WidgetArguments => {
Description => 'JavaScript chart color scheme', #loc
},
},
EnableURLShortener => {
Section => 'General', #loc
Overridable => 1,
SortOrder => 12,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Enable URL shortener', #loc
},
},
# User overridable options for RT at a glance
HomePageRefreshInterval => {
Section => 'RT at a glance', #loc
Overridable => 1,
SortOrder => 2,
Widget => '/Widgets/Form/Select',
WidgetArguments => {
Description => 'Home page refresh interval', #loc
Callback => sub {
my @values = RT->Config->Get('RefreshIntervals');
my %labels = (
0 => "Don't refresh home page.", # loc
);
for my $value (@values) {
if ($value % 60 == 0) {
$labels{$value} = [
'Refresh home page every [quant,_1,minute,minutes].', #loc
$value / 60
];
}
else {
$labels{$value} = [
'Refresh home page every [quant,_1,second,seconds].', #loc
$value
];
}
}
unshift @values, 0;
return { Values => \@values, ValuesLabel => \%labels };
},
},
},
# User overridable options for Ticket displays
PreferRichText => {
Section => 'Ticket display', # loc
Overridable => 1,
SortOrder => 0.9,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Display messages in rich text if available', # loc
Hints => 'Rich text (HTML) shows formatting such as colored text, bold, italics, and more', # loc
},
},
MaxInlineBody => {
Section => 'Ticket display', #loc
Overridable => 1,
SortOrder => 1,
Widget => '/Widgets/Form/Integer',
WidgetArguments => {
Description => 'Maximum inline message length', #loc
Hints =>
"Length in characters; Use '0' to show all messages inline, regardless of length" #loc
},
},
OldestTransactionsFirst => {
Section => 'Ticket display',
Overridable => 1,
SortOrder => 2,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Show oldest history first', #loc
},
},
ShowHistory => {
Section => 'Ticket display',
Overridable => 1,
SortOrder => 3,
Widget => '/Widgets/Form/Select',
WidgetArguments => {
Description => 'Show history', #loc
Values => [qw(delay click always scroll)],
ValuesLabel => {
delay => "after the rest of the page loads", #loc
click => "after clicking a link", #loc
always => "immediately", #loc
scroll => "as you scroll", #loc
},
},
},
ShowUnreadMessageNotifications => {
Section => 'Ticket display',
Overridable => 1,
SortOrder => 4,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Notify me of unread messages', #loc
},
},
PlainTextMono => {
Section => 'Ticket display',
Overridable => 1,
SortOrder => 5,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Display plain-text attachments in fixed-width font', #loc
Hints => 'Display all plain-text attachments in a monospace font with formatting preserved, but wrapping as needed.', #loc
},
},
MoreAboutRequestorTicketList => {
Section => 'Ticket display', #loc
Overridable => 1,
SortOrder => 6,
Widget => '/Widgets/Form/Select',
WidgetArguments => {
Description => 'What tickets to display in the "More about requestor" box', #loc
Values => [qw(Active Inactive All None)],
ValuesLabel => {
Active => "Show the Requestor's 10 highest priority active tickets", #loc
Inactive => "Show the Requestor's 10 highest priority inactive tickets", #loc
All => "Show the Requestor's 10 highest priority tickets", #loc
None => "Show no tickets for the Requestor", #loc
},
},
},
SimplifiedRecipients => {
Section => 'Ticket display', #loc
Overridable => 1,
SortOrder => 7,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => "Show simplified recipient list on ticket update", #loc
},
},
SquelchedRecipients => {
Section => 'Ticket display', #loc
Overridable => 1,
SortOrder => 8,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => "Default to squelching all outgoing email notifications (from web interface) on ticket update", #loc
},
},
DisplayTicketAfterQuickCreate => {
Section => 'Ticket display',
Overridable => 1,
SortOrder => 9,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Display ticket after "Quick Create"', #loc
},
},
QuoteFolding => {
Section => 'Ticket display',
Overridable => 1,
SortOrder => 10,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Enable quote folding?' # loc
}
},
HideUnsetFieldsOnDisplay => {
Section => 'Ticket display',
Overridable => 1,
SortOrder => 11,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Hide unset fields?' # loc
}
},
InlineEdit => {
Section => 'Ticket display',
Overridable => 1,
SortOrder => 12,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Enable inline edit?' # loc
}
},
InlineEditPanelBehavior => {
Type => 'HASH',
PostLoadCheck => sub {
my $config = shift;
# use scalar context intentionally to avoid not a hash error
my $behavior = $config->Get('InlineEditPanelBehavior') || {};
unless (ref($behavior) eq 'HASH') {
RT->Logger->error("Config option \%InlineEditPanelBehavior is a @{[ref $behavior]} not a HASH; ignoring");
$behavior = {};
}
my %valid = map { $_ => 1 } qw/link click always hide/;
for my $class (keys %$behavior) {
if (ref($behavior->{$class}) eq 'HASH') {
for my $panel (keys %{ $behavior->{$class} }) {
my $value = $behavior->{$class}{$panel};
if (!$valid{$value}) {
RT->Logger->error("Config option \%InlineEditPanelBehavior{$class}{$panel}, which is '$value', must be one of: " . (join ', ', map { "'$_'" } sort keys %valid) . "; ignoring");
delete $behavior->{$class}{$panel};
}
}
} else {
RT->Logger->error("Config option \%InlineEditPanelBehavior{$class} is not a HASH; ignoring");
delete $behavior->{$class};
next;
}
}
$config->Set( InlineEditPanelBehavior => %$behavior );
},
},
ShowSearchNavigation => {
Section => 'Ticket display',
Overridable => 1,
SortOrder => 13,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Show search navigation', # loc
Hints => 'Show search navigation links of "First", "Last", "Prev" and "Next"', # loc
}
},
QuoteSelectedText => {
Section => 'Ticket display',
Overridable => 1,
SortOrder => 14,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Quote selected text on ticket update', # loc
}
},
# User overridable locale options
DateTimeFormat => {
Section => 'Locale', #loc
Overridable => 1,
Widget => '/Widgets/Form/Select',
WidgetArguments => {
Description => 'Date format', #loc
Callback => sub { my $ret = { Values => [], ValuesLabel => {}};
my $date = RT::Date->new($HTML::Mason::Commands::session{'CurrentUser'});
$date->SetToNow;
foreach my $value ($date->Formatters) {
push @{$ret->{Values}}, $value;
$ret->{ValuesLabel}{$value} = $date->Get(
Format => $value,
Timezone => 'user',
);
}
return $ret;
},
},
},
RTAddressRegexp => {
Type => 'SCALAR',
Immutable => 1,
PostLoadCheck => sub {
my $self = shift;
my $value = $self->Get('RTAddressRegexp');
if (not $value) {
$RT::Logger->debug(
'The RTAddressRegexp option is not set in the config.'
.' Not setting this option results in additional SQL queries to'
.' check whether each address belongs to RT or not.'
.' It is especially important to set this option if RT receives'
.' emails on addresses that are not in the database or config.'
);
} elsif (ref $value and ref $value eq "Regexp") {
# Ensure that the regex is case-insensitive; while the
# local part of email addresses is _technically_
# case-sensitive, most MTAs don't treat it as such.
$RT::Logger->warning(
'RTAddressRegexp is set to a case-sensitive regular expression.'
.' This may lead to mail loops with MTAs which treat the'
.' local part as case-insensitive -- which is most of them.'
) if "$value" =~ /^\(\?[a-z]*-([a-z]*):/ and "$1" =~ /i/;
}
},
},
# User overridable mail options
EmailFrequency => {
Section => 'Mail', #loc
Overridable => 1,
Default => 'Individual messages',
Widget => '/Widgets/Form/Select',
WidgetArguments => {
Description => 'Email delivery', #loc
Values => [
'Individual messages', #loc
'Daily digest', #loc
'Weekly digest', #loc
'Suspended' #loc
]
}
},
NotifyActor => {
Section => 'Mail', #loc
Overridable => 1,
SortOrder => 2,
Widget => '/Widgets/Form/Boolean',
WidgetArguments => {
Description => 'Outgoing mail', #loc
Hints => 'Should RT send you mail for ticket updates you make?', #loc
}
},
# this tends to break extensions that stash links in ticket update pages
Organization => {
Type => 'SCALAR',
Immutable => 1,
Widget => '/Widgets/Form/String',
PostLoadCheck => sub {
my ($self,$value) = @_;
$RT::Logger->error("your \$Organization setting ($value) appears to contain whitespace. Please fix this.")
if $value =~ /\s/;;
},
},
rtname => {
Immutable => 1,
Widget => '/Widgets/Form/String',
},
# Internal config options
DatabaseExtraDSN => {
Type => 'HASH',
Immutable => 1,
},
DatabaseAdmin => {
Immutable => 1,
Widget => '/Widgets/Form/String',
},
DatabaseHost => {
Immutable => 1,
Widget => '/Widgets/Form/String',
},
DatabaseName => {
Immutable => 1,
Widget => '/Widgets/Form/String',
},
DatabasePassword => {
Immutable => 1,
Widget => '/Widgets/Form/String',
Obfuscate => sub {
my ($config, $sources, $user) = @_;
return $user->loc('Password not printed');
},
},
DatabasePort => {
Immutable => 1,
Widget => '/Widgets/Form/Integer',
},
DatabaseRTHost => {
Immutable => 1,
Widget => '/Widgets/Form/String',
},
DatabaseType => {
Immutable => 1,
Widget => '/Widgets/Form/String',
},
DatabaseUser => {
Immutable => 1,
Widget => '/Widgets/Form/String',
},
FullTextSearch => {
Type => 'HASH',
PostLoadCheck => sub {
my $self = shift;
my $v = $self->Get('FullTextSearch');
return unless $v->{Enable} and $v->{Indexed};
my $dbtype = $self->Get('DatabaseType');
if ($dbtype eq 'Oracle') {
if (not $v->{IndexName}) {
$RT::Logger->error("No IndexName set for full-text index; disabling");
$v->{Enable} = $v->{Indexed} = 0;
}
} elsif ($dbtype eq 'Pg') {
my $bad = 0;
if (not $v->{'Column'}) {
$RT::Logger->error("No Column set for full-text index; disabling");
$v->{Enable} = $v->{Indexed} = 0;
} elsif ($v->{'Column'} eq "Content"
and (not $v->{'Table'} or $v->{'Table'} eq "Attachments")) {
$RT::Logger->error("Column for full-text index is set to Content, not tsvector column; disabling");
$v->{Enable} = $v->{Indexed} = 0;
}
} elsif ($dbtype eq 'mysql') {
if (not $v->{'Table'}) {
$RT::Logger->error("No Table set for full-text index; disabling");
$v->{Enable} = $v->{Indexed} = 0;
} elsif ($v->{'Table'} eq "Attachments") {
$RT::Logger->error("Table for full-text index is set to Attachments, not FTS table; disabling");
$v->{Enable} = $v->{Indexed} = 0;
} else {
my (undef, $create) = eval { $RT::Handle->dbh->selectrow_array("SHOW CREATE TABLE " . $v->{Table}); };
my ($engine) = ($create||'') =~ /engine=(\S+)/i;
if (not $create) {
$RT::Logger->error("External table ".$v->{Table}." does not exist");
$v->{Enable} = $v->{Indexed} = 0;
} elsif (lc $engine eq "sphinx") {
# External Sphinx indexer
$v->{Sphinx} = 1;
unless ($v->{'MaxMatches'}) {
$RT::Logger->warn("No MaxMatches set for full-text index; defaulting to 10000");
$v->{MaxMatches} = 10_000;
}
} else {
# Internal, one-column table
$v->{Column} = 'Content';
$v->{Engine} = $engine;
}
}
} else {
$RT::Logger->error("Indexed full-text-search not supported for $dbtype");
$v->{Indexed} = 0;
}
},
},
DisableGraphViz => {
Type => 'SCALAR',
Widget => '/Widgets/Form/Boolean',
PostLoadCheck => sub {
my $self = shift;
my $value = shift;
return if $value;
return if RT::StaticUtil::RequireModule("GraphViz2");
$RT::Logger->debug("You've enabled GraphViz, but we couldn't load the module: $@");
$self->Set( DisableGraphViz => 1 );
},
},
DisableGD => {
Type => 'SCALAR',
Widget => '/Widgets/Form/Boolean',
PostLoadCheck => sub {
my $self = shift;
my $value = shift;
return if $value;
return if RT::StaticUtil::RequireModule("GD");
$RT::Logger->debug("You've enabled GD, but we couldn't load the module: $@");
$self->Set( DisableGD => 1 );
},
},
MailCommand => {
Type => 'SCALAR',
Widget => '/Widgets/Form/String',
PostLoadCheck => sub {
my $self = shift;
my $value = $self->Get('MailCommand');
return if ref($value) eq "CODE"
or $value =~/^(sendmail|sendmailpipe|qmail|testfile|mbox)$/;
$RT::Logger->error("Unknown value for \$MailCommand: $value; defaulting to sendmailpipe");
$self->Set( MailCommand => 'sendmailpipe' );
},
},
HTMLFormatter => {
Type => 'SCALAR',
Widget => '/Widgets/Form/String',
PostLoadCheck => sub { RT::Interface::Email->_HTMLFormatter },
},
Plugins => {
Immutable => 1,
},
RecordBaseClass => {
Immutable => 1,
Widget => '/Widgets/Form/String',
},
WebSessionClass => {
Immutable => 1,
Widget => '/Widgets/Form/String',
},
DevelMode => {
Immutable => 1,
Widget => '/Widgets/Form/Boolean',
PostLoadCheck => sub {
my $self = shift;
if ( $self->Get('DevelMode') and $self->Get('WebSecureCookies') ) {
RT->Logger->debug('If you are doing RT development and running a dev server, disabling the $WebSecureCookies option will allow cookies to work without setting up SSL.');
}
},
},
DisallowExecuteCode => {
Immutable => 1,
Widget => '/Widgets/Form/Boolean',
},
MailPlugins => {
Type => 'ARRAY',
Immutable => 1,
PostLoadCheck => sub {
my $self = shift;
# Make sure Crypt is post-loaded first
$META{Crypt}{'PostLoadCheck'}->( $self, $self->Get( 'Crypt' ) );
RT::Interface::Email::Plugins(Add => ["Authz::Default", "Action::Defaults"]);
RT::Interface::Email::Plugins(Add => ["Auth::MailFrom"])
unless RT::Interface::Email::Plugins(Code => 1, Method => "GetCurrentUser");
},
},
Crypt => {
Immutable => 1,
Invisible => 1,
Type => 'HASH',
PostLoadCheck => sub {
my $self = shift;
require RT::Crypt;
for my $proto (RT::Crypt->EnabledProtocols) {
my $opt = $self->Get($proto);
if (not RT::Crypt->LoadImplementation($proto)) {
$RT::Logger->error("You enabled $proto, but we couldn't load module RT::Crypt::$proto");
$opt->{'Enable'} = 0;
} elsif (not RT::Crypt->LoadImplementation($proto)->Probe) {
$opt->{'Enable'} = 0;
} elsif ($META{$proto}{'PostLoadCheck'}) {
$META{$proto}{'PostLoadCheck'}->( $self, $self->Get( $proto ) );
}
}
my $opt = $self->Get('Crypt');
my @enabled = RT::Crypt->EnabledProtocols;
my %enabled;
$enabled{$_} = 1 for @enabled;
$opt->{'Enable'} = scalar @enabled;
$opt->{'Incoming'} = [ $opt->{'Incoming'} ]
if $opt->{'Incoming'} and not ref $opt->{'Incoming'};
if ( $opt->{'Incoming'} && @{ $opt->{'Incoming'} } ) {
$RT::Logger->warning("$_ explicitly set as incoming Crypt plugin, but not marked Enabled; removing")
for grep {not $enabled{$_}} @{$opt->{'Incoming'}};
$opt->{'Incoming'} = [ grep {$enabled{$_}} @{$opt->{'Incoming'}} ];
} else {
$opt->{'Incoming'} = \@enabled;
}
if ( $opt->{'Outgoing'} ) {
if (ref($opt->{'Outgoing'}) eq 'HASH') {
# Check each entry in the hash
foreach my $q (keys(%{$opt->{'Outgoing'}})) {
if (not $enabled{$opt->{'Outgoing'}->{$q}}) {
if ($q ne '') {
$RT::Logger->warning($opt->{'Outgoing'}->{$q}.
" explicitly set as outgoing Crypt plugin for queue $q, but not marked Enabled; "
. (@enabled ? "using $enabled[0]" : "removing"));
} else {
$RT::Logger->warning($opt->{'Outgoing'}->{$q}.
" explicitly set as default outgoing Crypt plugin, but not marked Enabled; "
. (@enabled ? "using $enabled[0]" : "removing"));
}
$opt->{'Outgoing'}->{$q} = $enabled[0];
}
}
# If there's no entry for the default queue, set one
if (!$opt->{'Outgoing'}->{''} && scalar(@enabled)) {
$RT::Logger->warning("No default outgoing Crypt plugin set; using $enabled[0]");
$opt->{'Outgoing'}->{''} = $enabled[0];
}
} else {
if (not $enabled{$opt->{'Outgoing'}}) {
$RT::Logger->warning($opt->{'Outgoing'}.
" explicitly set as outgoing Crypt plugin, but not marked Enabled; "
. (@enabled ? "using $enabled[0]" : "removing"));
}
$opt->{'Outgoing'} = $enabled[0] unless $enabled{$opt->{'Outgoing'}};
}
} else {
$opt->{'Outgoing'} = $enabled[0];
}
},
},
SMIME => {
Type => 'HASH',
Immutable => 1,
Invisible => 1,
Obfuscate => sub {
my ( $config, $value, $user ) = @_;
$value->{Passphrase} = $user->loc('Password not printed');
return $value;
},