[Bps-public-commit] rt-extension-configindatabase branch, master, updated. 45cfca5482a75d8e39eed5576edfba8acdbbc45b
Shawn Moore
shawn at bestpractical.com
Thu Aug 3 18:58:40 EDT 2017
The branch, master has been updated
via 45cfca5482a75d8e39eed5576edfba8acdbbc45b (commit)
via 9cd5538fb44b520544ea436802ec8168f6b54fa1 (commit)
via 3d21c1713662294a025ac8c1f07c80aa7002135f (commit)
via e9d505d5fe853eb7f377e767809ff3eafd5437b5 (commit)
via b8ff77fd780b495370e1c989028587db92e9c61e (commit)
via 954203523770dfadeb60c329591d510a7108db35 (commit)
via 37615a1b4f000621f9eb562943c8d38a71292269 (commit)
via d22bf4dc280b55c2de904de87a42730ef07e283a (commit)
via 6bf1cb0078232ebf6a7c392463be070e12452e78 (commit)
via 34891214c60ca378f589fc58b619d673fed4ca78 (commit)
via cedbfecb337afc1f293729040a205f58e67381c1 (commit)
via 10e5392e73a171bc5f8897a1854d5a5c6181e70a (commit)
via ae24a507afc6c944ba8e393547748399c7dde52b (commit)
via 62a7fbeb84a8d5db2a5c793baa5b3223840da7cd (commit)
via e2e200e0f8cd8566d0e6fc6488b3492594ba1b8d (commit)
from 8ca2c139e13a8e92b763d7f054df4808dad1382f (commit)
Summary of changes:
META.yml | 2 +
etc/schema.Oracle | 2 +
etc/schema.Pg | 2 +
etc/schema.SQLite | 2 +
etc/schema.mysql | 2 +
html/Admin/Tools/EditConfig.html | 131 +++++++++++++++++++++++++++++++++++
lib/RT/DatabaseSetting.pm | 68 +++++++++++++++++-
lib/RT/DatabaseSettings.pm | 2 +
lib/RT/Extension/ConfigInDatabase.pm | 70 +++++++++++++++++++
static/css/config-in-database.css | 6 ++
10 files changed, 285 insertions(+), 2 deletions(-)
create mode 100644 html/Admin/Tools/EditConfig.html
create mode 100644 static/css/config-in-database.css
- Log -----------------------------------------------------------------
commit e2e200e0f8cd8566d0e6fc6488b3492594ba1b8d
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Aug 3 20:22:51 2017 +0000
Add Disabled column
diff --git a/etc/schema.Oracle b/etc/schema.Oracle
index e50d7f9..ea37dce 100644
--- a/etc/schema.Oracle
+++ b/etc/schema.Oracle
@@ -4,6 +4,7 @@ CREATE TABLE RTxDatabaseSettings (
Name VARCHAR2(255) CONSTRAINT RTxDatabaseSettings_Name_Unique unique NOT NULL,
Content CLOB,
ContentType VARCHAR2(80),
+ Disabled NUMBER(11,0) DEFAULT 0 NOT NULL,
Creator NUMBER(11,0) DEFAULT 0 NOT NULL,
Created DATE,
LastUpdatedBy NUMBER(11,0) DEFAULT 0 NOT NULL,
@@ -11,4 +12,5 @@ CREATE TABLE RTxDatabaseSettings (
);
CREATE UNIQUE INDEX RTxDatabaseSettings1 ON RTxDatabaseSettings (LOWER(Name));
+CREATE INDEX RTxDatabaseSettings2 ON RTxDatabaseSettings (Disabled);
diff --git a/etc/schema.Pg b/etc/schema.Pg
index f837d2a..4ae963e 100644
--- a/etc/schema.Pg
+++ b/etc/schema.Pg
@@ -4,6 +4,7 @@ CREATE TABLE RTxDatabaseSettings (
Name varchar(255) NOT NULL,
Content text NULL,
ContentType varchar(80) NULL,
+ Disabled integer NOT NULL DEFAULT 0 ,
Creator integer NOT NULL DEFAULT 0,
Created timestamp DEFAULT NULL,
LastUpdatedBy integer NOT NULL DEFAULT 0,
@@ -12,4 +13,5 @@ CREATE TABLE RTxDatabaseSettings (
);
CREATE UNIQUE INDEX RTxDatabaseSettings1 ON RTxDatabaseSettings (LOWER(Name));
+CREATE INDEX RTxDatabaseSettings2 ON RTxDatabaseSettings (Disabled);
diff --git a/etc/schema.SQLite b/etc/schema.SQLite
index bce40c2..56f6349 100644
--- a/etc/schema.SQLite
+++ b/etc/schema.SQLite
@@ -3,6 +3,7 @@ CREATE TABLE RTxDatabaseSettings (
Name varchar(255) collate NOCASE NOT NULL,
Content longtext collate NOCASE NULL,
ContentType varchar(80) collate NOCASE NULL,
+ Disabled int2 NOT NULL DEFAULT 0,
Creator int(11) NOT NULL DEFAULT 0,
Created timestamp DEFAULT NULL,
LastUpdatedBy int(11) NOT NULL DEFAULT 0,
@@ -10,4 +11,5 @@ CREATE TABLE RTxDatabaseSettings (
);
CREATE UNIQUE INDEX RTxDatabaseSettings1 ON RTxDatabaseSettings (Name);
+CREATE INDEX RTxDatabaseSettings2 ON RTxDatabaseSettings (Disabled);
diff --git a/etc/schema.mysql b/etc/schema.mysql
index 55bd178..fea1fd8 100644
--- a/etc/schema.mysql
+++ b/etc/schema.mysql
@@ -3,6 +3,7 @@ CREATE TABLE RTxDatabaseSettings (
Name varchar(255) NOT NULL,
Content longblob NULL,
ContentType varchar(80) CHARACTER SET ascii NULL,
+ Disabled int2 NOT NULL DEFAULT 0,
Creator int(11) NOT NULL DEFAULT 0,
Created datetime DEFAULT NULL,
LastUpdatedBy int(11) NOT NULL DEFAULT 0,
@@ -11,4 +12,5 @@ CREATE TABLE RTxDatabaseSettings (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE UNIQUE INDEX RTxDatabaseSettings1 ON RTxDatabaseSettings (Name);
+CREATE UNIQUE INDEX RTxDatabaseSettings2 ON RTxDatabaseSettings (Disabled);
diff --git a/lib/RT/DatabaseSetting.pm b/lib/RT/DatabaseSetting.pm
index bf5e4fa..8c1ae96 100644
--- a/lib/RT/DatabaseSetting.pm
+++ b/lib/RT/DatabaseSetting.pm
@@ -261,6 +261,7 @@ sub _CoreAccessible {
Name => { read => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varchar(255)', default => ''},
Content => { read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'blob', default => ''},
ContentType => { read => 1, write => 1, sql_type => 12, length => 16, is_blob => 0, is_numeric => 0, type => 'varchar(16)', default => ''},
+ Disabled => { read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
Creator => { read => 1, type => 'int(11)', default => '0', auto => 1 },
Created => { read => 1, type => 'datetime', default => '', auto => 1 },
LastUpdatedBy => { read => 1, type => 'int(11)', default => '0', auto => 1 },
diff --git a/lib/RT/DatabaseSettings.pm b/lib/RT/DatabaseSettings.pm
index 01f65ce..3f02eac 100644
--- a/lib/RT/DatabaseSettings.pm
+++ b/lib/RT/DatabaseSettings.pm
@@ -24,6 +24,8 @@ Sets default ordering by id ascending.
sub _Init {
my $self = shift;
+ $self->{'with_disabled_column'} = 1;
+
$self->OrderBy( FIELD => 'id', ORDER => 'ASC' );
return $self->SUPER::_Init( @_ );
}
commit 62a7fbeb84a8d5db2a5c793baa5b3223840da7cd
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Aug 3 21:06:25 2017 +0000
Form for editing all editable system config
diff --git a/META.yml b/META.yml
index 92771bc..9a1328e 100644
--- a/META.yml
+++ b/META.yml
@@ -17,6 +17,7 @@ name: RT-Extension-ConfigInDatabase
no_index:
directory:
- etc
+ - html
- inc
requires:
perl: 5.10.1
diff --git a/html/Admin/Tools/EditConfig.html b/html/Admin/Tools/EditConfig.html
new file mode 100644
index 0000000..c5eeaef
--- /dev/null
+++ b/html/Admin/Tools/EditConfig.html
@@ -0,0 +1,59 @@
+<%INIT>
+my $title = loc('System Configuration');
+unless ($session{'CurrentUser'}->HasRight( Object=> $RT::System, Right => 'SuperUser')) {
+ Abort(loc('This feature is only available to system administrators'));
+}
+
+use Data::Dumper;
+
+sub stringify {
+ my $value = shift;
+ return "" if !defined($value);
+
+ local $Data::Dumper::Terse = 1;
+ local $Data::Dumper::Indent = 2;
+ my $output = Dumper $value;
+ chomp $output;
+ return $output;
+}
+
+</%INIT>
+<& /Admin/Elements/Header, Title => $title &>
+<& /Elements/Tabs &>
+
+<form method="post" action="EditConfig.html">
+<&|/Widgets/TitleBox, title => loc("RT Configuration") &>
+<table border="0" cellspacing="0" cellpadding="5" width="100%" class="collection">
+<tr class="collection-as-table">
+<th class="collection-as-table"><&|/l&>Option</&></th>
+<th class="collection-as-table"><&|/l&>Value</&></th>
+</tr>
+<%PERL>
+my $index_conf;
+foreach my $key ( RT->Config->Options( Overridable => undef, Sorted => 0 ) ) {
+ my $meta = RT->Config->Meta( $key );
+ my $raw_value = RT->Config->Get( $key, $session{'CurrentUser'} );
+ my $val = stringify($raw_value);
+
+ $index_conf++;
+
+</%PERL>
+<tr class="<% $index_conf%2 ? 'oddline' : 'evenline'%>">
+<td class="collection-as-table"><% $key %></td>
+<td class="collection-as-table">
+% if ( $meta->{Obfuscate} || ($key =~ /Password/i and $key !~ /MinimumPasswordLength|AllowLoginPasswordAutoComplete/ )) {
+<em><% loc('Must modify in config file' ) %></em>\
+% } else {
+% my $rows = 1;
+% $rows += scalar @{[ $val =~ /\n/g ]}; # each newline adds a row
+% $rows += scalar @{[ $val =~ /.{79}/g ]}; # each very long line adds a row, e.g. UserSearchResultFormat
+% $rows++ if $rows > 1; # buffer
+% $rows = 6 if $rows > 6;
+<textarea name="<% $key %>" cols="80" rows="<% $rows %>"><% $val %></textarea>
+% }
+</td>
+</tr>
+% }
+</table>
+</&>
+</form>
commit ae24a507afc6c944ba8e393547748399c7dde52b
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Aug 3 21:07:12 2017 +0000
Implement immutable options
diff --git a/html/Admin/Tools/EditConfig.html b/html/Admin/Tools/EditConfig.html
index c5eeaef..4c2d515 100644
--- a/html/Admin/Tools/EditConfig.html
+++ b/html/Admin/Tools/EditConfig.html
@@ -41,7 +41,7 @@ foreach my $key ( RT->Config->Options( Overridable => undef, Sorted => 0 ) ) {
<tr class="<% $index_conf%2 ? 'oddline' : 'evenline'%>">
<td class="collection-as-table"><% $key %></td>
<td class="collection-as-table">
-% if ( $meta->{Obfuscate} || ($key =~ /Password/i and $key !~ /MinimumPasswordLength|AllowLoginPasswordAutoComplete/ )) {
+% if ( $meta->{Immutable} || $meta->{Obfuscate} || ($key =~ /Password/i and $key !~ /MinimumPasswordLength|AllowLoginPasswordAutoComplete/ )) {
<em><% loc('Must modify in config file' ) %></em>\
% } else {
% my $rows = 1;
diff --git a/lib/RT/Extension/ConfigInDatabase.pm b/lib/RT/Extension/ConfigInDatabase.pm
index 8d1e0cc..adecf34 100644
--- a/lib/RT/Extension/ConfigInDatabase.pm
+++ b/lib/RT/Extension/ConfigInDatabase.pm
@@ -6,6 +6,27 @@ use RT::DatabaseSettings;
our $VERSION = '0.01';
+for (qw/DatabaseAdmin DatabaseExtraDSN DatabaseHost DatabaseName
+ DatabasePassword DatabasePort DatabaseRTHost DatabaseType
+ DatabaseUser
+
+ WebBaseURL WebDomain WebPath WebPort WebURL
+
+ Organization rtname Plugins MailPlugins
+
+ RecordBaseClass WebSessionClass DevelMode
+
+ ExternalAuthPriority ExternalInfoPriority
+ ExternalSettings/) {
+ next if !$RT::Config::META{$_};
+
+ $RT::Config::META{$_}{Immutable} = 1;
+}
+
+# special case due to being autovivified from other options
+$RT::Config::META{ExternalAuth}{Immutable} = 1
+ if RT::Handle::cmp_version($RT::VERSION, '4.4.0') >= 0;
+
__PACKAGE__->LoadConfigFromDatabase();
sub LoadConfigFromDatabase {
commit 10e5392e73a171bc5f8897a1854d5a5c6181e70a
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Aug 3 21:08:56 2017 +0000
Use a widget if we have it
diff --git a/html/Admin/Tools/EditConfig.html b/html/Admin/Tools/EditConfig.html
index 4c2d515..20a10e9 100644
--- a/html/Admin/Tools/EditConfig.html
+++ b/html/Admin/Tools/EditConfig.html
@@ -43,6 +43,19 @@ foreach my $key ( RT->Config->Options( Overridable => undef, Sorted => 0 ) ) {
<td class="collection-as-table">
% if ( $meta->{Immutable} || $meta->{Obfuscate} || ($key =~ /Password/i and $key !~ /MinimumPasswordLength|AllowLoginPasswordAutoComplete/ )) {
<em><% loc('Must modify in config file' ) %></em>\
+% } elsif ($meta->{Widget}) {
+ <& $meta->{'Widget'},
+ Default => 1,
+ DefaultValue => '',
+ DefaultLabel => '(no value)',
+
+ %{ $m->comp('/Widgets/FinalizeWidgetArguments', WidgetArguments =>
+ $meta->{'WidgetArguments'} ) },
+ Name => $key,
+ CurrentValue => $raw_value,
+ Description => '',
+ Hints => '',
+ &>
% } else {
% my $rows = 1;
% $rows += scalar @{[ $val =~ /\n/g ]}; # each newline adds a row
commit cedbfecb337afc1f293729040a205f58e67381c1
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Aug 3 21:14:41 2017 +0000
Fix unnecessary padding
diff --git a/META.yml b/META.yml
index 9a1328e..5b9aae1 100644
--- a/META.yml
+++ b/META.yml
@@ -19,6 +19,7 @@ no_index:
- etc
- html
- inc
+ - static
requires:
perl: 5.10.1
resources:
diff --git a/lib/RT/Extension/ConfigInDatabase.pm b/lib/RT/Extension/ConfigInDatabase.pm
index adecf34..037a96f 100644
--- a/lib/RT/Extension/ConfigInDatabase.pm
+++ b/lib/RT/Extension/ConfigInDatabase.pm
@@ -6,6 +6,8 @@ use RT::DatabaseSettings;
our $VERSION = '0.01';
+RT->AddStyleSheets("config-in-database.css");
+
for (qw/DatabaseAdmin DatabaseExtraDSN DatabaseHost DatabaseName
DatabasePassword DatabasePort DatabaseRTHost DatabaseType
DatabaseUser
diff --git a/static/css/config-in-database.css b/static/css/config-in-database.css
new file mode 100644
index 0000000..3ce92e7
--- /dev/null
+++ b/static/css/config-in-database.css
@@ -0,0 +1,6 @@
+/* remove unnecessary left padding for radio options */
+body#comp-Admin-Tools-EditConfig div.widget .label {
+ width: auto;
+ float: none;
+}
+
commit 34891214c60ca378f589fc58b619d673fed4ca78
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Aug 3 21:35:43 2017 +0000
Use consistent textarea input widget for integers
The integer widget is just a textbox as of 4.4.2, not worth the
inconsistency
diff --git a/html/Admin/Tools/EditConfig.html b/html/Admin/Tools/EditConfig.html
index 20a10e9..05409b5 100644
--- a/html/Admin/Tools/EditConfig.html
+++ b/html/Admin/Tools/EditConfig.html
@@ -43,7 +43,7 @@ foreach my $key ( RT->Config->Options( Overridable => undef, Sorted => 0 ) ) {
<td class="collection-as-table">
% if ( $meta->{Immutable} || $meta->{Obfuscate} || ($key =~ /Password/i and $key !~ /MinimumPasswordLength|AllowLoginPasswordAutoComplete/ )) {
<em><% loc('Must modify in config file' ) %></em>\
-% } elsif ($meta->{Widget}) {
+% } elsif ($meta->{Widget} && $meta->{Widget} ne '/Widgets/Form/Integer') {
<& $meta->{'Widget'},
Default => 1,
DefaultValue => '',
commit 6bf1cb0078232ebf6a7c392463be070e12452e78
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Aug 3 21:37:35 2017 +0000
Flag many core variables as booleans
These have never been UI-editable before, so we never bothered to give
them a Widget; only user preferences had them
diff --git a/lib/RT/Extension/ConfigInDatabase.pm b/lib/RT/Extension/ConfigInDatabase.pm
index 037a96f..8779792 100644
--- a/lib/RT/Extension/ConfigInDatabase.pm
+++ b/lib/RT/Extension/ConfigInDatabase.pm
@@ -29,6 +29,41 @@ for (qw/DatabaseAdmin DatabaseExtraDSN DatabaseHost DatabaseName
$RT::Config::META{ExternalAuth}{Immutable} = 1
if RT::Handle::cmp_version($RT::VERSION, '4.4.0') >= 0;
+for (qw/AllowUserAutocompleteForUnprivileged AlwaysDownloadAttachments
+ AmbiguousDayInFuture AmbiguousDayInPast ApprovalRejectionNotes
+ ArticleOnTicketCreate AutocompleteOwnersForSearch
+ CanonicalizeRedirectURLs CanonicalizeURLsInFeeds
+ ChartsTimezonesInDB CheckMoreMSMailHeaders DateDayBeforeMonth
+ DisableGD DisableGraphViz DisallowExecuteCode
+ DontSearchFileAttachments DropLongAttachments
+ EditCustomFieldsSingleColumn EnableReminders
+ ExternalStorageDirectLink ForceApprovalsView ForwardFromUser
+ Framebusting HideArticleSearchOnReplyCreate
+ HideResolveActionsWithDependencies
+ HideTimeFieldsFromUnprivilegedUsers LoopsToRTOwner
+ MessageBoxIncludeSignature MessageBoxIncludeSignatureOnComment
+ OnlySearchActiveTicketsInSimpleSearch ParseNewMessageForTicketCcs
+ PreferDateTimeFormatNatural PreviewScripMessages RecordOutgoingEmail
+ RestrictLoginReferrer RestrictReferrer SearchResultsAutoRedirect
+ ShowBccHeader ShowMoreAboutPrivilegedUsers ShowRTPortal
+ ShowRemoteImages ShowTransactionImages StoreLoops StrictLinkACL
+ SuppressInlineTextFiles TruncateLongAttachments
+ TrustHTMLAttachments UseFriendlyFromLine UseFriendlyToLine
+ UseOriginatorHeader UseSQLForACLChecks UseTransactionBatch
+ ValidateUserEmailAddresses WebFallbackToRTLogin
+ WebFlushDbCacheEveryRequest WebHttpOnlyCookies WebRemoteUserAuth
+ WebRemoteUserAutocreate WebRemoteUserContinuous WebRemoteUserGecos
+ WebSecureCookies WikiImplicitLinks
+
+ HideOneTimeSuggestions LinkArticlesOnInclude
+ MessageBoxUseSystemContextMenu
+ SelfServiceCorrespondenceOnly ShowSearchResultCount/) {
+ next if !$RT::Config::META{$_};
+
+ $RT::Config::META{$_}{Widget} = '/Widgets/Form/Boolean';
+ $RT::Config::META{$_}{WidgetArguments} = {};
+}
+
__PACKAGE__->LoadConfigFromDatabase();
sub LoadConfigFromDatabase {
commit d22bf4dc280b55c2de904de87a42730ef07e283a
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Aug 3 21:38:11 2017 +0000
Add dropdown for the several log level conf options
diff --git a/lib/RT/Extension/ConfigInDatabase.pm b/lib/RT/Extension/ConfigInDatabase.pm
index 8779792..3728b7b 100644
--- a/lib/RT/Extension/ConfigInDatabase.pm
+++ b/lib/RT/Extension/ConfigInDatabase.pm
@@ -64,6 +64,15 @@ for (qw/AllowUserAutocompleteForUnprivileged AlwaysDownloadAttachments
$RT::Config::META{$_}{WidgetArguments} = {};
}
+for (qw/LogToSyslog LogToSTDERR LogToFile LogStackTraces StatementLog/) {
+ next if !$RT::Config::META{$_};
+
+ $RT::Config::META{$_}{Widget} = '/Widgets/Form/Select';
+ $RT::Config::META{$_}{WidgetArguments}{Values} = [qw(
+ debug info notice warning error critical alert emergency
+ )];
+}
+
__PACKAGE__->LoadConfigFromDatabase();
sub LoadConfigFromDatabase {
commit 37615a1b4f000621f9eb562943c8d38a71292269
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Aug 3 21:38:24 2017 +0000
Don't show RestrictReferrerLogin
The option is named RestrictLoginReferrer; RestrictReferrerLogin is
provided simply for its PostLoadCheck to warn users about the incorrect
spelling
diff --git a/html/Admin/Tools/EditConfig.html b/html/Admin/Tools/EditConfig.html
index 05409b5..2a13f26 100644
--- a/html/Admin/Tools/EditConfig.html
+++ b/html/Admin/Tools/EditConfig.html
@@ -32,6 +32,9 @@ sub stringify {
my $index_conf;
foreach my $key ( RT->Config->Options( Overridable => undef, Sorted => 0 ) ) {
my $meta = RT->Config->Meta( $key );
+
+ next if $meta->{Invisible};
+
my $raw_value = RT->Config->Get( $key, $session{'CurrentUser'} );
my $val = stringify($raw_value);
diff --git a/lib/RT/Extension/ConfigInDatabase.pm b/lib/RT/Extension/ConfigInDatabase.pm
index 3728b7b..b18c7f8 100644
--- a/lib/RT/Extension/ConfigInDatabase.pm
+++ b/lib/RT/Extension/ConfigInDatabase.pm
@@ -73,6 +73,9 @@ for (qw/LogToSyslog LogToSTDERR LogToFile LogStackTraces StatementLog/) {
)];
}
+# special case due to being only for PostLoadCheck
+$RT::Config::META{RestrictReferrerLogin}{Invisible} = 1;
+
__PACKAGE__->LoadConfigFromDatabase();
sub LoadConfigFromDatabase {
commit 954203523770dfadeb60c329591d510a7108db35
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Aug 3 21:47:11 2017 +0000
Link to web docs
This is not ideal; better would be to have the docs available
right within the page. However there's no easy way to extract them from
RT_Config.pm
diff --git a/html/Admin/Tools/EditConfig.html b/html/Admin/Tools/EditConfig.html
index 2a13f26..00aa690 100644
--- a/html/Admin/Tools/EditConfig.html
+++ b/html/Admin/Tools/EditConfig.html
@@ -4,8 +4,11 @@ unless ($session{'CurrentUser'}->HasRight( Object=> $RT::System, Right => 'Super
Abort(loc('This feature is only available to system administrators'));
}
-use Data::Dumper;
+my $doc_version = $RT::VERSION;
+$doc_version =~ s/rc\d+//; # 4.4.2rc1 -> 4.4.2
+$doc_version =~ s/\.\d+-\d+-g\w+$//; # 4.4.3-1-g123 -> 4.4
+use Data::Dumper;
sub stringify {
my $value = shift;
return "" if !defined($value);
@@ -40,9 +43,11 @@ foreach my $key ( RT->Config->Options( Overridable => undef, Sorted => 0 ) ) {
$index_conf++;
+ my $doc_url = "https://docs.bestpractical.com/rt/$doc_version/RT_Config.html#$key";
+
</%PERL>
<tr class="<% $index_conf%2 ? 'oddline' : 'evenline'%>">
-<td class="collection-as-table"><% $key %></td>
+<td class="collection-as-table"><a href="<% $doc_url %>" target="_blank"><% $key %></a></td>
<td class="collection-as-table">
% if ( $meta->{Immutable} || $meta->{Obfuscate} || ($key =~ /Password/i and $key !~ /MinimumPasswordLength|AllowLoginPasswordAutoComplete/ )) {
<em><% loc('Must modify in config file' ) %></em>\
commit b8ff77fd780b495370e1c989028587db92e9c61e
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Aug 3 22:19:28 2017 +0000
Add a hook for linking to other pages to edit config
e.g. for lifecycles, SLA, etc we'd want a more elaborate UI
diff --git a/html/Admin/Tools/EditConfig.html b/html/Admin/Tools/EditConfig.html
index 00aa690..4597f60 100644
--- a/html/Admin/Tools/EditConfig.html
+++ b/html/Admin/Tools/EditConfig.html
@@ -49,7 +49,9 @@ foreach my $key ( RT->Config->Options( Overridable => undef, Sorted => 0 ) ) {
<tr class="<% $index_conf%2 ? 'oddline' : 'evenline'%>">
<td class="collection-as-table"><a href="<% $doc_url %>" target="_blank"><% $key %></a></td>
<td class="collection-as-table">
-% if ( $meta->{Immutable} || $meta->{Obfuscate} || ($key =~ /Password/i and $key !~ /MinimumPasswordLength|AllowLoginPasswordAutoComplete/ )) {
+% if ( $meta->{EditLink} ) {
+<&|/l_unsafe, "<a href=\"$meta->{EditLink}\">", loc($meta->{EditLinkLabel}), "</a>" &>Visit [_1][_2][_3] to manage this setting</&>
+% } elsif ( $meta->{Immutable} || $meta->{Obfuscate} || ($key =~ /Password/i and $key !~ /MinimumPasswordLength|AllowLoginPasswordAutoComplete/ )) {
<em><% loc('Must modify in config file' ) %></em>\
% } elsif ($meta->{Widget} && $meta->{Widget} ne '/Widgets/Form/Integer') {
<& $meta->{'Widget'},
commit e9d505d5fe853eb7f377e767809ff3eafd5437b5
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Aug 3 22:39:10 2017 +0000
Create or update DatabaseSettings on form submit
diff --git a/html/Admin/Tools/EditConfig.html b/html/Admin/Tools/EditConfig.html
index 4597f60..7409e9c 100644
--- a/html/Admin/Tools/EditConfig.html
+++ b/html/Admin/Tools/EditConfig.html
@@ -4,6 +4,8 @@ unless ($session{'CurrentUser'}->HasRight( Object=> $RT::System, Right => 'Super
Abort(loc('This feature is only available to system administrators'));
}
+my @results;
+
my $doc_version = $RT::VERSION;
$doc_version =~ s/rc\d+//; # 4.4.2rc1 -> 4.4.2
$doc_version =~ s/\.\d+-\d+-g\w+$//; # 4.4.3-1-g123 -> 4.4
@@ -20,11 +22,55 @@ sub stringify {
return $output;
}
+if (delete $ARGS{Update}) {
+ $RT::Handle->BeginTransaction;
+ my $has_error;
+
+ for my $key (keys %ARGS) {
+ next if $key =~ /-Current$/;
+ my $val = $ARGS{$key};
+ $val = '' if $val eq '__empty_value__';
+ my $prev = $ARGS{$key . '-Current'};
+ next if $val eq $prev;
+
+ my $setting = RT::DatabaseSetting->new($session{CurrentUser});
+ $setting->Load($key);
+ if ($setting->Id) {
+ if ($setting->Disabled) {
+ $setting->SetDisabled(0);
+ }
+
+ my ($ok, $msg) = $setting->SetContent($val);
+ push @results, $msg;
+ $has_error++ if !$ok;
+ }
+ else {
+ my ($ok, $msg) = $setting->Create(
+ Name => $key,
+ Content => $val,
+ );
+ push @results, $msg;
+ $has_error++ if !$ok;
+ }
+ }
+
+ if ($has_error) {
+ push @results, loc("No changes made.");
+ $RT::Handle->Rollback;
+ }
+ else {
+ $RT::Handle->Commit;
+ }
+}
+
</%INIT>
<& /Admin/Elements/Header, Title => $title &>
<& /Elements/Tabs &>
+<& /Elements/ListActions, actions => \@results &>
<form method="post" action="EditConfig.html">
+<input type="hidden" name="Update" value=1></input>
+
<&|/Widgets/TitleBox, title => loc("RT Configuration") &>
<table border="0" cellspacing="0" cellpadding="5" width="100%" class="collection">
<tr class="collection-as-table">
@@ -66,6 +112,7 @@ foreach my $key ( RT->Config->Options( Overridable => undef, Sorted => 0 ) ) {
Description => '',
Hints => '',
&>
+<input type="hidden" name="<% $key %>-Current" value="<% $raw_value %>"></input>
% } else {
% my $rows = 1;
% $rows += scalar @{[ $val =~ /\n/g ]}; # each newline adds a row
@@ -73,10 +120,12 @@ foreach my $key ( RT->Config->Options( Overridable => undef, Sorted => 0 ) ) {
% $rows++ if $rows > 1; # buffer
% $rows = 6 if $rows > 6;
<textarea name="<% $key %>" cols="80" rows="<% $rows %>"><% $val %></textarea>
+<textarea name="<% $key %>-Current" class="hidden"><% $val %></textarea>
% }
</td>
</tr>
% }
</table>
</&>
+<& /Elements/Submit, Label => loc('Save Changes') &>
</form>
commit 3d21c1713662294a025ac8c1f07c80aa7002135f
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Aug 3 22:52:46 2017 +0000
Implement SetContent
This will refresh server settings and provide a useful update message
diff --git a/lib/RT/DatabaseSetting.pm b/lib/RT/DatabaseSetting.pm
index 8c1ae96..3e0078f 100644
--- a/lib/RT/DatabaseSetting.pm
+++ b/lib/RT/DatabaseSetting.pm
@@ -190,6 +190,54 @@ sub Content {
return $content;
}
+=head2 SetContent
+
+=cut
+
+sub SetContent {
+ my $self = shift;
+ my $value = shift;
+ my $content_type = shift || '';
+
+ my $old_value = $self->Content;
+ unless (defined($old_value) && length($old_value)) {
+ $old_value = $self->loc('(no value)');
+ }
+
+ if (ref $value) {
+ $value = $self->_SerializeContent($value);
+ if (!$value) {
+ return (0, $@);
+ }
+ $content_type = 'storable';
+ }
+
+ $RT::Handle->BeginTransaction;
+
+ my ($ok, $msg) = $self->_Set( Field => 'Content', Value => $value );
+ if (!$ok) {
+ $RT::Handle->Rollback;
+ return ($ok, $self->loc("Unable to update [_1]: [_2]", $self->Name, $msg));
+ }
+
+ if ($self->ContentType ne $content_type) {
+ ($ok, $msg) = $self->_Set( Field => 'ContentType', Value => $content_type );
+ if (!$ok) {
+ $RT::Handle->Rollback;
+ return ($ok, $self->loc("Unable to update [_1]: [_2]", $self->Name, $msg));
+ }
+ }
+
+ $RT::Handle->Commit;
+ RT::Extension::ConfigInDatabase->ApplyConfigChangeToAllServerProcesses;
+
+ unless (defined($value) && length($value)) {
+ $value = $self->loc('(no value)');
+ }
+
+ return ($ok, $self->loc("[_1] changed from [_2] to [_3]", $self->Name, $old_value, $value));
+}
+
=head1 PRIVATE METHODS
Documented for internal use only, do not call these from outside
commit 9cd5538fb44b520544ea436802ec8168f6b54fa1
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Aug 3 22:53:32 2017 +0000
Improve messaging from DatabaseSetting->Create
diff --git a/lib/RT/DatabaseSetting.pm b/lib/RT/DatabaseSetting.pm
index 3e0078f..f3fced0 100644
--- a/lib/RT/DatabaseSetting.pm
+++ b/lib/RT/DatabaseSetting.pm
@@ -71,17 +71,27 @@ sub Create {
$args{'ContentType'} = 'storable';
}
+ my $old_value = RT->Config->Get($args{Name});
+ unless (defined($old_value) && length($old_value)) {
+ $old_value = $self->loc('(no value)');
+ }
+
( $id, $msg ) = $self->SUPER::Create(
map { $_ => $args{$_} } grep {exists $args{$_}}
qw(Name Content ContentType),
);
unless ($id) {
- return (0, $self->loc("Database setting create failed: [_1]", $msg));
+ return (0, $self->loc("Setting [_1] to [_2] failed: [_3]", $args{Name}, $args{Content}, $msg));
}
RT::Extension::ConfigInDatabase->ApplyConfigChangeToAllServerProcesses;
- return ($id, $self->loc('Database setting created'));
+ my $content = $self->Content;
+ unless (defined($content) && length($content)) {
+ $content = $self->loc('(no value)');
+ }
+
+ return ($id, $self->loc("[_1] changed from [_2] to [_3]", $self->Name, $old_value, $content));
}
=head2 CurrentUserCanSee
commit 45cfca5482a75d8e39eed5576edfba8acdbbc45b
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Aug 3 22:55:46 2017 +0000
Forbid creating DatabaseSettings for immutable settings
diff --git a/lib/RT/DatabaseSetting.pm b/lib/RT/DatabaseSetting.pm
index f3fced0..974a011 100644
--- a/lib/RT/DatabaseSetting.pm
+++ b/lib/RT/DatabaseSetting.pm
@@ -63,6 +63,11 @@ sub Create {
my ( $id, $msg ) = $self->ValidateName( $args{'Name'} );
return ( 0, $msg ) unless $id;
+ my $meta = RT->Config->Meta($args{'Name'});
+ if ($meta->{Immutable}) {
+ return ( 0, $self->loc("You cannot update [_1] using database config; you must edit your site config", $args{'Name'}) );
+ }
+
if (ref ($args{'Content'}) ) {
$args{'Content'} = $self->_SerializeContent($args{'Content'});
if (!$args{'Content'}) {
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list