1 # $Header: /home/cvs/cvsroot/freeside/rt/lib/RT/CurrentUser.pm,v 1.1 2002-08-12 06:17:07 ivan Exp $
2 # (c) 1996-1999 Jesse Vincent <jesse@fsck.com>
3 # This software is redistributable under the terms of the GNU GPL
7 RT::CurrentUser - an RT object representing the current user
22 ok (require RT::TestHarness);
23 ok (require RT::CurrentUser);
30 package RT::CurrentUser;
37 #The basic idea here is that $self->CurrentUser is always supposed
38 # to be a CurrentUser object. but that's hard to do when we're trying to load
39 # the CurrentUser object
45 $self->{'table'} = "Users";
51 $self->_MyCurrentUser($self);
59 return (0, 'Permission Denied');
67 return (0, 'Permission Denied');
76 Returns the RT::User object associated with this CurrentUser object.
83 unless ($self->{'UserObj'}) {
85 $self->{'UserObj'} = RT::User->new($self);
86 unless ($self->{'UserObj'}->Load($self->Id)) {
87 $RT::Logger->err("Couldn't load ".$self->Id. "from the users database.\n");
91 return ($self->{'UserObj'});
102 Password => 'neither',
103 EmailAddress => 'read',
104 Privileged => 'read',
105 IsAdministrator => 'read'
107 return($self->SUPER::_Accessible(@_, %Cols));
111 # {{{ sub LoadByEmail
115 Loads a User into this CurrentUser object.
116 Takes the email address of the user to load.
122 my $identifier = shift;
124 $self->LoadByCol("EmailAddress",$identifier);
129 # {{{ sub LoadByGecos
133 Loads a User into this CurrentUser object.
134 Takes a unix username as its only argument.
140 my $identifier = shift;
142 $self->LoadByCol("Gecos",$identifier);
151 Loads a User into this CurrentUser object.
157 my $identifier = shift;
158 $self->LoadByCol("Name",$identifier);
167 Loads a User into this CurrentUser object.
168 Takes either an integer (users id column reference) or a Name
169 The latter is deprecated. Instead, you should use LoadByName.
170 Formerly, this routine also took email addresses.
176 my $identifier = shift;
178 #if it's an int, load by id. otherwise, load by name.
179 if ($identifier !~ /\D/) {
180 $self->SUPER::LoadById($identifier);
183 # This is a bit dangerous, we might get false authen if somebody
184 # uses ambigous userids or real names:
185 $self->LoadByCol("Name",$identifier);
195 Takes a password as a string. Passes it off to IsPassword in this
196 user's UserObj. If it is the user's password and the user isn't
199 Otherwise, returns undef.
207 return ($self->UserObj->IsPassword($value));
216 Returns true if the current user can be granted rights and be
223 return ($self->UserObj->Privileged());
228 # {{{ Convenient ACL methods
232 calls $self->UserObj->HasQueueRight with the arguments passed in
238 return ($self->UserObj->HasQueueRight(@_));
241 =head2 HasSystemRight
243 calls $self->UserObj->HasSystemRight with the arguments passed in
250 return ($self->UserObj->HasSystemRight(@_));
256 =head2 HasSystemRight
258 calls $self->UserObj->HasRight with the arguments passed in
264 return ($self->UserObj->HasRight(@_));