diff options
Diffstat (limited to 'rt/lib/RT/Base.pm')
-rw-r--r-- | rt/lib/RT/Base.pm | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/rt/lib/RT/Base.pm b/rt/lib/RT/Base.pm index 03b50e600..f32922103 100644 --- a/rt/lib/RT/Base.pm +++ b/rt/lib/RT/Base.pm @@ -1,8 +1,8 @@ -# {{{ BEGIN BPS TAGGED BLOCK +# BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC # <jesse@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -42,7 +42,7 @@ # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. # -# }}} END BPS TAGGED BLOCK +# END BPS TAGGED BLOCK }}} package RT::Base; use Carp; use Scalar::Util; @@ -52,9 +52,18 @@ use vars qw(@EXPORT); @EXPORT=qw(loc CurrentUser); -=head1 FUNCTIONS +=head1 NAME + +RT::Base + +=head1 SYNOPSIS +=head1 DESCRIPTION + +=head1 FUNCTIONS + +=cut # {{{ sub CurrentUser @@ -72,6 +81,9 @@ sub CurrentUser { if (@_) { $self->{'original_user'} = $self->{'user'}; $self->{'user'} = shift; + # We need to weaken the CurrentUser ($self->{'user'}) reference + # if the object in question is the currentuser object. + # This avoids memory leaks. Scalar::Util::weaken($self->{'user'}) if (ref($self->{'user'}) && $self->{'user'} == $self ); } @@ -79,7 +91,6 @@ sub CurrentUser { unless ( ref( $self->{'user'}) ) { $RT::Logger->err( "$self was created without a CurrentUser\n" . Carp::cluck() ); return (0); - die; } return ( $self->{'user'} ); } @@ -98,7 +109,7 @@ sub OriginalUser { } -=item loc LOC_STRING +=head2 loc LOC_STRING l is a method which takes a loc string to this object's CurrentUser->LanguageHandle for localization. @@ -125,6 +136,18 @@ sub loc { } } +sub loc_fuzzy { + my $self = shift; + if (my $user = $self->OriginalUser) { + return $user->loc_fuzzy(@_); + } + else { + use Carp; + Carp::confess("No currentuser"); + return ("Critical error:$self has no CurrentUser", $self); + } +} + eval "require RT::Base_Vendor"; die $@ if ($@ && $@ !~ qr{^Can't locate RT/Base_Vendor.pm}); eval "require RT::Base_Local"; |