line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2003-2020 by [Mark Overmeer ]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.02. |
5
|
|
|
|
|
|
|
# This code is part of distribution User-Identity. Meta-POD processed with |
6
|
|
|
|
|
|
|
# OODoc into POD and HTML manual-pages. See README.md |
7
|
|
|
|
|
|
|
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package User::Identity::Location; |
10
|
2
|
|
|
2
|
|
70422
|
use vars '$VERSION'; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
124
|
|
11
|
|
|
|
|
|
|
$VERSION = '1.00'; |
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
14
|
use base 'User::Identity::Item'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
549
|
|
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
16
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
44
|
|
16
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
46
|
|
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
|
454
|
use User::Identity; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
64
|
|
19
|
2
|
|
|
2
|
|
14
|
use Scalar::Util 'weaken'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1549
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
1
|
0
|
sub type { "location" } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub init($) |
26
|
4
|
|
|
4
|
0
|
13
|
{ my ($self, $args) = @_; |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
66
|
|
|
19
|
$args->{postal_code} ||= delete $args->{pc}; |
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
20
|
$self->SUPER::init($args); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
exists $args->{$_} && ($self->{'UIL_'.$_} = delete $args->{$_}) |
33
|
4
|
|
100
|
|
|
79
|
foreach qw/city country country_code fax organization |
34
|
|
|
|
|
|
|
pobox pobox_pc postal_code state street phone/; |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
11
|
$self; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
2
|
1
|
654
|
sub street() { shift->{UIL_street} } |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
2
|
1
|
9
|
sub postalCode() { shift->{UIL_postal_code} } |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
3
|
1
|
12
|
sub pobox() { shift->{UIL_pobox} } |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
2
|
|
|
2
|
1
|
7
|
sub poboxPostalCode() { shift->{UIL_pobox_pc} } |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#----------------------------------------- |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
2
|
1
|
9
|
sub city() { shift->{UIL_city} } |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
0
|
1
|
0
|
sub state() { shift->{UIL_state} } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub country() |
61
|
3
|
|
|
3
|
1
|
6
|
{ my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return $self->{UIL_country} |
64
|
3
|
100
|
|
|
|
12
|
if defined $self->{UIL_country}; |
65
|
|
|
|
|
|
|
|
66
|
1
|
50
|
|
|
|
4
|
my $cc = $self->countryCode or return; |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
52
|
eval 'require Geography::Countries'; |
69
|
1
|
50
|
|
|
|
9
|
return if $@; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
0
|
scalar Geography::Countries::country($cc); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
5
|
|
|
5
|
1
|
302
|
sub countryCode() { shift->{UIL_country_code} } |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
1
|
1
|
5
|
sub organization() { shift->{UIL_organization} } |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
#----------------------------------------- |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub phone() |
84
|
3
|
|
|
3
|
1
|
7
|
{ my $self = shift; |
85
|
|
|
|
|
|
|
|
86
|
3
|
50
|
|
|
|
13
|
my $phone = $self->{UIL_phone} or return (); |
87
|
3
|
100
|
|
|
|
12
|
my @phone = ref $phone ? @$phone : $phone; |
88
|
3
|
100
|
|
|
|
15
|
wantarray ? @phone : $phone[0]; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub fax() |
93
|
3
|
|
|
3
|
1
|
1438
|
{ my $self = shift; |
94
|
|
|
|
|
|
|
|
95
|
3
|
50
|
|
|
|
11
|
my $fax = $self->{UIL_fax} or return (); |
96
|
3
|
100
|
|
|
|
13
|
my @fax = ref $fax ? @$fax : $fax; |
97
|
3
|
100
|
|
|
|
14
|
wantarray ? @fax : $fax[0]; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#----------------------------------------- |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub fullAddress() |
104
|
2
|
|
|
2
|
1
|
1706
|
{ my $self = shift; |
105
|
2
|
|
50
|
|
|
7
|
my $cc = $self->countryCode || 'en'; |
106
|
|
|
|
|
|
|
|
107
|
2
|
|
|
|
|
5
|
my ($address, $pc); |
108
|
2
|
100
|
|
|
|
6
|
if($address = $self->pobox) { $pc = $self->poboxPostalCode } |
|
1
|
|
|
|
|
3
|
|
109
|
1
|
|
|
|
|
3
|
else { $address = $self->street; $pc = $self->postalCode } |
|
1
|
|
|
|
|
3
|
|
110
|
|
|
|
|
|
|
|
111
|
2
|
|
|
|
|
7
|
my ($org, $city, $state) = @$self{ qw/UIL_organization UIL_city UIL_state/ }; |
112
|
2
|
50
|
33
|
|
|
12
|
return unless defined $city && defined $address; |
113
|
|
|
|
|
|
|
|
114
|
2
|
|
|
|
|
5
|
my $country = $self->country; |
115
|
2
|
50
|
|
|
|
10
|
$country |
|
|
100
|
|
|
|
|
|
116
|
|
|
|
|
|
|
= defined $country ? "\n$country" |
117
|
|
|
|
|
|
|
: defined $cc ? "\n".uc($cc) |
118
|
|
|
|
|
|
|
: ''; |
119
|
|
|
|
|
|
|
|
120
|
2
|
100
|
|
|
|
7
|
if(defined $org) {$org .= "\n"} else {$org = ''}; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
121
|
|
|
|
|
|
|
|
122
|
2
|
50
|
|
|
|
6
|
if($cc eq 'nl') |
123
|
2
|
50
|
33
|
|
|
26
|
{ $pc = "$1 ".uc($2)." " if defined $pc && $pc =~ m/(\d{4})\s*([a-zA-Z]{2})/; |
124
|
2
|
|
|
|
|
15
|
return "$org$address\n$pc$city$country\n"; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
else |
127
|
0
|
|
0
|
|
|
|
{ $state ||= ''; |
128
|
0
|
|
|
|
|
|
return "$org$address\n$city$state$country\n$pc"; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |
133
|
|
|
|
|
|
|
|