projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
RT#37908: Convert existing email-sending code to use common interface [switched jobs...
[freeside.git]
/
FS
/
FS
/
contact.pm
diff --git
a/FS/FS/contact.pm
b/FS/FS/contact.pm
index
07458c7
..
6120480
100644
(file)
--- a/
FS/FS/contact.pm
+++ b/
FS/FS/contact.pm
@@
-259,7
+259,10
@@
sub insert {
}
if ( $link_hash{'selfservice_access'} eq 'R'
}
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 );
)
{
my $error = $self->send_reset_email( queue=>1 );
@@
-452,8
+455,11
@@
sub replace {
);
my $contact_phone = qsearchs('contact_phone', \%cp);
);
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 new value is empty, delete old entry
- if (!$
self->get($pf)
) {
+ if (!$
pv
) {
if ($contact_phone) {
$error = $contact_phone->delete;
if ( $error ) {
if ($contact_phone) {
$error = $contact_phone->delete;
if ( $error ) {
@@
-464,7
+470,9
@@
sub replace {
next;
}
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';
$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 } );
#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,
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?
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 {
my $queue = new FS::queue {
- 'job' => 'FS::
Misc::process_send_email
',
+ 'job' => 'FS::
cust_msg::process_send
',
'custnum' => $cust_main ? $cust_main->custnum : '',
};
'custnum' => $cust_main ? $cust_main->custnum : '',
};
- $queue->insert( $
msg_template->prepare( %msg_template )
);
+ $queue->insert( $
cust_msg->custmsgnum
);
} else {
} else {