summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Record.pm
diff options
context:
space:
mode:
Diffstat (limited to 'rt/lib/RT/Record.pm')
-rwxr-xr-xrt/lib/RT/Record.pm71
1 files changed, 42 insertions, 29 deletions
diff --git a/rt/lib/RT/Record.pm b/rt/lib/RT/Record.pm
index 341d88bfc..191970a27 100755
--- a/rt/lib/RT/Record.pm
+++ b/rt/lib/RT/Record.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
# <jesse@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -22,7 +22,9 @@
#
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+# 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.
#
#
# CONTRIBUTION SUBMISSION POLICY:
@@ -43,7 +45,6 @@
# those contributions and any derivatives thereof.
#
# END BPS TAGGED BLOCK }}}
-
=head1 NAME
RT::Record - Base class for RT record objects
@@ -65,18 +66,23 @@ 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();
-use strict;
-use vars qw/@ISA $_TABLE_ATTR/;
+our $_TABLE_ATTR = { };
-@ISA = qw(RT::Base);
-if ($RT::DontCacheSearchBuilderRecords ) {
+if ( $RT::DontCacheSearchBuilderRecords ) {
push (@ISA, 'DBIx::SearchBuilder::Record');
} else {
push (@ISA, 'DBIx::SearchBuilder::Record::Cachable');
@@ -188,7 +194,7 @@ sub AddAttribute {
Description => $args{'Description'},
Content => $args{'Content'} );
-
+
# XXX TODO: Why won't RedoSearch work here?
$self->Attributes->_DoSearch;
@@ -236,8 +242,12 @@ sub DeleteAttribute {
=head2 FirstAttribute NAME
-Returns the value of the first attribute with the matching name
-for this object, or C<undef> if no such attributes exist.
+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.
=cut
@@ -651,11 +661,6 @@ sub SQLType {
}
-require Encode::compat if $] < 5.007001;
-require Encode;
-
-
-
sub __Value {
my $self = shift;
@@ -817,7 +822,10 @@ sub _EncodeLOB {
elsif ($RT::DropLongAttachments) {
# drop the attachment on the floor
- $RT::Logger->info( "$self: Dropped an attachment of size " . length($Body) . "\n" . "It started: " . substr( $Body, 0, 60 ) . "\n" );
+ $RT::Logger->info( "$self: Dropped an attachment of size "
+ . length($Body) . "\n"
+ . "It started: " . substr( $Body, 0, 60 ) . "\n"
+ );
return ("none", "Large attachment dropped" );
}
}
@@ -926,7 +934,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;
@@ -1250,7 +1258,9 @@ sub _Links {
=head2 _AddLink
-Takes a paramhash of Type and one of Base or Target. Adds that link to this ticket.
+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.
=cut
@@ -1275,13 +1285,11 @@ 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';
}
@@ -1297,7 +1305,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") );
+ return ( $old_link->id, $self->loc("Link already exists"), 1 );
}
# }}}
@@ -1362,7 +1370,7 @@ sub _DeleteLink {
$direction='Base';
}
else {
- $RT::Logger->debug("$self: Base or Target must be specified\n");
+ $RT::Logger->error("Base or Target must be specified\n");
return ( 0, $self->loc('Either base or target must be specified') );
}
@@ -1459,11 +1467,11 @@ sub _NewTransaction {
$self->_SetLastUpdated;
- if ( defined $args{'TimeTaken'} ) {
+ if ( defined $args{'TimeTaken'} and $self->can('_UpdateTimeTaken')) {
$self->_UpdateTimeTaken( $args{'TimeTaken'} );
}
if ( $RT::UseTransactionBatch and $transaction ) {
- push @{$self->{_TransactionBatch}}, $trans;
+ push @{$self->{_TransactionBatch}}, $trans if $args{'CommitScrips'};
}
return ( $transaction, $msg, $trans );
}
@@ -1634,10 +1642,11 @@ sub _AddCustomFieldValue {
);
}
}
+ $values->RedoSearch if $i; # redo search if have deleted at least one value
}
my ( $old_value, $old_content );
- if ( $old_value = $cf->ValuesForObject($self)->First ) {
+ if ( $old_value = $values->First ) {
$old_content = $old_value->Content();
return (1) if( $old_content eq $args{'Value'} && $old_value->LargeContent eq $args{'LargeContent'});;
}
@@ -1650,7 +1659,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 );
@@ -1689,7 +1698,7 @@ sub _AddCustomFieldValue {
# otherwise, just add a new value and record "new value added"
else {
- my ($new_value_id) = $cf->AddValueForObject(
+ my ($new_value_id, $value_msg) = $cf->AddValueForObject(
Object => $self,
Content => $args{'Value'},
LargeContent => $args{'LargeContent'},
@@ -1697,7 +1706,7 @@ sub _AddCustomFieldValue {
);
unless ($new_value_id) {
- return ( 0, $self->loc("Could not add new custom field value. ") );
+ return ( 0, $self->loc( "Could not add new custom field value: [_1]", $value_msg) );
}
if ( $args{'RecordTransaction'} ) {
my ( $TransactionId, $Msg, $TransactionObj ) =
@@ -1869,6 +1878,10 @@ 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";