X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Flib%2FRT%2FCurrentUser.pm;h=6997ddbac9d1cbbe273a8d9fce44a7fdb8a7d0a6;hb=0ebeec96313dd7edfca340f01f8fbbbac1f4aa1d;hp=4ca2f98919f79b206787753d052ab30d6ee29fb0;hpb=945721f48f74d5cfffef7c7cf3a3d6bc2521f5dd;p=freeside.git diff --git a/rt/lib/RT/CurrentUser.pm b/rt/lib/RT/CurrentUser.pm index 4ca2f9891..6997ddbac 100755 --- a/rt/lib/RT/CurrentUser.pm +++ b/rt/lib/RT/CurrentUser.pm @@ -1,26 +1,7 @@ -# BEGIN LICENSE BLOCK -# -# Copyright (c) 1996-2003 Jesse Vincent -# -# (Except where explictly superceded by other copyright notices) -# -# This work is made available to you under the terms of Version 2 of -# the GNU General Public License. A copy of that license should have -# been provided with this software, but in any event can be snarfed -# from www.gnu.org. -# -# This work is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# Unless otherwise specified, all modifications, corrections or -# extensions to this work which alter its source code become the -# property of Best Practical Solutions, LLC when submitted for -# inclusion in the work. -# -# -# END LICENSE BLOCK +# $Header: /home/cvs/cvsroot/freeside/rt/lib/RT/CurrentUser.pm,v 1.1 2002-08-12 06:17:07 ivan Exp $ +# (c) 1996-1999 Jesse Vincent +# This software is redistributable under the terms of the GNU GPL + =head1 NAME RT::CurrentUser - an RT object representing the current user @@ -38,6 +19,7 @@ =begin testing +ok (require RT::TestHarness); ok (require RT::CurrentUser); =end testing @@ -46,14 +28,10 @@ ok (require RT::CurrentUser); package RT::CurrentUser; - use RT::Record; -use RT::I18N; - -use strict; -use vars qw/@ISA/; @ISA= qw(RT::Record); + # {{{ sub _Init #The basic idea here is that $self->CurrentUser is always supposed @@ -70,7 +48,7 @@ sub _Init { $self->Load($Name); } - $self->CurrentUser($self); + $self->_MyCurrentUser($self); } # }}} @@ -78,8 +56,7 @@ sub _Init { # {{{ sub Create sub Create { - my $self = shift; - return (0, $self->loc('Permission Denied')); + return (0, 'Permission Denied'); } # }}} @@ -87,8 +64,7 @@ sub Create { # {{{ sub Delete sub Delete { - my $self = shift; - return (0, $self->loc('Permission Denied')); + return (0, 'Permission Denied'); } # }}} @@ -108,7 +84,7 @@ sub UserObj { use RT::User; $self->{'UserObj'} = RT::User->new($self); unless ($self->{'UserObj'}->Load($self->Id)) { - $RT::Logger->err($self->loc("Couldn't load [_1] from the users database.\n", $self->Id)); + $RT::Logger->err("Couldn't load ".$self->Id. "from the users database.\n"); } } @@ -116,42 +92,6 @@ sub UserObj { } # }}} -# {{{ sub PrincipalObj - -=head2 PrincipalObj - - Returns this user's principal object. this is just a helper routine for - $self->UserObj->PrincipalObj - -=cut - -sub PrincipalObj { - my $self = shift; - return($self->UserObj->PrincipalObj); -} - - -# }}} - - -# {{{ sub PrincipalId - -=head2 PrincipalId - - Returns this user's principal Id. this is just a helper routine for - $self->UserObj->PrincipalId - -=cut - -sub PrincipalId { - my $self = shift; - return($self->UserObj->PrincipalId); -} - - -# }}} - - # {{{ sub _Accessible sub _Accessible { my $self = shift; @@ -180,8 +120,6 @@ Takes the email address of the user to load. sub LoadByEmail { my $self = shift; my $identifier = shift; - - $identifier = RT::User::CanonicalizeEmailAddress(undef, $identifier); $self->LoadByCol("EmailAddress",$identifier); @@ -287,88 +225,46 @@ sub Privileged { # }}} +# {{{ Convenient ACL methods -# {{{ sub HasRight +=head2 HasQueueRight -=head2 HasRight - -calls $self->UserObj->HasRight with the arguments passed in +calls $self->UserObj->HasQueueRight with the arguments passed in =cut -sub HasRight { - my $self = shift; - return ($self->UserObj->HasRight(@_)); +sub HasQueueRight { + my $self = shift; + return ($self->UserObj->HasQueueRight(@_)); } -# }}} - -# {{{ Localization - -=head2 LanguageHandle +=head2 HasSystemRight -Returns this current user's langauge handle. Should take a language -specification. but currently doesn't +calls $self->UserObj->HasSystemRight with the arguments passed in -=begin testing - -ok (my $cu = RT::CurrentUser->new('root')); -ok (my $lh = $cu->LanguageHandle); -ok ($lh != undef); -ok ($lh->isa('Locale::Maketext')); -ok ($cu->loc('TEST_STRING') eq "Concrete Mixer", "Localized TEST_STRING into English"); -ok ($lh = $cu->LanguageHandle('fr')); -ok ($cu->loc('Before') eq "Avant", "Localized TEST_STRING into Frenc"); - -=end testing +=cut -=cut -sub LanguageHandle { - my $self = shift; - if ((!defined $self->{'LangHandle'}) || - (!UNIVERSAL::can($self->{'LangHandle'}, 'maketext')) || - (@_)) { - $self->{'LangHandle'} = RT::I18N->get_handle(@_); - } - # Fall back to english. - unless ($self->{'LangHandle'}) { - die "We couldn't get a dictionary. Nye mogu naidti slovar. No puedo encontrar dictionario."; - } - return ($self->{'LangHandle'}); +sub HasSystemRight { + my $self = shift; + return ($self->UserObj->HasSystemRight(@_)); } +# }}} -sub loc { - my $self = shift; - return '' if $_[0] eq ''; - - my $handle = $self->LanguageHandle; - - if (@_ == 1) { - # pre-scan the lexicon hashes to return _AUTO keys verbatim, - # to keep locstrings containing '[' and '~' from tripping over Maketext - return $_[0] unless grep { exists $_->{$_[0]} } @{ $handle->_lex_refs }; - } +# {{{ sub HasRight - return $handle->maketext(@_); -} +=head2 HasSystemRight -sub loc_fuzzy { - my $self = shift; - return '' if $_[0] eq ''; +calls $self->UserObj->HasRight with the arguments passed in - # XXX: work around perl's deficiency when matching utf8 data - return $_[0] if Encode::is_utf8($_[0]); - my $result = $self->LanguageHandle->maketext_fuzzy(@_); +=cut - return($result); +sub HasRight { + my $self = shift; + return ($self->UserObj->HasRight(@_)); } -# }}} -eval "require RT::CurrentUser_Vendor"; -die $@ if ($@ && $@ !~ qr{^Can't locate RT/CurrentUser_Vendor.pm}); -eval "require RT::CurrentUser_Local"; -die $@ if ($@ && $@ !~ qr{^Can't locate RT/CurrentUser_Local.pm}); +# }}} 1;