X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcontact.pm;h=735fe138f0ea8fd97f57807dc8717eef65d0eced;hb=5013b675230c3330f25ca0d12ec7dfab95653bcd;hp=8fcd724a069459a388e49fb6ef42178a1b31eef3;hpb=b808053966fd3c43edefa1b7c4b93cbeb7cf546e;p=freeside.git diff --git a/FS/FS/contact.pm b/FS/FS/contact.pm index 8fcd724a0..735fe138f 100644 --- a/FS/FS/contact.pm +++ b/FS/FS/contact.pm @@ -1,14 +1,8 @@ package FS::contact; +use base qw( FS::Record ); use strict; -use base qw( FS::Record ); -use FS::Record qw( qsearch qsearchs dbh ); -use FS::prospect_main; -use FS::cust_main; -use FS::contact_class; -use FS::cust_location; -use FS::contact_phone; -use FS::contact_email; +use FS::Record qw( qsearchs dbh ); # qw( qsearch qsearchs dbh ); =head1 NAME @@ -68,6 +62,16 @@ title comment +=item selfservice_access + +empty or Y + +=item _password + +=item _password_encoding + +empty or bcrypt + =item disabled disabled @@ -153,6 +157,16 @@ sub insert { } + #unless ( $import || $skip_fuzzyfiles ) { + #warn " queueing fuzzyfiles update\n" + # if $DEBUG > 1; + $error = $self->queue_fuzzyfiles_update; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "updating fuzzy search cache: $error"; + } + #} + $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; @@ -277,6 +291,16 @@ sub replace { } + #unless ( $import || $skip_fuzzyfiles ) { + #warn " queueing fuzzyfiles update\n" + # if $DEBUG > 1; + $error = $self->queue_fuzzyfiles_update; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "updating fuzzy search cache: $error"; + } + #} + $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; @@ -306,6 +330,44 @@ sub _parse_phonestring { ); } +=item queue_fuzzyfiles_update + +Used by insert & replace to update the fuzzy search cache + +=cut + +use FS::cust_main::Search; +sub queue_fuzzyfiles_update { + my $self = shift; + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + foreach my $field ( 'first', 'last' ) { + my $queue = new FS::queue { + 'job' => 'FS::cust_main::Search::append_fuzzyfiles_fuzzyfield' + }; + my @args = "contact.$field", $self->get($field); + my $error = $queue->insert( @args ); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "queueing job (transaction rolled back): $error"; + } + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + ''; + +} + =item check Checks all fields to make sure this is a valid example. If there is @@ -330,6 +392,9 @@ sub check { || $self->ut_namen('first') || $self->ut_textn('title') || $self->ut_textn('comment') + || $self->ut_enum('selfservice_access', [ '', 'Y' ]) + || $self->ut_textn('_password') + || $self->ut_enum('_password_encoding', [ '', 'bcrypt']) || $self->ut_enum('disabled', [ '', 'Y' ]) ; return $error if $error; @@ -353,34 +418,12 @@ sub line { $data; } -sub cust_location { - my $self = shift; - return '' unless $self->locationnum; - qsearchs('cust_location', { 'locationnum' => $self->locationnum } ); -} - -sub contact_class { - my $self = shift; - return '' unless $self->classnum; - qsearchs('contact_class', { 'classnum' => $self->classnum } ); -} - sub contact_classname { my $self = shift; my $contact_class = $self->contact_class or return ''; $contact_class->classname; } -sub contact_phone { - my $self = shift; - qsearch('contact_phone', { 'contactnum' => $self->contactnum } ); -} - -sub contact_email { - my $self = shift; - qsearch('contact_email', { 'contactnum' => $self->contactnum } ); -} - =back =head1 BUGS