[Rt-commit] r18972 - in rt/3.999/trunk: lib/RT/Model share/html/Admin/Queues

ruz at bestpractical.com ruz at bestpractical.com
Fri Mar 27 19:47:22 EDT 2009


Author: ruz
Date: Fri Mar 27 19:47:22 2009
New Revision: 18972

Modified:
   rt/3.999/trunk/lib/RT/Model/GroupCollection.pm
   rt/3.999/trunk/share/html/Admin/Global/GroupRights.html
   rt/3.999/trunk/share/html/Admin/Queues/GroupRights.html

Log:
* use limit_to_roles

Modified: rt/3.999/trunk/lib/RT/Model/GroupCollection.pm
==============================================================================
--- rt/3.999/trunk/lib/RT/Model/GroupCollection.pm	(original)
+++ rt/3.999/trunk/lib/RT/Model/GroupCollection.pm	Fri Mar 27 19:47:22 2009
@@ -77,12 +77,6 @@
 
 use RT::Model::UserCollection;
 
-# XXX: below some code is marked as subject to generalize in Groups, Users classes.
-# RUZ suggest name Principals::Generic or Principals::Base as abstract class, but
-# Jesse wants something that doesn't imply it's a Principals.pm subclass.
-# See comments below for candidats.
-
-
 sub implicit_clauses {
     my $self = shift;
     $self->order_by(
@@ -137,6 +131,9 @@
 
 =over 4
 
+=item object - an object roles of which should be looked, replaces the following
+two arguments;
+
 =item model - mandatory name of a model, for example: 'RT::Model::Ticket';
 
 =item instance - optional id of the model record;
@@ -159,6 +156,9 @@
         subclause        => 'limit_to_roles',
         @_
     );
+    @args{'model', 'instance'} = (ref $args{'object'}, $args{'object'}->id)
+        if $args{'object'};
+
     $self->open_paren( $args{'subclause'} );
     $self->limit(
         subclause        => $args{'subclause'},
@@ -184,60 +184,6 @@
     $self->close_paren( $args{'subclause'} );
 }
 
-=head2 limit_to_roles_for_queue QUEUE_ID
-
-Limits the set of groups found to role groups for queue QUEUE_ID
-
-=cut
-
-sub limit_to_roles_for_queue {
-    my $self  = shift;
-    my $queue = shift;
-    $self->limit(
-        column   => 'domain',
-        operator => '=',
-        value    => 'RT::Model::Queue-Role'
-    );
-    $self->limit( column => 'instance', operator => '=', value => $queue );
-}
-
-
-
-=head2 limit_to_roles_for_ticket Ticket_ID
-
-Limits the set of groups found to role groups for Ticket Ticket_ID
-
-=cut
-
-sub limit_to_roles_for_ticket {
-    my $self   = shift;
-    my $Ticket = shift;
-    $self->limit(
-        column   => 'domain',
-        operator => '=',
-        value    => 'RT::Model::Ticket-Role'
-    );
-    $self->limit( column => 'instance', operator => '=', value => '$Ticket' );
-}
-
-
-
-=head2 limit_to_roles_for_system System_ID
-
-Limits the set of groups found to role groups for System System_ID
-
-=cut
-
-sub limit_to_roles_for_system {
-    my $self = shift;
-    $self->limit(
-        column   => 'domain',
-        operator => '=',
-        value    => 'RT::System-Role'
-    );
-}
-
-
 =head2 with_member {principal => PRINCIPAL_ID, recursively => undef}
 
 Limits the set of groups returned to groups which have

Modified: rt/3.999/trunk/share/html/Admin/Global/GroupRights.html
==============================================================================
--- rt/3.999/trunk/share/html/Admin/Global/GroupRights.html	(original)
+++ rt/3.999/trunk/share/html/Admin/Global/GroupRights.html	Fri Mar 27 19:47:22 2009
@@ -74,7 +74,7 @@
 <h1><&|/l&>Roles</&></h1>
 <table>
 % $Groups = RT::Model::GroupCollection->new( current_user => Jifty->web->current_user );
-% $Groups->limit_to_roles_for_system();
+% $Groups->limit_to_roles( object => RT->system );
 %	while (my $Group = $Groups->next()) {
   <tr align="right"> 
 	<td valign="top">

Modified: rt/3.999/trunk/share/html/Admin/Queues/GroupRights.html
==============================================================================
--- rt/3.999/trunk/share/html/Admin/Queues/GroupRights.html	(original)
+++ rt/3.999/trunk/share/html/Admin/Queues/GroupRights.html	Fri Mar 27 19:47:22 2009
@@ -76,7 +76,7 @@
 <h1><&|/l&>Roles</&></h1>
 <table>
 % $Groups = RT::Model::GroupCollection->new( current_user => Jifty->web->current_user );
-% $Groups->limit_to_roles_for_queue($queue_obj->id);
+% $Groups->limit_to_roles( object => $queue_obj );
 %	while (my $Group = $Groups->next()) {
   <tr align="right"> 
 	<td valign="top">


More information about the Rt-commit mailing list