summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-08-29 21:27:20 -0700
committerMark Wells <mark@freeside.biz>2015-08-30 17:49:15 -0700
commiteda12d4d82a25ba333fb4e822aef9704b3ae938a (patch)
tree59667c2f81f3478fa1c5a49299cff9579520ed88 /FS
parent2d8749c581dce1c2564487b87425b60cbb37a690 (diff)
#21564: user interface for REST client
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/msg_template.pm15
1 files changed, 11 insertions, 4 deletions
diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm
index 827bb9883..4c2ac4bd4 100644
--- a/FS/FS/msg_template.pm
+++ b/FS/FS/msg_template.pm
@@ -5,7 +5,7 @@ use strict;
use vars qw( $DEBUG $conf );
use FS::Conf;
-use FS::Record qw( qsearch qsearchs );
+use FS::Record qw( qsearch qsearchs dbh );
use FS::cust_msg;
use FS::template_content;
@@ -95,11 +95,16 @@ sub _rebless {
eval "use $class;";
bless($self, $class) unless $@;
- # merge in the extension fields
+ # merge in the extension fields (but let fields in $self override them)
+ # except don't ever override the extension's primary key, it's immutable
if ( $self->msgnum and $self->extension_table ) {
my $extension = $self->_extension;
if ( $extension ) {
- $self->{Hash} = { $self->hash, $extension->hash };
+ my $ext_key = $extension->get($extension->primary_key);
+ $self->{Hash} = { $extension->hash,
+ $self->hash,
+ $extension->primary_key => $ext_key
+ };
}
}
@@ -194,6 +199,8 @@ sub replace {
my $extension = $new->_extension;
if ( $extension ) {
+ # merge changes into the extension record and replace it
+ $extension->{Hash} = { $extension->hash, $new->hash };
$error ||= $extension->replace;
}
@@ -212,7 +219,7 @@ sub replace_check {
if ( $old->msgclass ) {
if ( !$self->msgclass ) {
$self->set('msgclass', $old->msgclass);
- } else {
+ } elsif ( $old->msgclass ne $self->msgclass ) {
return "Can't change message template class from ".$old->msgclass.
" to ".$self->msgclass.".";
}