[Rt-commit] r10310 - in rt/branches/3.7-EXPERIMENTAL: .

ruz at bestpractical.com ruz at bestpractical.com
Sun Jan 13 17:51:50 EST 2008


Author: ruz
Date: Sun Jan 13 17:51:50 2008
New Revision: 10310

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Groups_Overlay.pm

Log:
 r10134 at cubic-pc:  cubic | 2008-01-06 02:19:30 +0300
 ::Groups
 * add WithoutMember method along with WithMember


Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Groups_Overlay.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Groups_Overlay.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Groups_Overlay.pm	Sun Jan 13 17:51:50 2008
@@ -242,8 +242,6 @@
 
 Limits the set of groups returned to groups which have
 Principal PRINCIPAL_ID as a member
-   
-
 
 =cut
 
@@ -265,6 +263,36 @@
     $self->Limit(ALIAS => $members, FIELD => 'MemberId', OPERATOR => '=', VALUE => $args{'PrincipalId'});
 }
 
+sub WithoutMember {
+    my $self = shift;
+    my %args = (
+        PrincipalId => undef,
+        Recursively => undef,
+        @_
+    );
+
+    my $members = $args{'Recursively'} ? 'CachedGroupMembers' : 'GroupMembers';
+    my $members_alias = $self->Join(
+        TYPE   => 'LEFT',
+        FIELD1 => 'id',
+        TABLE2 => $members,
+        FIELD2 => 'GroupId',
+    );
+    $self->Limit(
+        LEFTJOIN => $members_alias,
+        ALIAS    => $members_alias,
+        FIELD    => 'MemberId',
+        OPERATOR => '=',
+        VALUE    => $args{'PrincipalId'},
+    );
+    $self->Limit(
+        ALIAS    => $members_alias,
+        FIELD    => 'MemberId',
+        OPERATOR => 'IS',
+        VALUE    => 'NULL',
+        QUOTEVALUE => 0,
+    );
+}
 
 =head2 WithRight { Right => RIGHTNAME, Object => RT::Record, IncludeSystemRights => 1, IncludeSuperusers => 0, EquivObjects => [ ] }
 


More information about the Rt-commit mailing list