[freeside-commits] freeside/FS/FS/cust_main Search.pm,1.9,1.10
Ivan,,,
ivan at wavetail.420.am
Thu Dec 8 19:20:56 PST 2011
Update of /home/cvs/cvsroot/freeside/FS/FS/cust_main
In directory wavetail.420.am:/tmp/cvs-serv5109/cust_main
Modified Files:
Search.pm
Log Message:
fix automatic creation of fuzzy files, RT#15484
Index: Search.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main/Search.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -d -r1.9 -r1.10
--- Search.pm 28 Nov 2011 01:40:17 -0000 1.9
+++ Search.pm 9 Dec 2011 03:20:54 -0000 1.10
@@ -18,7 +18,7 @@
$DEBUG = 0;
$me = '[FS::cust_main::Search]';
- at fuzzyfields = @FS::cust_main::fuzzyfields;
+ at fuzzyfields = ( 'first', 'last', 'company', 'address1' );
install_callback FS::UID sub {
$conf = new FS::Conf;
@@ -859,7 +859,7 @@
sub check_and_rebuild_fuzzyfiles {
my $dir = $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc;
- rebuild_fuzzyfiles() if grep { ! -e "$dir/cust_main.$_" } @fuzzyfields
+ rebuild_fuzzyfiles() if grep { ! -e "$dir/cust_main.$_" } @fuzzyfields;
}
=item rebuild_fuzzyfiles
@@ -902,6 +902,41 @@
}
+=item append_fuzzyfiles FIRSTNAME LASTNAME COMPANY ADDRESS1
+
+=cut
+
+sub append_fuzzyfiles {
+ #my( $first, $last, $company ) = @_;
+
+ check_and_rebuild_fuzzyfiles();
+
+ use Fcntl qw(:flock);
+
+ my $dir = $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc;
+
+ foreach my $field (@fuzzyfields) {
+ my $value = shift;
+
+ if ( $value ) {
+
+ open(CACHE,">>$dir/cust_main.$field")
+ or die "can't open $dir/cust_main.$field: $!";
+ flock(CACHE,LOCK_EX)
+ or die "can't lock $dir/cust_main.$field: $!";
+
+ print CACHE "$value\n";
+
+ flock(CACHE,LOCK_UN)
+ or die "can't unlock $dir/cust_main.$field: $!";
+ close CACHE;
+ }
+
+ }
+
+ 1;
+}
+
=item all_X
=cut
More information about the freeside-commits
mailing list