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.
31 @EXPORT=qw(loc CurrentUser);
41 If called with an argument, sets the current user to that user object.
42 This will affect ACL decisions, etc.
43 Returns the current user
51 $self->{'original_user'} = $self->{'user'};
52 $self->{'user'} = shift;
53 Scalar::Util::weaken($self->{'user'}) if (ref($self->{'user'}) &&
54 $self->{'user'} == $self );
57 unless ( ref( $self->{'user'}) ) {
58 $RT::Logger->err( "$self was created without a CurrentUser\n" . Carp::cluck() );
62 return ( $self->{'user'} );
71 $self->{'original_user'} = shift;
72 Scalar::Util::weaken($self->{'original_user'})
73 if (ref($self->{'original_user'}) && $self->{'original_user'} == $self );
75 return ( $self->{'original_user'} || $self->{'user'} );
81 l is a method which takes a loc string
82 to this object's CurrentUser->LanguageHandle for localization.
84 you call it like this:
86 $self->loc("I have [quant,_1,concrete mixer].", 6);
88 In english, this would return:
89 I have 6 concrete mixers.
96 if (my $user = $self->OriginalUser) {
97 return $user->loc(@_);
101 Carp::confess("No currentuser");
102 return ("Critical error:$self has no CurrentUser", $self);
106 eval "require RT::Base_Vendor";
107 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Base_Vendor.pm});
108 eval "require RT::Base_Local";
109 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Base_Local.pm});