| 1 | package App::ZofCMS::Plugin::HTMLMailer; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use base 'App::ZofCMS::Plugin::Base'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use MIME::Lite; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use HTML::Template; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use File::Spec::Functions (qw/catfile/); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | our $VERSION = '1.001010'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub _key { 'plug_htmlmailer' } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_key: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub _defaults { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_defaults: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | #to => [ qw/foo@bar.com ber@bar.com/ ], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | #template => 'mail_templates/new-forum-post.tmpl', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | subject => '', | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | template_dir => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | precode => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | mime_lite_params => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | from => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | cc => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | bcc => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | template_params => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | html_template_object => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub _do { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_do: not called CC=27 SCAR=66.3
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | my ( $self, $conf, $t, $q, $config ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | for ( qw/to bcc cc / ) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | $conf->{$_} = $conf->{$_}->( $t, $q, $config ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if ref $conf->{$_} eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | $conf->{$_} = [ $conf->{$_} ] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | if ref $conf->{$_} ne 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | and defined $conf->{$_} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | and length $conf->{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $conf->{$_} ne "ARRAY" and defined $conf->{$_} and length $conf->{$_}
ref $conf->{$_} ne "ARRAY" and defined $conf->{$_}
MC/DC0%0/3
ref $conf->{$_} ne "ARRAY" and defined $conf->{$_} and length $conf->{$_}
ref $conf->{$_} ne "ARRAY"
defined $conf->{$_}
length $conf->{$_}
Truth table0%0/4
A and B and C
A= ref $conf->{$_} ne "ARRAY"B= defined $conf->{$_}C= length $conf->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | $conf->{attach} = $conf->{attach}->( $t, $q, $config ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if ref $conf->{attach} eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | $conf->{attach} = [ $conf->{attach} ] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | if $conf->{attach} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | and ref $conf->{attach}[0] ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$conf->{"attach"} and ref $conf->{"attach"}[0] ne "ARRAY"
MC/DC0%0/2
$conf->{"attach"} and ref $conf->{"attach"}[0] ne "ARRAY"
$conf->{"attach"}
ref $conf->{"attach"}[0] ne "ARRAY"
Truth table0%0/3
A and B
A= $conf->{"attach"}B= ref $conf->{"attach"}[0] ne "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | return | ||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | unless @{ $conf->{to} || [] } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$conf->{'to'} || []
defined $conf->{"template"} and length $conf->{"template"} or defined $conf->{"html_template_object"}
defined $conf->{"template"} and length $conf->{"template"}
MC/DC0%0/1
$conf->{'to'} || []
$conf->{'to'}
MC/DC0%0/3
defined $conf->{"template"} and length $conf->{"template"} or defined $conf->{"html_template_object"}
defined $conf->{"template"}
length $conf->{"template"}
defined $conf->{"html_template_object"}
Truth table0%0/2
A
A= $conf->{'to'}
Truth table0%0/5
A and B or C
A= defined $conf->{"template"}B= length $conf->{"template"}C= defined $conf->{"html_template_object"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | and ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | ( defined $conf->{template} and length $conf->{template} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | or defined $conf->{html_template_object} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@{$conf->{"to"} or [];} and defined $conf->{"template"} && length $conf->{"template"} || defined $conf->{"html_template_object"}
MC/DC0%0/2
@{$conf->{"to"} or [];} and defined $conf->{"template"} && length $conf->{"template"} || defined $conf->{"html_template_object"}
@{$conf->{"to"} or [];}
defined $conf->{"template"} && length $conf->{"template"} || defined $conf->{"html_template_object"}
Truth table0%0/3
A and B
A= @{$conf->{"to"} or [];}B= defined $conf->{"template"} && length $conf->{"template"} || defined $conf->{"html_template_object"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if ( ref $conf->{precode} eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $conf->{precode}->( $t, $q, $config, $conf ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | my $temp = $conf->{html_template_object} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | || HTML::Template->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | filename => ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ( defined $conf->{template_dir} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | and length $conf->{template_dir} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ) ? catfile( $conf->{template_dir}, $conf->{template} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | : $conf->{template_dir}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | ), | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$conf->{'html_template_object'} || 'HTML::Template'->new('filename', defined $conf->{'template_dir'} && length $conf->{'template_dir'} ? catfile($conf->{'template_dir'}, $conf->{'template'}) : $conf->{'template_dir'}, 'die_on_bad_params', 0)
defined $conf->{"template_dir"} and length $conf->{"template_dir"}
MC/DC0%0/2
$conf->{'html_template_object'} || 'HTML::Template'->new('filename', defined $conf->{'template_dir'} && length $conf->{'template_dir'} ? catfile($conf->{'template_dir'}, $conf->{'template'}) : $conf->{'template_dir'}, 'die_on_bad_params', 0)
$conf->{'html_template_object'}
'HTML::Template'->new('filename', defined $conf->{'template_dir'} && length $conf->{'template_dir'} ? catfile($conf->{'template_dir'}, $conf->{'template'}) : $conf->{'template_dir'}, 'die_on_bad_params', 0)
MC/DC0%0/2
defined $conf->{"template_dir"} and length $conf->{"template_dir"}
defined $conf->{"template_dir"}
length $conf->{"template_dir"}
Truth table0%0/3
A || B
A= $conf->{'html_template_object'}B= 'HTML::Template'->new('filename', defined $conf->{'template_dir'} && length $conf->{'template_dir'} ? catfile($conf->{'template_dir'}, $conf->{'template'}) : $conf->{'template_dir'}, 'die_on_bad_params', 0)
Truth table0%0/3
A and B
A= defined $conf->{"template_dir"}B= length $conf->{"template_dir"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | die_on_bad_params => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | $conf->{template_params} = $conf->{template_params}->( $t, $q, $config ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ref $conf->{template_params} eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $temp->param( @{ $conf->{template_params} } ) | |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if @{ $conf->{template_params} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$conf->{'template_params'} || []
MC/DC0%0/1
$conf->{'template_params'} || []
$conf->{'template_params'}
Truth table0%0/2
A
A= $conf->{'template_params'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | my $msg = MIME::Lite->new ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | Subject => $conf->{subject}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ( defined $conf->{from} ? ( From => $conf->{from} ) : (), ), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | To => ( join ',', @{ $conf->{to} } ), | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | ( ( defined $conf->{bcc} ) ? ( Bcc => ( join ',', @{ $conf->{bcc} } ), ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | ( ( defined $conf->{cc} ) ? ( cc => ( join ',', @{ $conf->{cc} } ), ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | Type => 'text/html', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | Data => $temp->output, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | for ( @{ $conf->{attach} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$conf->{'attach'} || []
MC/DC0%0/1
$conf->{'attach'} || []
$conf->{'attach'}
Truth table0%0/2
A
A= $conf->{'attach'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $msg->attach( @$_ ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | MIME::Lite->send( @{ $conf->{mime_lite_params} } ) | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if $conf->{mime_lite_params}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $msg->send; | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||