X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcontact.pm;h=612048022b99ecdc15576bbbfb2ae5851c1bbf26;hb=1cfc3ea3efb8c75388ad344ea9481f6f8df072b9;hp=07458c74286799028eaee1c1405640f698cc1ef4;hpb=167dbdad01e2c1b62fd9be43cc05212e8c874a02;p=freeside.git diff --git a/FS/FS/contact.pm b/FS/FS/contact.pm index 07458c742..612048022 100644 --- a/FS/FS/contact.pm +++ b/FS/FS/contact.pm @@ -259,7 +259,10 @@ sub insert { } if ( $link_hash{'selfservice_access'} eq 'R' - or ( $link_hash{'selfservice_access'} && $cust_contact ) + or ( $link_hash{'selfservice_access'} + && $cust_contact + && ! length($self->_password) + ) ) { my $error = $self->send_reset_email( queue=>1 ); @@ -452,8 +455,11 @@ sub replace { ); my $contact_phone = qsearchs('contact_phone', \%cp); + my $pv = $self->get($pf); + $pv =~ s/\s//g; + #if new value is empty, delete old entry - if (!$self->get($pf)) { + if (!$pv) { if ($contact_phone) { $error = $contact_phone->delete; if ( $error ) { @@ -464,7 +470,9 @@ sub replace { next; } - my %cpd = _parse_phonestring( $self->get($pf) ); + $contact_phone ||= new FS::contact_phone \%cp; + + my %cpd = _parse_phonestring( $pv ); $contact_phone->set( $_ => $cpd{$_} ) foreach keys %cpd; my $method = $contact_phone->contactphonenum ? 'replace' : 'insert'; @@ -829,6 +837,7 @@ sub send_reset_email { #die "selfservice-password_reset_msgnum unset" unless $msgnum; return { 'error' => "selfservice-password_reset_msgnum unset" } unless $msgnum; my $msg_template = qsearchs('msg_template', { msgnum => $msgnum } ); + return { 'error' => "selfservice-password_reset_msgnum cannot be loaded" } unless $msg_template; my %msg_template = ( 'to' => join(',', map $_->emailaddress, @contact_email ), 'cust_main' => $cust_main, @@ -838,11 +847,14 @@ sub send_reset_email { if ( $opt{'queue'} ) { #or should queueing just be the default? + my $cust_msg = $msg_template->prepare( %msg_template ); + my $error = $cust_msg->insert; + return { 'error' => $error } if $error; my $queue = new FS::queue { - 'job' => 'FS::Misc::process_send_email', + 'job' => 'FS::cust_msg::process_send', 'custnum' => $cust_main ? $cust_main->custnum : '', }; - $queue->insert( $msg_template->prepare( %msg_template ) ); + $queue->insert( $cust_msg->custmsgnum ); } else {