3 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 # (Except where explictly superceded by other copyright notices)
7 # This work is made available to you under the terms of Version 2 of
8 # the GNU General Public License. A copy of that license should have
9 # been provided with this software, but in any event can be snarfed
12 # This work is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # Unless otherwise specified, all modifications, corrections or
18 # extensions to this work which alter its source code become the
19 # property of Best Practical Solutions, LLC when submitted for
20 # inclusion in the work.
26 RT::CachedGroupMembers - a collection of RT::GroupMember objects
30 use RT::CachedGroupMembers;
40 ok (require RT::CachedGroupMembers);
47 no warnings qw(redefine);
53 Limits this search object to users who are members of this group
54 This is really useful when you want to have your UI separate out
55 groups from users for display purposes
62 my $principals = $self->NewAlias('Principals');
63 $self->Join( ALIAS1 => 'main', FIELD1 => 'MemberId',
64 ALIAS2 => $principals, FIELD2 =>'id');
66 $self->Limit( ALIAS => $principals,
67 FIELD => 'PrincipalType',
69 ENTRYAGGREGATOR => 'OR',
80 Limits this search object to Groups who are members of this group
81 This is really useful when you want to have your UI separate out
82 groups from users for display purposes
89 my $principals = $self->NewAlias('Principals');
90 $self->Join( ALIAS1 => 'main', FIELD1 => 'MemberId',
91 ALIAS2 => $principals, FIELD2 =>'id');
93 $self->Limit( ALIAS => $principals,
94 FIELD => 'PrincipalType',
96 ENTRYAGGREGATOR => 'OR',
102 # {{{ sub LimitToMembersOfGroup
104 =head2 LimitToMembersOfGroup PRINCIPAL_ID
106 Takes a Principal Id as its only argument.
107 Limits the current search principals which are _directly_ members
108 of the group which has PRINCIPAL_ID as its principal id.
112 sub LimitToMembersOfGroup {
116 return ($self->Limit(
119 ENTRYAGGREGATOR => 'OR',
125 # {{{ sub LimitToGroupsWithMember
127 =head2 LimitToGroupsWithMember PRINCIPAL_ID
129 Takes a Principal Id as its only argument.
130 Limits the current search to groups which contain PRINCIPAL_ID as a member or submember.
131 This function gets used by GroupMember->Create to populate subgroups
135 sub LimitToGroupsWithMember {
141 return ($self->Limit(
142 VALUE => $member || '0',
144 ENTRYAGGREGATOR => 'OR',