16 |
our @EXPORT = qw( |
our @EXPORT = qw( |
17 |
); |
); |
18 |
|
|
19 |
our $VERSION = '0.4'; |
our $VERSION = '0.5'; |
20 |
|
|
21 |
use Class::DBI::Loader; |
use Class::DBI::Loader; |
22 |
use Email::Valid; |
use Email::Valid; |
129 |
list => "My list", |
list => "My list", |
130 |
email => "john.doe@example.com", |
email => "john.doe@example.com", |
131 |
name => "John A. Doe", |
name => "John A. Doe", |
132 |
|
ext_id => 42, |
133 |
); |
); |
134 |
|
|
135 |
C<name> parametar is optional. |
C<name> and C<ext_id> parametars are optional. |
136 |
|
|
137 |
Return member ID if user is added. |
Return member ID if user is added. |
138 |
|
|
146 |
my $email = lc($arg->{'email'}) || croak "can't add user without e-mail"; |
my $email = lc($arg->{'email'}) || croak "can't add user without e-mail"; |
147 |
my $name = $arg->{'name'} || ''; |
my $name = $arg->{'name'} || ''; |
148 |
my $list_name = lc($arg->{'list'}) || croak "need list name"; |
my $list_name = lc($arg->{'list'}) || croak "need list name"; |
149 |
|
my $ext_id = $arg->{'ext_id'}; |
150 |
|
|
151 |
my $list = $self->_get_list($list_name) || croak "list $list_name doesn't exist"; |
my $list = $self->_get_list($list_name) || croak "list $list_name doesn't exist"; |
152 |
|
|
169 |
$this_user->update; |
$this_user->update; |
170 |
} |
} |
171 |
|
|
172 |
|
if (defined($ext_id) && ($this_user->ext_id || '') ne $ext_id) { |
173 |
|
$this_user->ext_id($ext_id); |
174 |
|
$this_user->update; |
175 |
|
} |
176 |
|
|
177 |
my $user_on_list = $user_list->find_or_create({ |
my $user_on_list = $user_list->find_or_create({ |
178 |
user_id => $this_user->id, |
user_id => $this_user->id, |
179 |
list_id => $list->id, |
list_id => $list->id, |
201 |
email => 'dpavlin@rot13.org |
email => 'dpavlin@rot13.org |
202 |
} |
} |
203 |
|
|
204 |
If list is not found, returns false. |
If list is not found, returns false. If there is C<ext_id> in user data, |
205 |
|
that will also be returned. |
206 |
|
|
207 |
=cut |
=cut |
208 |
|
|
226 |
email => $user_on_list->user_id->email, |
email => $user_on_list->user_id->email, |
227 |
}; |
}; |
228 |
|
|
229 |
|
my $ext_id = $user_on_list->user_id->ext_id; |
230 |
|
$row->{'ext_id'} = $ext_id if (defined($ext_id)); |
231 |
|
|
232 |
push @results, $row; |
push @results, $row; |
233 |
} |
} |
234 |
|
|
672 |
|
|
673 |
$message_id = NewList( |
$message_id = NewList( |
674 |
list => 'My list', |
list => 'My list', |
675 |
|
from => 'Name of my list', |
676 |
email => 'my-list@example.com' |
email => 'my-list@example.com' |
677 |
); |
); |
678 |
|
|
683 |
|
|
684 |
if ($_[0] !~ m/^HASH/) { |
if ($_[0] !~ m/^HASH/) { |
685 |
return $nos->new_list( |
return $nos->new_list( |
686 |
list => $_[0], email => $_[1], |
list => $_[0], from => $_[1], email => $_[2], |
687 |
); |
); |
688 |
} else { |
} else { |
689 |
return $nos->new_list( %{ shift @_ } ); |
return $nos->new_list( %{ shift @_ } ); |