summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Base.pm
diff options
context:
space:
mode:
authorivan <ivan>2005-10-15 09:11:20 +0000
committerivan <ivan>2005-10-15 09:11:20 +0000
commit673b9a458d9138523026963df6fa3b4683e09bae (patch)
tree42acc524ff5fd53e4fdb2f5b6dac4a42ce8057f6 /rt/lib/RT/Base.pm
parent591613cf1c861505335646fff3ffb4a705e011bf (diff)
parentd4d0590bef31071e8809ec046717444b95b3f30a (diff)
This commit was generated by cvs2svn to compensate for changes in r4407,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'rt/lib/RT/Base.pm')
-rw-r--r--rt/lib/RT/Base.pm35
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";