diff options
Diffstat (limited to 'rt/lib/RT/Record.pm')
-rwxr-xr-x | rt/lib/RT/Record.pm | 63 |
1 files changed, 27 insertions, 36 deletions
diff --git a/rt/lib/RT/Record.pm b/rt/lib/RT/Record.pm index 191970a27..1b622739e 100755 --- a/rt/lib/RT/Record.pm +++ b/rt/lib/RT/Record.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2007 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) @@ -22,9 +22,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301 or visit their web page on the internet at -# http://www.gnu.org/copyleft/gpl.html. +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # # CONTRIBUTION SUBMISSION POLICY: @@ -45,6 +43,7 @@ # those contributions and any derivatives thereof. # # END BPS TAGGED BLOCK }}} + =head1 NAME RT::Record - Base class for RT record objects @@ -66,23 +65,18 @@ ok (require RT::Record); =cut package RT::Record; - -use strict; -use warnings; - -our @ISA; -use base qw(RT::Base); - use RT::Date; use RT::User; use RT::Attributes; +use RT::Base; use DBIx::SearchBuilder::Record::Cachable; -use Encode qw(); -our $_TABLE_ATTR = { }; +use strict; +use vars qw/@ISA $_TABLE_ATTR/; +@ISA = qw(RT::Base); -if ( $RT::DontCacheSearchBuilderRecords ) { +if ($RT::DontCacheSearchBuilderRecords ) { push (@ISA, 'DBIx::SearchBuilder::Record'); } else { push (@ISA, 'DBIx::SearchBuilder::Record::Cachable'); @@ -194,7 +188,7 @@ sub AddAttribute { Description => $args{'Description'}, Content => $args{'Content'} ); - + # XXX TODO: Why won't RedoSearch work here? $self->Attributes->_DoSearch; @@ -242,12 +236,8 @@ sub DeleteAttribute { =head2 FirstAttribute NAME -Returns the first attribute with the matching name for this object (as an -L<RT::Attribute> object), or C<undef> if no such attributes exist. - -Note that if there is more than one attribute with the matching name on the -object, the choice of which one to return is basically arbitrary. This may be -made well-defined in the future. +Returns the value of the first attribute with the matching name +for this object, or C<undef> if no such attributes exist. =cut @@ -661,6 +651,11 @@ sub SQLType { } +require Encode::compat if $] < 5.007001; +require Encode; + + + sub __Value { my $self = shift; @@ -753,7 +748,7 @@ DBIx::SearchBuilder::Record sub _ClassAccessible { my $self = shift; - return $_TABLE_ATTR->{ref($self)}; + return $_TABLE_ATTR->{ ref($self) || $self }; } =head2 _Accessible COLUMN ATTRIBUTE @@ -934,7 +929,7 @@ sub Update { next if ( $value eq $self->$attribute() ); my $method = "Set$attribute"; my ( $code, $msg ) = $self->$method($value); - my ($prefix) = ref($self) =~ /RT(?:.*)::(\w+)/; + my ($prefix) = ref($self) =~ /RT::(\w+)/; # Default to $id, but use name if we can get it. my $label = $self->id; @@ -1258,9 +1253,7 @@ sub _Links { =head2 _AddLink -Takes a paramhash of Type and one of Base or Target. Adds that link to this object. - -Returns C<link id>, C<message> and C<exist> flag. +Takes a paramhash of Type and one of Base or Target. Adds that link to this ticket. =cut @@ -1285,11 +1278,13 @@ sub _AddLink { } elsif ( $args{'Base'} ) { $args{'Target'} = $self->URI(); + my $class = ref($self); $remote_link = $args{'Base'}; $direction = 'Target'; } elsif ( $args{'Target'} ) { $args{'Base'} = $self->URI(); + my $class = ref($self); $remote_link = $args{'Target'}; $direction = 'Base'; } @@ -1305,7 +1300,7 @@ sub _AddLink { Target => $args{'Target'} ); if ( $old_link->Id ) { $RT::Logger->debug("$self Somebody tried to duplicate a link"); - return ( $old_link->id, $self->loc("Link already exists"), 1 ); + return ( $old_link->id, $self->loc("Link already exists") ); } # }}} @@ -1370,7 +1365,7 @@ sub _DeleteLink { $direction='Base'; } else { - $RT::Logger->error("Base or Target must be specified\n"); + $RT::Logger->debug("$self: Base or Target must be specified\n"); return ( 0, $self->loc('Either base or target must be specified') ); } @@ -1471,7 +1466,7 @@ sub _NewTransaction { $self->_UpdateTimeTaken( $args{'TimeTaken'} ); } if ( $RT::UseTransactionBatch and $transaction ) { - push @{$self->{_TransactionBatch}}, $trans if $args{'CommitScrips'}; + push @{$self->{_TransactionBatch}}, $trans; } return ( $transaction, $msg, $trans ); } @@ -1659,7 +1654,7 @@ sub _AddCustomFieldValue { ); unless ($new_value_id) { - return ( 0, $self->loc( "Could not add new custom field value: [_1]", $value_msg) ); + return ( 0, $self->loc( "Could not add new custom field value. [_1] ",, $value_msg)); } my $new_value = RT::ObjectCustomFieldValue->new( $self->CurrentUser ); @@ -1698,7 +1693,7 @@ sub _AddCustomFieldValue { # otherwise, just add a new value and record "new value added" else { - my ($new_value_id, $value_msg) = $cf->AddValueForObject( + my ($new_value_id) = $cf->AddValueForObject( Object => $self, Content => $args{'Value'}, LargeContent => $args{'LargeContent'}, @@ -1706,7 +1701,7 @@ sub _AddCustomFieldValue { ); unless ($new_value_id) { - return ( 0, $self->loc( "Could not add new custom field value: [_1]", $value_msg) ); + return ( 0, $self->loc("Could not add new custom field value. ") ); } if ( $args{'RecordTransaction'} ) { my ( $TransactionId, $Msg, $TransactionObj ) = @@ -1878,10 +1873,6 @@ sub LoadCustomFieldByIdentifier { sub BasicColumns { } -sub WikiBase { - return $RT::WebPath. "/index.html?q="; -} - eval "require RT::Record_Vendor"; die $@ if ($@ && $@ !~ qr{^Can't locate RT/Record_Vendor.pm}); eval "require RT::Record_Local"; |