[Rt-commit] rt branch, 3.999-trunk, updated. b64585d696c6cb23491a76f13017520823f9697b
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Tue Nov 24 20:19:31 EST 2009
The branch, 3.999-trunk has been updated
via b64585d696c6cb23491a76f13017520823f9697b (commit)
from a0c5441e54e132b05d111faa023ff65ba632cc86 (commit)
Summary of changes:
etc/initialdata | 4 +-
lib/RT/Action/ConfigSystem.pm | 53 +++++++++++-----------------------------
lib/RT/Config.pod | 4 +-
lib/RT/Model/Config.pm | 9 +------
4 files changed, 20 insertions(+), 50 deletions(-)
- Log -----------------------------------------------------------------
commit b64585d696c6cb23491a76f13017520823f9697b
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Nov 25 09:14:58 2009 +0800
use eval in ConfigSystem action
diff --git a/etc/initialdata b/etc/initialdata
index e695133..32f852a 100755
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -667,12 +667,12 @@ Hour: { $subscription_obj->sub_value('Hour') }
'drop_long_attachments' => undef,
'email_input_encodings' => [ 'utf-8', 'iso-8859-1', 'us-ascii' ],
'email_output_encoding' => 'utf-8',
- 'email_subject_tag_regex' => '{{rtname}}',
+ 'email_subject_tag_regex' => 'example.com',
'enable_reminders' => 1,
'extract_subject_tag_match' => '\[.+? #\d+\]',
'forward_from_user' => 0,
'friendly_from_line_format' => '"%s via RT" <%s>',
- 'friendly_to_line_format' => '"%s of {{rtname}} Ticket #%s":;',
+ 'friendly_to_line_format' => '"%s of example.com Ticket #%s":;',
'full_text_search' => {
enable => 0,
indexed => 0,
diff --git a/lib/RT/Action/ConfigSystem.pm b/lib/RT/Action/ConfigSystem.pm
index bcf84f3..f5dbce7 100644
--- a/lib/RT/Action/ConfigSystem.pm
+++ b/lib/RT/Action/ConfigSystem.pm
@@ -5,6 +5,7 @@ package RT::Action::ConfigSystem;
use base qw/RT::Action Jifty::Action/;
use Scalar::Defer;
use Try::Tiny;
+use Data::Dumper;
sub arguments {
my $self = shift;
@@ -14,26 +15,13 @@ sub arguments {
my $configs = RT::Model::ConfigCollection->new;
$configs->unlimit;
while ( my $config = $configs->next ) {
+ my $value = RT->config->get( $config->name );
$args->{ $config->name } = {
default_value => defer {
- my $value = $config->value;
- $value = ''
- if defined $value && $value eq $config->_empty_string;
- if ( ref $value eq 'ARRAY' ) {
- return '[' . join( ', ', @$value ) . ']';
- }
- elsif ( ref $value eq 'HASH' ) {
- my $str = '{';
- for my $key ( keys %$value ) {
- $str .= qq{$key => $value->{$key},};
- }
- $str .= '}';
- return $str;
- }
- else {
- return $value;
- }
- }
+ local $Data::Dumper::Terse = 1;
+ Dumper $value,
+ },
+ ref $value ? ( render_as => 'textarea' ) : (),
};
}
return $self->{__cached_arguments} = $args;
@@ -102,27 +90,16 @@ sub _canonicalize_arguments {
for my $arg ( $self->argument_names ) {
if ( $self->has_argument($arg) ) {
my $value = $self->argument_value( $arg );
- if ( $value && $value !~ /^{{\w+}}/ ) {
- if ( $value =~ /^\[ \s* (.*?) \s* \]\s*$/x ) {
- my $v = $1;
- if ( $v =~ /\S/ ) {
- $value = [ split /\s*,\s*/, $v ];
- }
- else {
- $value = [];
- }
- }
- elsif ( $value =~ /^{ \s* (.*?) \s* } \s* $/x ) {
- my $pair = $1;
- if ( $pair =~ /\S/ ) {
- $value = { split /\s*(?:,|=>)\s*/, $pair };
- }
- else {
- $value = {};
- }
- }
- $self->argument_value( $arg, $value );
+ next unless defined $value;
+ my $eval = eval $value;
+ if ( $@ ) {
+ return $self->validation_error(
+ $arg => _( "invalid value: %1", $value ) );
+ }
+ else {
+ $value = $eval;
}
+ $self->argument_value( $arg, $value );
}
}
return 1;
diff --git a/lib/RT/Config.pod b/lib/RT/Config.pod
index 6d5721e..c913f92 100644
--- a/lib/RT/Config.pod
+++ b/lib/RT/Config.pod
@@ -35,7 +35,7 @@ C<qr/(example.com|example.org)/i>
This setting would make RT behave exactly as it does without the
setting enabled.
-default: C<'{{rtname}}' >
+default: C<"example.com">
=item C<organization>
@@ -375,7 +375,7 @@ default: C<0>
C<sprintf()> format of the friendly 'From:' header; its arguments
are WatcherType and TicketId.
-default: C<"\"%s of {{rtname}} Ticket #%s\":;">
+default: C<"\"%s of example.com Ticket #%s\":;">
=item C<notify_actor>
diff --git a/lib/RT/Model/Config.pm b/lib/RT/Model/Config.pm
index 281c577..97b0c12 100644
--- a/lib/RT/Model/Config.pm
+++ b/lib/RT/Model/Config.pm
@@ -100,14 +100,7 @@ sub get {
}
}
- my $value = $self->_get( $name );
- if ( defined $value ) {
- $value =~ s/{{(\w+)}}/$self->get($1) || ''/ge if $value && !ref $value;
- return $value;
- }
- else {
- return;
- }
+ return $self->_get( $name );
}
sub set {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list