[Rt-commit] rt branch, 3.999-trunk, updated. 9379fd6a6543d8071a7917650eee8724067087a2

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri Nov 20 02:51:12 EST 2009


The branch, 3.999-trunk has been updated
       via  9379fd6a6543d8071a7917650eee8724067087a2 (commit)
       via  b5928cfb9885531c97f8d8f70817a8b20d752ae9 (commit)
       via  a46c5e6043a2528916ae15d97a42e432908f2598 (commit)
      from  c75254c2c039d21ccc39d097125512b9da2503a0 (commit)

Summary of changes:
 lib/RT/Action/ConfigSystem.pm |   76 +++++++++++++++++++++++++++++++++++++++--
 lib/RT/Config.pod             |    6 ++-
 2 files changed, 77 insertions(+), 5 deletions(-)

- Log -----------------------------------------------------------------
commit a46c5e6043a2528916ae15d97a42e432908f2598
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Nov 20 13:40:25 2009 +0800

    do canonical thing in _canonicalize_arguments

diff --git a/lib/RT/Action/ConfigSystem.pm b/lib/RT/Action/ConfigSystem.pm
index d04b4d5..6cc045d 100644
--- a/lib/RT/Action/ConfigSystem.pm
+++ b/lib/RT/Action/ConfigSystem.pm
@@ -89,11 +89,22 @@ sub take_action {
 
     for my $arg ( $self->argument_names ) {
         if ( $self->has_argument($arg) ) {
+            RT->config->set( $arg, $self->argument_value($arg) );
+        }
+    }
+
+    return 1;
+}
+
+sub _canonicalize_arguments {
+    my $self = shift;
+    for my $arg ( $self->argument_names ) {
+        if ( $self->has_argument($arg) ) {
             my $value = $self->argument_value( $arg );
-            if ($value && $value !~ /^{{\w+}}/ ) {
+            if ( $value && $value !~ /^{{\w+}}/ ) {
                 if ( $value =~ /^\[ \s* (.*?) \s* \]\s*$/x ) {
                     my $v = $1;
-                    if ($v =~ /\S/ ) {
+                    if ( $v =~ /\S/ ) {
                         $value = [ split /\s*,\s*/, $v ];
                     }
                     else {
@@ -109,12 +120,10 @@ sub take_action {
                         $value = {};
                     }
                 }
+                $self->argument_value( $arg, $value );
             }
-
-            RT->config->set( $arg, $value );
         }
     }
-
     return 1;
 }
 

commit b5928cfb9885531c97f8d8f70817a8b20d752ae9
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Nov 20 14:35:06 2009 +0800

    validate organization, gnupg and graphviz in ConfigSystem action

diff --git a/lib/RT/Action/ConfigSystem.pm b/lib/RT/Action/ConfigSystem.pm
index 6cc045d..d177d04 100644
--- a/lib/RT/Action/ConfigSystem.pm
+++ b/lib/RT/Action/ConfigSystem.pm
@@ -4,6 +4,7 @@ use warnings;
 package RT::Action::ConfigSystem;
 use base qw/RT::Action Jifty::Action/;
 use Scalar::Defer; 
+use Try::Tiny;
 
 sub arguments {
     my $self = shift;
@@ -127,6 +128,66 @@ sub _canonicalize_arguments {
     return 1;
 }
 
+sub validate_organization {
+    my $self = shift;
+    my $value = shift;
+    return 1 unless defined $value;
+    if ( $value =~ /\s/ ) {
+        return $self->validation_error(
+            organization => _("Organization cannot contain whitespaces.") );
+    }
+    return 1;
+}
+
+sub validate_gnupg {
+    my $self = shift;
+    my $value = shift;
+    return 1 unless defined $value;
+    if ( ref $value && ref $value eq 'HASH' ) {
+        if ( $value->{enable} ) {
+            my $gpgopts = $self->argument_value('gnupg_options')
+              || RT->config->get('gnupg_options') || {};
+            unless ( -d $gpgopts->{homedir} && -r _ ) {    # no homedir, no gpg
+                return $self->validation_error(
+                    gnupg => _(
+"couldn't successfully read your configured GnuPG home directory: '%1'",
+                        $gpgopts->{homedir}
+                      )
+                );
+            }
+
+            require RT::Crypt::GnuPG;
+            unless ( RT::Crypt::GnuPG::probe() ) {
+                return $self->validation_error(
+                    gnupg => _("couldn't successfully execute gpg") );
+            }
+        }
+    }
+    else {
+        return $self->validation_error(
+            gnupg => _("gnupg value should be a hashref.") );
+    }
+    return 1;
+}
+
+sub validate_disable_graphviz {
+    my $self  = shift;
+    my $value = shift;
+    return 1 unless defined $value;
+
+    try {
+        require IPC::Run;
+        require IPC::Run::SafeHandles;
+        require GraphViz;
+    }
+    catch {
+        return $self->validation_error(
+            disable_graphviz => _( "GraphViz can't be enabled: %1", $_ ) );
+    };
+
+    return 1;
+}
+
 =head2 report_success
 
 =cut

commit 9379fd6a6543d8071a7917650eee8724067087a2
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Nov 20 14:35:18 2009 +0800

    pod update

diff --git a/lib/RT/Config.pod b/lib/RT/Config.pod
index eec2f63..6d5721e 100644
--- a/lib/RT/Config.pod
+++ b/lib/RT/Config.pod
@@ -589,7 +589,7 @@ default: C<0>
 
 =item C<trust_html_attachments>
 
-if C<TrustHTMLAttachments> is not defined, we will display them
+if C<trust_html_attachments> is not defined, we will display them
 as text. This prevents malicious HTML and javascript from being
 sent in a request (although there is probably more to it than that)
 
@@ -711,7 +711,9 @@ default: C<10>
 
 =item C<disable_graphviz>
 
-default: C<undef>
+Disable GraphViz or not
+
+default: C<'0'>
 
 =item C<oldest_transactions_first>
 

-----------------------------------------------------------------------


More information about the Rt-commit mailing list