[Rt-commit] rt branch, master, updated. rt-4.1.8-493-gfb240a8

Thomas Sibley trs at bestpractical.com
Fri May 24 22:32:34 EDT 2013


The branch, master has been updated
       via  fb240a8aee2979660ab840c91b65d73c891de041 (commit)
       via  672cafb30917b937319422fce350828c14f82887 (commit)
       via  abf15b97a8d4bb7c3fe701a13881ac0eed0fb987 (commit)
       via  a1e97e060e300177b3f666f7b4f5129d6e04a303 (commit)
       via  d645bf558917c649506e526003c0abe960a9113f (commit)
       via  3d566af7d7f451e9bbf6c9cd308a5d17a0c5dc4c (commit)
       via  bab8ef2e81ede6a51eba564a9e09831e2ed37928 (commit)
       via  2348440f769204e9cb7d70f1388b9e9cdd5b1092 (commit)
      from  25110b4850349f070a41cf376d8d38d25a7be548 (commit)

Summary of changes:
 lib/RT.pm                                   |   2 +-
 lib/RT/ACE.pm                               |  17 +--
 lib/RT/Article.pm                           |  19 ---
 lib/RT/Class.pm                             | 115 ++-------------
 lib/RT/CustomField.pm                       |  86 +----------
 lib/RT/Dashboard.pm                         |  39 ++---
 lib/RT/Group.pm                             | 135 ++----------------
 lib/RT/Interface/Web.pm                     |   4 +-
 lib/RT/Lifecycle.pm                         |  35 +----
 lib/RT/Lifecycle/Ticket.pm                  |  21 +++
 lib/RT/Queue.pm                             | 213 +++++-----------------------
 lib/RT/Record.pm                            |  31 ++++
 lib/RT/{Plugin.pm => Record/Role/Rights.pm} | 108 +++++++-------
 lib/RT/Scrip.pm                             |  48 +------
 lib/RT/System.pm                            | 164 ++++++---------------
 lib/RT/Ticket.pm                            |  57 --------
 lib/RT/Topic.pm                             |  39 +----
 lib/RT/Transaction.pm                       |  17 ---
 t/api/group-rights.t                        |   2 +-
 t/api/groups.t                              |   2 +-
 t/api/system.t                              |   2 +-
 t/api/users.t                               |   2 +-
 22 files changed, 257 insertions(+), 901 deletions(-)
 copy lib/RT/{Plugin.pm => Record/Role/Rights.pm} (58%)

- Log -----------------------------------------------------------------
commit fb240a8aee2979660ab840c91b65d73c891de041
Merge: 25110b4 672cafb
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri May 24 19:26:03 2013 -0700

    Merge branch '4.2/rights-api'
    
    Conflicts:
    	lib/RT/System.pm
            $principal->Type → $principal->Name for role groups

diff --cc lib/RT/Lifecycle.pm
index b15a039,a31c394..2ff7caa
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@@ -782,8 -655,29 +757,12 @@@ sub FillCache 
              push @{ $LIFECYCLES_TYPES{$type}{''} },
                  @{ $LIFECYCLES_TYPES{$type}{$category} } if $category;
          }
+ 
+         my $class = "RT::Lifecycle::".ucfirst($type);
+         $class->RegisterRights if $class->require
+             and $class->can("RegisterRights");
      }
  
 -    foreach my $lifecycle ( values %LIFECYCLES_CACHE ) {
 -        my @res;
 -        if ( ref $lifecycle->{'actions'} eq 'HASH' ) {
 -            foreach my $k ( sort keys %{ $lifecycle->{'actions'} } ) {
 -                push @res, $k, $lifecycle->{'actions'}{ $k };
 -            }
 -        } elsif ( ref $lifecycle->{'actions'} eq 'ARRAY' ) {
 -            @res = @{ $lifecycle->{'actions'} };
 -        }
 -
 -        my @tmp = splice @res;
 -        while ( my ($transition, $info) = splice @tmp, 0, 2 ) {
 -            my ($from, $to) = split /\s*->\s*/, $transition, 2;
 -            push @res, { %$info, from => $from, to => $to };
 -        }
 -        $lifecycle->{'actions'} = \@res;
 -    }
      return;
  }
  
diff --cc lib/RT/System.pm
index e8143fa,3493a7a..c4ccf23
--- a/lib/RT/System.pm
+++ b/lib/RT/System.pm
@@@ -130,58 -107,27 +107,27 @@@ types to which the role group doesn't a
  =cut
  
  sub AvailableRights {
-     my $self        = shift;
-     my $principal   = shift;
-     my @types       = keys %RT::ACE::OBJECT_TYPES;
- 
-     # Include global system rights by default
-     my %rights = %{ $RIGHTS };
+     my $self = shift;
+     my $principal = shift;
+     my $class = ref($self) || $self;
  
-     # Only return rights on classes which support the role asked for
+     my @rights;
      if ($principal and $principal->IsRoleGroup) {
 -        my $role = $principal->Object->Type;
 +        my $role = $principal->Object->Name;
-         @types   = grep { $_->DOES('RT::Record::Role::Roles') and $_->HasRole($role) } @types;
-         %rights  = ();
+         for my $class (keys %RT::ACE::RIGHTS) {
+             next unless $class->DOES('RT::Record::Role::Roles') and $class->HasRole($role);
+             push @rights, values %{ $RT::ACE::RIGHTS{$class} };
+         }
+     } else {
+         @rights = map {values %{$_}} values %RT::ACE::RIGHTS;
      }
  
-     # Build a merged list of system wide rights, queue rights, group rights, etc.
-     %rights = (
-         %rights,
-         %{ $self->_ForACEObjectTypes(\@types => 'AvailableRights', @_) },
-     );
-     delete $rights{ExecuteCode} if RT->Config->Get('DisallowExecuteCode');
- 
-     return(\%rights);
- }
- 
- sub _ForACEObjectTypes {
-     my $self   = shift;
-     my $types  = shift || [];
-     my $method = shift;
-     return {} unless @$types and $method;
+     my %rights;
+     $rights{$_->{Name}} = $_->{Description} for @rights;
  
-     my %data;
-     for my $class (sort @$types) {
-         next unless $RT::ACE::OBJECT_TYPES{$class};
- 
-         # Skip ourselves otherwise we'd loop infinitely
-         next if $class eq 'RT::System';
- 
-         my $object = $class->new(RT->SystemUser);
- 
-         unless ($object->can($method)) {
-             RT->Logger->error("RT::ACE object type $class doesn't support the $method method! Skipping.");
-             next;
-         }
- 
-         # embrace and extend
-         %data = (
-             %data,
-             %{ $object->$method(@_) || {} },
-         );
-     }
+     delete $rights{ExecuteCode} if RT->Config->Get('DisallowExecuteCode');
  
-     return \%data;
+     return \%rights;
  }
  
  =head2 RightCategories

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


More information about the Rt-commit mailing list