line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Subscribe.pm 1335 2003-08-13 13:08:05Z richardc $ |
2
|
|
|
|
|
|
|
package Siesta::Plugin::Subscribe; |
3
|
3
|
|
|
3
|
|
2731
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
91
|
|
4
|
3
|
|
|
3
|
|
18
|
use Siesta::Plugin; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
20
|
|
5
|
3
|
|
|
3
|
|
1648
|
use String::Random; |
|
3
|
|
|
|
|
6758
|
|
|
3
|
|
|
|
|
163
|
|
6
|
3
|
|
|
3
|
|
21
|
use base 'Siesta::Plugin'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
1209
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub description { |
9
|
1
|
|
|
1
|
0
|
656
|
'A system plugin used for subscribing a member to the list'; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub process { |
13
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
14
|
1
|
|
|
|
|
2
|
my $mail = shift; |
15
|
1
|
|
|
|
|
44
|
my $list = $self->list; |
16
|
1
|
|
|
|
|
72
|
my $email = $mail->from; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# check to see if they're already subbed |
19
|
1
|
50
|
|
|
|
21
|
if ( $list->is_member($email) ) { |
20
|
0
|
|
|
|
|
0
|
$mail->reply( body => Siesta->bake('subscribe_already', |
21
|
|
|
|
|
|
|
list => $list, |
22
|
|
|
|
|
|
|
message => $mail) ); |
23
|
0
|
|
|
|
|
0
|
return 1; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
946
|
my $user = Siesta::Member->load( $email ); |
27
|
1
|
|
|
|
|
3
|
my $newuser; |
28
|
1
|
50
|
|
|
|
4
|
unless ($user) { |
29
|
0
|
|
|
|
|
0
|
my $password = String::Random->new->randpattern('......'); |
30
|
0
|
|
|
|
|
0
|
$user = Siesta::Member->create({ email => $email, |
31
|
|
|
|
|
|
|
password => $password }); |
32
|
0
|
|
|
|
|
0
|
$newuser = 1; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# add the user to the list and if that fails, send an error |
36
|
1
|
50
|
|
|
|
84
|
unless ( $list->add_member( $user ) ) { |
37
|
|
|
|
|
|
|
# mail them and reject them |
38
|
0
|
|
|
|
|
0
|
$mail->reply( body => Siesta->bake('subscribe_already', |
39
|
|
|
|
|
|
|
list => $list, |
40
|
|
|
|
|
|
|
message => $mail) ); |
41
|
0
|
|
|
|
|
0
|
return 1; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# mail the listowner and tell them that someone subbed |
45
|
1
|
|
|
|
|
56006
|
$mail->reply( to => $list->owner->email, |
46
|
|
|
|
|
|
|
body => Siesta->bake('subscribe_notify', |
47
|
|
|
|
|
|
|
list => $list, |
48
|
|
|
|
|
|
|
user => $user, |
49
|
|
|
|
|
|
|
message => $mail ) |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# mail the person and tell them that they've been subbed |
53
|
1
|
|
|
|
|
15
|
$mail->reply( body => Siesta->bake('subscribe_reply', |
54
|
|
|
|
|
|
|
list => $list, |
55
|
|
|
|
|
|
|
message => $mail, |
56
|
|
|
|
|
|
|
user => $user, |
57
|
|
|
|
|
|
|
newuser => $newuser, |
58
|
|
|
|
|
|
|
) |
59
|
|
|
|
|
|
|
); |
60
|
1
|
|
|
|
|
8
|
return 1; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|