[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.7-960-gb7b86fe

Jesse Vincent jesse at bestpractical.com
Mon Dec 20 19:13:03 EST 2010


The branch, 3.9-trunk has been updated
       via  b7b86fea30a33cae2894ac09455c94bd04666821 (commit)
       via  d87fbc66217452072ff16d708951278cb2cec525 (commit)
       via  e1758162d3d2a56bcbec852f4b163fb3b97f5d7c (commit)
      from  d70f8b30ab6b3114aaaeef3830d21c552ccfaace (commit)

Summary of changes:
 lib/RT.pm                               |   19 ++++++++++++++++++-
 lib/RT/Interface/Email/Auth/MailFrom.pm |    3 +--
 lib/RT/Interface/Web.pm                 |    7 ++++---
 lib/RT/User_Overlay.pm                  |    4 +---
 lib/RT/Users_Overlay.pm                 |   16 ++--------------
 share/html/Elements/Tabs                |   18 +++++++++---------
 6 files changed, 35 insertions(+), 32 deletions(-)

- Log -----------------------------------------------------------------
commit e1758162d3d2a56bcbec852f4b163fb3b97f5d7c
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Mon Dec 20 18:02:44 2010 -0500

    precache the user's system rights, saving 8 SQL queries per page

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index b7aa9f4..1bf2efd 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -460,6 +460,9 @@ sub ShowRequestedPage {
 
     my $m = $HTML::Mason::Commands::m;
 
+    # precache all system level rights for the current user
+    $HTML::Mason::Commands::session{CurrentUser}->PrincipalObj->HasRights( Object => RT->System );
+
     InitializeMenu();
 
     SendSessionCookie();

commit d87fbc66217452072ff16d708951278cb2cec525
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Mon Dec 20 18:03:22 2010 -0500

    correct calls from $RT::System to RT->System

diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 05a91cc..045e77b 100755
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -120,16 +120,16 @@ if ( $request_path !~ m{^/SelfService/} ) {
     $tools->child( offline => title => loc('Offline'), path    => '/Tools/Offline.html', sort_order => 10,
                    description => loc('Create tickets offline') );
 
-    if ( $session{'CurrentUser'}->HasRight( Right => 'ShowApprovalsTab', Object => $RT::System ) )
+    if ( $session{'CurrentUser'}->HasRight( Right => 'ShowApprovalsTab', Object => RT->System ) )
     {
         $tools->child( approval => title => loc('Approval'), path     => '/Approvals/', sort_order=> 3,
                        description => loc('My Approvals') );
     }
 
-    if ( $session{'CurrentUser'}->HasRight( Right => 'ShowConfigTab', Object => $RT::System ) )
+    if ( $session{'CurrentUser'}->HasRight( Right => 'ShowConfigTab', Object => RT->System ) )
     {
         my $admin = $tools->child( config => title => loc('Configuration'), path   => '/Admin/', sort_order => 1 );
-        if ( $session{'CurrentUser'}->HasRight( Object => $RT::System, Right => 'AdminUsers' ) ) {
+        if ( $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'AdminUsers' ) ) {
             my $users = $admin->child( users => title => loc('Users'), path => '/Admin/Users/', description => loc('Manage users and passwords') );
             $users->child( select => title => loc('Select'), path   => "/Admin/Users/" );
             $users->child( create => title => loc('Create'), path => "/Admin/Users/Modify.html?Create=1" );
@@ -143,7 +143,7 @@ if ( $request_path !~ m{^/SelfService/} ) {
         $queues->child( select => title => loc('Select'), path => "/Admin/Queues/" );
         $queues->child( create => title => loc('Create'), path => "/Admin/Queues/Modify.html?Create=1" );
 
-        if ( $session{'CurrentUser'}->HasRight( Object => $RT::System, Right => 'AdminCustomField' ) ) {
+        if ( $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'AdminCustomField' ) ) {
             my $cfs = $admin->child( 'custom-fields' => title => loc('Custom Fields'), path => '/Admin/CustomFields/', description => loc('Manage custom fields and custom field values') );
             $cfs->child( select => title => loc('Select'), path   => "/Admin/CustomFields/" );
             $cfs->child( create => title => loc('Create'), path => "/Admin/CustomFields/Modify.html?Create=1" );
@@ -208,7 +208,7 @@ if ( $request_path !~ m{^/SelfService/} ) {
         $admin_tools->child( configuration => title => loc('System Configuration'), path => '/Admin/Tools/Configuration.html',
                              description => loc('Detailed information about your RT setup') );
         if (RT->Config->Get('StatementLog')
-            && $session{'CurrentUser'}->HasRight( Right => 'SuperUser', Object => $RT::System )) {
+            && $session{'CurrentUser'}->HasRight( Right => 'SuperUser', Object => RT->System )) {
            $admin_tools->child( 'sql-queries' => title => loc('SQL Queries'), path => '/Admin/Tools/Queries.html',
                                 description => loc('Browse the SQL queries made in this process') );
         }
@@ -224,7 +224,7 @@ if ( $request_path !~ m{^/SelfService/} ) {
 
 
     if ( $session{'CurrentUser'}->UserObj
-         && $session{'CurrentUser'}->HasRight( Right  => 'ModifySelf', Object => $RT::System )) {
+         && $session{'CurrentUser'}->HasRight( Right  => 'ModifySelf', Object => RT->System )) {
         my $settings = $about_me->child( settings => title => loc('Settings'), path => '/Prefs/Other.html', );
         $settings->child( options => title => loc('Options'), path     => '/Prefs/Other.html', );
         $settings->child( about_me => title => loc('About me'), path     => '/User/Prefs.html', );
@@ -636,7 +636,7 @@ if ( $request_path !~ m{^/SelfService/} ) {
 
             if ($request_path =~ m{^/Search/Results.html}
                 &&                        #XXX TODO better abstraction
-                $session{'CurrentUser'}->HasRight( Right => 'SuperUser', Object => $RT::System )) {
+                $session{'CurrentUser'}->HasRight( Right => 'SuperUser', Object => RT->System )) {
                 my $shred_args = $query_string->(
                     search          => 1,
                     plugin          => 'Tickets',
@@ -727,7 +727,7 @@ if ( $request_path =~ m{^/SelfService} ) {
                     sort_order   => 99
     );
 
-    if ( $session{'CurrentUser'}->HasRight( Right => 'ModifySelf', Object => $RT::System ) ) {
+    if ( $session{'CurrentUser'}->HasRight( Right => 'ModifySelf', Object => RT->System ) ) {
         $about_me->child( prefs => title => loc('Preferences'), path  => '/SelfService/Prefs.html' );
     }
 
@@ -737,7 +737,7 @@ if ( $request_path =~ m{^/SelfService} ) {
         $about_me->child( logout => title => loc('Logout'), path   => '/NoAuth/Logout.html' );
     }
 
-    if ($session{'CurrentUser'}->HasRight( Right => 'ShowArticle', Object => $RT::System )) {
+    if ($session{'CurrentUser'}->HasRight( Right => 'ShowArticle', Object => RT->System )) {
         PageWidgets->child( 'goto-article' => raw_html => $m->scomp('/SelfService/Elements/SearchArticle') );
     }
 

commit b7b86fea30a33cae2894ac09455c94bd04666821
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Mon Dec 20 19:11:36 2010 -0500

    Privileged and Unprivileged groups should change about as often as
    SystemUser and Nobody. cache them in the RT process

diff --git a/lib/RT.pm b/lib/RT.pm
index 0d5c823..47725ba 100755
--- a/lib/RT.pm
+++ b/lib/RT.pm
@@ -55,7 +55,7 @@ package RT;
 use File::Spec ();
 use Cwd ();
 
-use vars qw($Config $System $SystemUser $Nobody $Handle $Logger $_INSTALL_MODE);
+use vars qw($Config $System $SystemUser $Nobody $Handle $Logger $_Privileged $_Unprivileged $_INSTALL_MODE);
 
 use vars qw($BasePath
  $EtcPath
@@ -550,6 +550,23 @@ also L</InitSystemObjects>.
 
 sub Nobody { return $Nobody }
 
+sub PrivilegedUsers {
+    if (!$_Privileged) {
+    $_Privileged = RT::Group->new(RT->SystemUser);
+    $_Privileged->LoadSystemInternalGroup('Privileged');
+    }
+    return $_Privileged;
+}
+
+sub UnprivilegedUsers {
+    if (!$_Unprivileged) {
+    $_Unprivileged = RT::Group->new(RT->SystemUser);
+    $_Unprivileged->LoadSystemInternalGroup('Unprivileged');
+    }
+    return $_Unprivileged;
+}
+
+
 =head2 Plugins
 
 Returns a listref of all Plugins currently configured for this RT instance.
diff --git a/lib/RT/Interface/Email/Auth/MailFrom.pm b/lib/RT/Interface/Email/Auth/MailFrom.pm
index d483202..a15f746 100755
--- a/lib/RT/Interface/Email/Auth/MailFrom.pm
+++ b/lib/RT/Interface/Email/Auth/MailFrom.pm
@@ -77,8 +77,7 @@ sub GetCurrentUser {
     }
 
     # If the user can't be loaded, we may need to create one. Figure out the acl situation.
-    my $unpriv = RT::Group->new( RT->SystemUser );
-    $unpriv->LoadSystemInternalGroup('Unprivileged');
+    my $unpriv = RT->UnprivilegedUsers();
     unless ( $unpriv->Id ) {
         $RT::Logger->crit("Couldn't find the 'Unprivileged' internal group");
         return ( $args{'CurrentUser'}, -1 );
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 1bf2efd..6774779 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -2475,9 +2475,7 @@ sub GetPrincipalsMap {
             ];
         }
         elsif (/Users/) {
-            my $Privileged = RT::Group->new($session{'CurrentUser'});
-            $Privileged->LoadSystemInternalGroup('Privileged');
-            my $Users = $Privileged->UserMembersObj();
+            my $Users = RT->PrivilegedUsers->UserMembersObj();
             $Users->OrderBy( FIELD => 'Name', ORDER => 'ASC' );
 
             # Only show users who have rights granted on this object
diff --git a/lib/RT/User_Overlay.pm b/lib/RT/User_Overlay.pm
index d7ef799..6b95929 100755
--- a/lib/RT/User_Overlay.pm
+++ b/lib/RT/User_Overlay.pm
@@ -367,9 +367,7 @@ Returns true if this user is privileged. Returns undef otherwise.
 
 sub Privileged {
     my $self = shift;
-    my $priv = RT::Group->new($self->CurrentUser);
-    $priv->LoadSystemInternalGroup('Privileged');
-    if ( $priv->HasMember( $self->PrincipalId ) ) {
+    if ( RT->PrivilegedUsers->HasMember( $self->id ) ) {
         return(1);
     } else {
         return(undef);
diff --git a/lib/RT/Users_Overlay.pm b/lib/RT/Users_Overlay.pm
index 5db7770..62b654a 100755
--- a/lib/RT/Users_Overlay.pm
+++ b/lib/RT/Users_Overlay.pm
@@ -200,13 +200,7 @@ Limits to users who can be made members of ACLs and groups
 
 sub LimitToPrivileged {
     my $self = shift;
-
-    my $priv = RT::Group->new( $self->CurrentUser );
-    $priv->LoadSystemInternalGroup('Privileged');
-    unless ( $priv->Id ) {
-        $RT::Logger->crit("Couldn't find a privileged users group");
-    }
-    $self->MemberOfGroup( $priv->PrincipalId );
+    $self->MemberOfGroup( RT->PrivilegedUsers->id );
 }
 
 =head2 LimitToUnprivileged
@@ -217,13 +211,7 @@ Limits to unprivileged users only
 
 sub LimitToUnprivileged {
     my $self = shift;
-
-    my $unpriv = RT::Group->new( $self->CurrentUser );
-    $unpriv->LoadSystemInternalGroup('Unprivileged');
-    unless ( $unpriv->Id ) {
-        $RT::Logger->crit("Couldn't find an 'Unprivileged' users group");
-    }
-    $self->MemberOfGroup( $unpriv->PrincipalId );
+    $self->MemberOfGroup( RT->UnprivilegedUsers->id);
 }
 
 

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


More information about the Rt-commit mailing list