diff options
author | Ivan Kohler <ivan@freeside.biz> | 2015-01-29 17:59:07 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2015-01-29 17:59:07 -0800 |
commit | f79a7ca7e5b3e484646190e15f995b9779089ff0 (patch) | |
tree | ecc154a7e64bd8c5908b8585fe77bb267f3baf29 /FS | |
parent | 24c38179b5d35f4edf2ab5fa157c7ca86046552e (diff) | |
parent | 07f2ee893fc57164ae3672f1a494d395c4eb1d26 (diff) |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Conf.pm | 15 | ||||
-rw-r--r-- | FS/FS/Cron/agent_email.pm | 5 | ||||
-rw-r--r-- | FS/FS/Cron/upload.pm | 5 | ||||
-rw-r--r-- | FS/FS/Upgrade.pm | 47 | ||||
-rw-r--r-- | FS/FS/cust_bill.pm | 5 | ||||
-rw-r--r-- | FS/FS/cust_credit.pm | 5 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 5 | ||||
-rw-r--r-- | FS/FS/cust_main/Billing_Realtime.pm | 5 | ||||
-rw-r--r-- | FS/FS/cust_pay.pm | 5 | ||||
-rw-r--r-- | FS/FS/cust_pkg.pm | 5 | ||||
-rw-r--r-- | FS/FS/msg_template.pm | 5 | ||||
-rw-r--r-- | FS/FS/pay_batch.pm | 5 | ||||
-rw-r--r-- | FS/FS/quotation.pm | 5 | ||||
-rw-r--r-- | FS/FS/upload_target.pm | 5 |
14 files changed, 57 insertions, 65 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 802794c..029f1a1 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -593,6 +593,21 @@ sub config_items { ( @config_items, $self->_orbase_items(@_) ); } +=item invoice_from_full [ AGENTNUM ] + +Returns values of invoice_from and invoice_from_name, appropriately combined +based on their current values. + +=cut + +sub invoice_from_full { + my ($self, $agentnum) = @_; + return $self->config('invoice_from_name', $agentnum ) ? + $self->config('invoice_from_name', $agentnum ) . ' <' . + $self->config('invoice_from', $agentnum ) . '>' : + $self->config('invoice_from', $agentnum ); +} + =back =head1 SUBROUTINES diff --git a/FS/FS/Cron/agent_email.pm b/FS/FS/Cron/agent_email.pm index 623b920..6bc1cc6 100644 --- a/FS/FS/Cron/agent_email.pm +++ b/FS/FS/Cron/agent_email.pm @@ -29,10 +29,7 @@ sub agent_email { RT::ConnectToDatabase(); } - my $from = $conf->config('invoice_from_name') ? - $conf->config('invoice_from_name') . ' <' . - $conf->config('invoice_from') . '>' : - $conf->config('invoice_from'); + my $from = $conf->invoice_from_full(); my $outbuf = '';; my( $fs_interp, $rt_interp ) = mason_interps('standalone', 'outbuf'=>\$outbuf); diff --git a/FS/FS/Cron/upload.pm b/FS/FS/Cron/upload.pm index fa1762f..6a4d153 100644 --- a/FS/FS/Cron/upload.pm +++ b/FS/FS/Cron/upload.pm @@ -508,10 +508,7 @@ sub prepare_report { ( to => $to, - from => $conf->config('invoice_from_name', $agentnum) ? - $conf->config('invoice_from_name', $agentnum) . ' <' . - $conf->config('invoice_from', $agentnum) . '>' : - $conf->config('invoice_from', $agentnum), + from => $conf->invoice_from_full($agentnum), subject => $subject, body => $body, ); diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm index 5d092ed..f84e4e5 100644 --- a/FS/FS/Upgrade.pm +++ b/FS/FS/Upgrade.pm @@ -46,22 +46,6 @@ sub upgrade_config { my $conf = new FS::Conf; - if ($conf->config('invoice_from') =~ /\<(.*)\>/) { - my $realemail = $1; - $realemail =~ s/^\s*//; # remove leading spaces - $realemail =~ s/\s*$//; # remove trailing spaces - my $realname = $conf->config('invoice_from'); - $realname =~ s/\<.*\>//; # remove email address - $realname =~ s/^\s*//; # remove leading spaces - $realname =~ s/\s*$//; # remove trailing spaces - # properly quote names that contain punctuation - if (($realname =~ /[^[:alnum:][:space:]]/) && ($realname !~ /^\".*\"$/)) { - $realname = '"' . $realname . '"'; - } - $conf->set('invoice_from_name', $realname); - $conf->set('invoice_from', $realemail); - } - $conf->touch('payment_receipt') if $conf->exists('payment_receipt_email') || $conf->config('payment_receipt_msgnum'); @@ -79,8 +63,15 @@ sub upgrade_config { } } + my @agents = qsearch('agent', {}); + upgrade_overlimit_groups($conf); - map { upgrade_overlimit_groups($conf,$_->agentnum) } qsearch('agent', {}); + map { upgrade_overlimit_groups($conf,$_->agentnum) } @agents; + + upgrade_invoice_from($conf); + foreach my $agent (@agents) { + upgrade_invoice_from($conf,$agent->agentnum); + } my $DIST_CONF = '/usr/local/etc/freeside/default_conf/';#DIST_CONF in Makefile $conf->set($_, scalar(read_file( "$DIST_CONF/$_" )) ) @@ -183,6 +174,28 @@ sub upgrade_overlimit_groups { } } +sub upgrade_invoice_from { + my ($conf, $agentnum) = @_; + if ( + (!$conf->config('invoice_from_name',$agentnum)) && + ($conf->config('invoice_from',$agentnum) =~ /\<(.*)\>/) + ) { + my $realemail = $1; + $realemail =~ s/^\s*//; # remove leading spaces + $realemail =~ s/\s*$//; # remove trailing spaces + my $realname = $conf->config('invoice_from',$agentnum); + $realname =~ s/\<.*\>//; # remove email address + $realname =~ s/^\s*//; # remove leading spaces + $realname =~ s/\s*$//; # remove trailing spaces + # properly quote names that contain punctuation + if (($realname =~ /[^[:alnum:][:space:]]/) && ($realname !~ /^\".*\"$/)) { + $realname = '"' . $realname . '"'; + } + $conf->set('invoice_from_name', $realname, $agentnum); + $conf->set('invoice_from', $realemail, $agentnum); + } +} + =item upgrade =cut diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 6ded57f..d2a6ded 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -1085,10 +1085,7 @@ sub email { # this is where we set the From: address $from ||= $self->_agent_invoice_from || #XXX should go away - $conf->config('invoice_from_name', $self->cust_main->agentnum ) ? - $conf->config('invoice_from_name', $self->cust_main->agentnum ) . ' <' . - $conf->config('invoice_from', $self->cust_main->agentnum ) . '>' : - $conf->config('invoice_from', $self->cust_main->agentnum ); + $conf->invoice_from_full( $self->cust_main->agentnum ); my @invoicing_list = $self->cust_main->invoicing_list_emailonly; diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm index 6f4f720..deebe27 100644 --- a/FS/FS/cust_credit.pm +++ b/FS/FS/cust_credit.pm @@ -282,10 +282,7 @@ sub delete { my $cust_main = $self->cust_main; my $error = send_email( - 'from' => $conf->config('invoice_from_name', $self->cust_main->agentnum) ? - $conf->config('invoice_from_name', $self->cust_main->agentnum) . ' <' . - $conf->config('invoice_from', $self->cust_main->agentnum) . '>' : - $conf->config('invoice_from', $self->cust_main->agentnum), + 'from' => $conf->invoice_from_full($self->cust_main->agentnum), #invoice_from??? well as good as any 'to' => $conf->config('deletecredits'), 'subject' => 'FREESIDE NOTIFICATION: Credit deleted', diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 1ed1d4a..d6f1a31 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -4327,10 +4327,7 @@ sub notify { return unless $conf->exists($template); - my $from = $conf->config('invoice_from_name', $self->agentnum) ? - $conf->config('invoice_from_name', $self->agentnum) . ' <' . - $conf->config('invoice_from', $self->agentnum) . '>' : - $conf->config('invoice_from', $self->agentnum) + my $from = $conf->invoice_from_full($self->agentnum) if $conf->exists('invoice_from', $self->agentnum); $from = $options{from} if exists($options{from}); diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm index f9f3754..20698fb 100644 --- a/FS/FS/cust_main/Billing_Realtime.pm +++ b/FS/FS/cust_main/Billing_Realtime.pm @@ -1109,10 +1109,7 @@ sub _realtime_bop_result { }; my $error = send_email( - 'from' => $conf->config('invoice_from_name', $self->agentnum ) ? - $conf->config('invoice_from_name', $self->agentnum ) . ' <' . - $conf->config('invoice_from', $self->agentnum ) . '>' : - $conf->config('invoice_from', $self->agentnum ), + 'from' => $conf->invoice_from_full( $self->agentnum ), 'to' => [ grep { $_ ne 'POST' } $self->invoicing_list ], 'subject' => 'Your payment could not be processed', 'body' => [ $template->fill_in(HASH => $templ_hash) ], diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index e44278d..139d2ff 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -694,10 +694,7 @@ sub send_receipt { 'msgtype' => 'receipt', }; $error = $queue->insert( - 'from' => $conf->config('invoice_from_name', $cust_main->agentnum ) ? - $conf->config('invoice_from_name', $cust_main->agentnum ) . ' <' . - $conf->config('invoice_from', $cust_main->agentnum ) . '>' : - $conf->config('invoice_from', $cust_main->agentnum ), + 'from' => $conf->invoice_from_full( $cust_main->agentnum ), #invoice_from??? well as good as any 'to' => \@invoicing_list, 'subject' => 'Payment receipt', diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index ccf63db..0f0983b 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -947,10 +947,7 @@ sub cancel { } else { $error = send_email( - 'from' => $conf->config('invoice_from_name', $self->cust_main->agentnum) ? - $conf->config('invoice_from_name', $self->cust_main->agentnum) . ' <' . - $conf->config('invoice_from', $self->cust_main->agentnum) . '>' : - $conf->config('invoice_from', $self->cust_main->agentnum), + 'from' => $conf->invoice_from_full( $self->cust_main->agentnum ), 'to' => \@invoicing_list, 'subject' => ( $conf->config('cancelsubject') || 'Cancellation Notice' ), 'body' => [ map "$_\n", $conf->config('cancelmessage') ], diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm index 70a8e49..f45fb2a 100644 --- a/FS/FS/msg_template.pm +++ b/FS/FS/msg_template.pm @@ -398,10 +398,7 @@ sub prepare { $from_addr = scalar( $conf->config($opt{'from_config'}, $cust_main->agentnum) ); } - $from_addr ||= $conf->config('invoice_from_name', $cust_main->agentnum) ? - $conf->config('invoice_from_name', $cust_main->agentnum) . ' <' . - $conf->config('invoice_from', $cust_main->agentnum) . '>' : - $conf->config('invoice_from', $cust_main->agentnum); + $from_addr ||= $conf->invoice_from_full($cust_main->agentnum); } # my @cust_msg = (); # if ( $conf->exists('log_sent_mail') and !$opt{'preview'} ) { diff --git a/FS/FS/pay_batch.pm b/FS/FS/pay_batch.pm index 3079db1..fcf1a5a 100644 --- a/FS/FS/pay_batch.pm +++ b/FS/FS/pay_batch.pm @@ -749,10 +749,7 @@ sub import_from_gateway { my $body = "Import from gateway ".$gateway->label."\n".$error_text; send_email( to => $mail_on_error, - from => $conf->config('invoice_from_name') ? - $conf->config('invoice_from_name') . ' <' . - $conf->config('invoice_from') . '>' : - $conf->config('invoice_from'), + from => $conf->invoice_from_full(), subject => $subject, body => $body, ); diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm index 774495a..5c94150 100644 --- a/FS/FS/quotation.pm +++ b/FS/FS/quotation.pm @@ -183,10 +183,7 @@ sub email { # this is where we set the From: address $from ||= $conf->config('quotation_from', $self->cust_or_prospect->agentnum ) - || ($conf->config('invoice_from_name', $self->cust_or_prospect->agentnum ) ? - $conf->config('invoice_from_name', $self->cust_or_prospect->agentnum ) . ' <' . - $conf->config('invoice_from', $self->cust_or_prospect->agentnum ) . '>' : - $conf->config('invoice_from', $self->cust_or_prospect->agentnum )); + || $conf->invoice_from_full( $self->cust_or_prospect->agentnum ); $self->SUPER::email( { 'from' => $from, %$opt, diff --git a/FS/FS/upload_target.pm b/FS/FS/upload_target.pm index 73d2a04..af2dcb1 100644 --- a/FS/FS/upload_target.pm +++ b/FS/FS/upload_target.pm @@ -163,10 +163,7 @@ sub put { # (maybe use only the raw content, so that we don't have to supply a # customer for substitutions? ewww.) my %message = ( - 'from' => $conf->config('invoice_from_name') ? - $conf->config('invoice_from_name') . ' <' . - $conf->config('invoice_from') . '>' : - $conf->config('invoice_from'), + 'from' => $conf->invoice_from_full(), 'to' => $to, 'subject' => $self->subject, 'nobody' => 1, |