2 # $Header: /home/cvs/cvsroot/freeside/rt/lib/RT/Users.pm,v 1.1 2002-08-12 06:17:07 ivan Exp $
3 # (c) 1996-1999 Jesse Vincent <jesse@fsck.com>
4 # This software is redistributable under the terms of the GNU GPL
8 RT::Users - Collection of RT::User objects
22 ok(require RT::TestHarness);
23 ok(require RT::Users);
31 @ISA = qw(RT::EasySearch);
36 $self->{'table'} = "Users";
37 $self->{'primary_key'} = "id";
39 # By default, order by name
40 $self->OrderBy( ALIAS => 'main',
44 return ($self->SUPER::_Init(@_));
53 A subclass of DBIx::SearchBuilder::_DoSearch that makes sure that _Disabled rows never get seen unless
54 we're explicitly trying to see them.
61 #unless we really want to find disabled rows, make sure we\'re only finding enabled ones.
62 unless($self->{'find_disabled_rows'}) {
63 $self->LimitToEnabled();
66 return($self->SUPER::_DoSearch(@_));
78 my $item = new RT::User($self->CurrentUser);
86 Takes one argument. an email address. limits the returned set to
94 $self->Limit(FIELD => 'EmailAddress', VALUE => "$addr");
103 takes one argument, a group id number. Limits the returned set
104 to members of a given group
112 return ("No group specified") if (!defined $group);
114 my $groupalias = $self->NewAlias('GroupMembers');
116 $self->Join( ALIAS1 => 'main', FIELD1 => 'id',
117 ALIAS2 => "$groupalias", FIELD2 => 'Name');
119 $self->Limit (ALIAS => "$groupalias",
128 # {{{ LimitToPrivileged
130 =head2 LimitToPrivileged
132 Limits to users who can be made members of ACLs and groups
136 sub LimitToPrivileged {
138 $self->Limit( FIELD => 'Privileged',
151 Limits to users who can be granted rights, but who should
152 never have their rights modified by a user or be made members of groups.
158 $self->Limit( FIELD => 'Privileged',
169 Takes a queue id as its first argument. Queue Id "0" is treated by RT as "applies to all queues"
170 Takes a specific right as an optional second argument
172 Limits the returned set to users who have rights in the queue specified, personally. If the optional second argument is supplied, limits to users who have been explicitly granted that right.
176 This should not be used as an ACL check, but only for obtaining lists of
177 users with explicit rights in a given queue.
186 $right = shift if (@_);
189 my $acl_alias = $self->NewAlias('ACL');
190 $self->Join( ALIAS1 => 'main', FIELD1 => 'id',
191 ALIAS2 => $acl_alias, FIELD2 => 'PrincipalId');
192 $self->Limit (ALIAS => $acl_alias,
193 FIELD => 'PrincipalType',
198 $self->Limit(ALIAS => $acl_alias,
199 FIELD => 'RightAppliesTo',
204 $self->Limit(ALIAS => $acl_alias,
205 FIELD => 'RightScope',
207 ENTRYAGGREGATOR => 'OR',
211 $self->Limit(ALIAS => $acl_alias,
212 FIELD => 'RightScope',
214 ENTRYAGGREGATOR => 'OR',
218 #TODO: is this being initialized properly if the right isn't there?
219 if (defined ($right)) {
221 $self->Limit(ALIAS => $acl_alias,
222 FIELD => 'RightName',
238 =head2 HasSystemRight
240 Takes one optional argument:
241 The name of a System level right.
243 Limits the returned set to users who have been granted system rights, personally. If the optional argument is passed in, limits to users who have been granted the explicit right listed. Please see the note attached to LimitToQueueRights
249 my $right = shift if (@_);
250 my $acl_alias = $self->NewAlias('ACL');
253 $self->Join( ALIAS1 => 'main', FIELD1 => 'id',
254 ALIAS2 => $acl_alias, FIELD2 => 'PrincipalId');
255 $self->Limit (ALIAS => $acl_alias,
256 FIELD => 'PrincipalType',
260 $self->Limit(ALIAS => $acl_alias,
261 FIELD => 'RightScope',
266 #TODO: is this being initialized properly if the right isn't there?
267 if (defined ($right)) {
268 $self->Limit(ALIAS => $acl_alias,
269 FIELD => 'RightName',