[Rt-commit] rt branch, new-style-templates, updated. rt-3.8.8-278-gd503fa7

Shawn Moore sartak at bestpractical.com
Thu Aug 5 16:46:10 EDT 2010


The branch, new-style-templates has been updated
       via  d503fa73a8ad6298cef625daa308236841392e42 (commit)
       via  0a594dff384c4f87ba4a48d01ce4a771f49d9e41 (commit)
       via  5de7c6062e11f6c4ee2c514839f6fc3b41ca9cc3 (commit)
       via  c695ebe8a7a1b247970c3a55c591e6e010456c79 (commit)
       via  5b706d871e9a41c3c9951e4ae9aebd82d0f7e63b (commit)
       via  f6101c638f3495b673817ea216c798f962130c69 (commit)
       via  93c8dccfb6f40ed2214f766e18a3101c2c09238c (commit)
       via  7942a451c0dd15820877d87c8f8ca6960e5cebf3 (commit)
       via  385b1a77248ca96169beae3a30ed3c60442611c1 (commit)
       via  d4fe09c49ec6377fb183754d76e09d3d480d5799 (commit)
       via  5602a094a9e3ba434283e69b589f6d2328dd80cf (commit)
       via  0c028fac9c4b4ee9566a9984df1f89c0f2422d08 (commit)
       via  e8c92bd2c9f3c12fa1207f660c1cf8af84e7d8fa (commit)
       via  c73df98e53258766f25ae49fee44c9176037d484 (commit)
       via  dfe8018c8af543ab3b4399195810c7f2eaacbd0e (commit)
       via  e469eb1419f1e440669206c1a26ae692cba6c489 (commit)
       via  605565b99070caa311c418011e673c296e856d53 (commit)
       via  1a3e1651dbcf0ae972f53bff9015e963fe7e2efa (commit)
       via  1c33536b4b71951770acabdb9776288830e31935 (commit)
      from  8332e02f58374ec41419dd33d3f22194d89c45da (commit)

Summary of changes:
 lib/RT/Handle.pm                                   |    4 +
 lib/RT/System.pm                                   |    1 +
 lib/RT/Template_Overlay.pm                         |   19 ++-
 lib/RT/Templates_Overlay.pm                        |    3 +-
 lib/RT/User_Overlay.pm                             |    6 +
 sbin/rt-setup-database.in                          |   26 +++-
 share/html/Elements/EditCustomFieldSelect          |    2 +-
 share/html/Elements/Header                         |   10 +-
 share/html/Elements/ShowLinks                      |   37 ++++-
 share/html/NoAuth/css/3.4-compat/main.css          |    2 +
 share/html/NoAuth/css/3.4-compat/misc.css          |    1 -
 share/html/NoAuth/css/3.5-default/main.css         |    2 +
 share/html/NoAuth/css/3.5-default/misc.css         |    1 -
 .../NoAuth/css/{web2/tools.css => base/main.css}   |   10 +-
 share/html/NoAuth/css/base/misc.css                |   13 +-
 share/html/NoAuth/css/base/ticket-update.css       |   32 ++++
 share/html/NoAuth/css/web2/main.css                |    2 +
 share/html/NoAuth/css/web2/misc.css                |    1 -
 share/html/Search/Bulk.html                        |   15 +--
 share/html/SelfService/Update.html                 |   23 +---
 share/html/Ticket/Create.html                      |   24 +---
 share/html/Ticket/Elements/AddAttachments          |   14 ++
 share/html/Ticket/Elements/EditBasics              |  156 ++++++++++----------
 .../Ticket/Elements/EditTransactionCustomFields    |    6 +-
 share/html/Ticket/Elements/PreviewScrips           |    2 +-
 share/html/Ticket/Elements/ShowSummary             |   13 +-
 share/html/Ticket/Elements/Tabs                    |   31 ++--
 share/html/Ticket/ModifyAll.html                   |   18 +--
 share/html/Ticket/Update.html                      |   98 +++++++------
 29 files changed, 322 insertions(+), 250 deletions(-)
 copy share/html/NoAuth/css/{web2/tools.css => base/main.css} (94%)
 create mode 100644 share/html/NoAuth/css/base/ticket-update.css
 create mode 100644 share/html/Ticket/Elements/AddAttachments

- Log -----------------------------------------------------------------
commit d503fa73a8ad6298cef625daa308236841392e42
Merge: 8332e02 0a594df
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Thu Aug 5 16:47:57 2010 -0400

    Merge branch '3.9-trunk' into new-style-templates
    
    Conflicts:
    	lib/RT/Template_Overlay.pm
        - just a spurious "added methods to the same place" conflict

diff --cc lib/RT/System.pm
index 910b122,b519428..f58eced
--- a/lib/RT/System.pm
+++ b/lib/RT/System.pm
@@@ -87,9 -87,9 +87,10 @@@ our $RIGHTS = 
        "Delegate specific rights which have been granted to you.",     # loc_pair
      ShowConfigTab => "show Configuration tab",     # loc_pair
      ShowApprovalsTab => "show Approvals tab",     # loc_pair
+     ShowGlobalTemplates => "show global templates",     # loc_pair
      LoadSavedSearch => "allow loading of saved searches",     # loc_pair
      CreateSavedSearch => "allow creation of saved searches",      # loc_pair
 +    ExecuteCode => "allow writing Perl code in templates, scrips, etc", # loc_pair
  };
  
  # Tell RT::ACE that this sort of object can get acls granted
diff --cc lib/RT/Template_Overlay.pm
index e26538b,4f28a3c..3ff2879
--- a/lib/RT/Template_Overlay.pm
+++ b/lib/RT/Template_Overlay.pm
@@@ -593,69 -470,20 +593,84 @@@ sub CurrentUserHasQueueRight 
      return ( $self->QueueObj->CurrentUserHasRight(@_) );
  }
  
 +=head2 SetType
 +
 +If setting Type to Perl, require the ExecuteCode right.
 +
 +=cut
 +
 +sub SetType {
 +    my $self    = shift;
 +    my $NewType = shift;
 +
 +    if ($NewType eq 'Perl' && !$self->CurrentUser->HasRight(Right => 'ExecuteCode', Object => $RT::System)) {
 +        return ( undef, $self->loc('Permission Denied') );
 +    }
 +
 +    return $self->_Set( Field => 'Type', Value => $NewType );
 +}
 +
 +=head2 CompileCheck
 +
 +If the template's Type is Perl, then compile check all the codeblocks to see if
 +they are syntactically valid. We eval them in a codeblock to avoid actually
 +executing the code.
 +
 +Returns an (ok, message) pair.
 +
 +=cut
 +
 +sub CompileCheck {
 +    my $self = shift;
 +
 +    return (1, $self->loc("Template does not include Perl code"))
 +        unless $self->Type eq 'Perl';
 +
 +    my $content = $self->Content;
 +    $content = '' if !defined($content);
 +
 +    my $template = Text::Template->new(
 +        TYPE   => 'STRING',
 +        SOURCE => $content,
 +    );
 +    $template->compile;
 +
 +    # copied from Text::Template::fill_in and refactored to be compile checks
 +    foreach my $fi_item (@{$template->{SOURCE}}) {
 +        my ($fi_type, $fi_text, $fi_lineno) = @$fi_item;
 +        next unless $fi_type eq 'PROG';
 +
 +        do {
 +            no strict 'vars';
 +            eval "sub { $fi_text }";
 +        };
 +        next if !$@;
 +
 +        my $error = $@;
 +
 +        # provide a (hopefully) useful line number for the error, but clean up
 +        # all the other extraneous garbage
 +        $error =~ s/\(eval \d+\) line (\d+).*/"template line " . ($1+$fi_lineno-1)/es;
 +
 +        return (0, $self->loc("Couldn't compile template codeblock '[_1]': [_2]", $fi_text, $error));
 +    }
 +
 +    return (1, $self->loc("Template compiles"));
 +}
 +
+ =head2 CurrentUserCanRead
+ 
+ =cut
+ 
+ sub CurrentUserCanRead {
+     my $self =shift;
+ 
+     return 1 if $self->CurrentUserHasQueueRight('ShowTemplate');
+ 
+     return $self->CurrentUser->HasRight( Right =>'ShowGlobalTemplates', Object => $RT::System )
+         if !$self->QueueObj->Id;
+ 
+     return;
+ }
+ 
 -
  1;

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


More information about the Rt-commit mailing list