summaryrefslogtreecommitdiff
path: root/FS/FS/svc_Common.pm
diff options
context:
space:
mode:
authorivan <ivan>2008-12-21 21:33:28 +0000
committerivan <ivan>2008-12-21 21:33:28 +0000
commit48bade3f01a672f235d61a29ad0d0b792fc80eab (patch)
tree175a6d060f647f9411d2634b109bbbb8ec5bbb1e /FS/FS/svc_Common.pm
parent93d2608554affca0d1e49ab1469328960c75848e (diff)
unique checking for svc_phone like svc_acct, closes: RT#4204 (also a few lines of the new per-agent config snuck in Conf.pm from RT#3989)
Diffstat (limited to 'FS/FS/svc_Common.pm')
-rw-r--r--FS/FS/svc_Common.pm24
1 files changed, 24 insertions, 0 deletions
diff --git a/FS/FS/svc_Common.pm b/FS/FS/svc_Common.pm
index 32c1d90e8..2866bfea4 100644
--- a/FS/FS/svc_Common.pm
+++ b/FS/FS/svc_Common.pm
@@ -249,6 +249,7 @@ sub insert {
my $error = $self->set_auto_inventory
|| $self->check
+ || $self->_check_duplicate
|| $self->SUPER::insert;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
@@ -314,6 +315,10 @@ sub insert {
'';
}
+#fallbacks
+sub _check_duplcate { ''; }
+sub table_dupcheck_fields { (); }
+
=item delete [ , OPTION => VALUE ... ]
Deletes this account from the database. If there is an error, returns the
@@ -390,6 +395,25 @@ sub replace {
return $error;
}
+ #redundant, but so any duplicate fields are maniuplated as appropriate
+ # (svc_phone.phonenum)
+ my $error = $new->check;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ #if ( $old->username ne $new->username || $old->domsvc != $new->domsvc ) {
+ if ( grep { $old->$_ ne $new->$_ } $new->table_dupcheck_fields ) {
+
+ $new->svcpart( $new->cust_svc->svcpart ) unless $new->svcpart;
+ $error = $new->_check_duplicate;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
$error = $new->SUPER::replace($old);
if ($error) {
$dbh->rollback if $oldAutoCommit;