/[notice-sender]/trunk/Nos.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/Nos.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 52 by dpavlin, Wed May 25 15:03:10 2005 UTC revision 56 by dpavlin, Tue Jun 21 09:14:54 2005 UTC
# Line 16  our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all' Line 16  our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'
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;
# Line 129  Add new member to list Line 129  Add new member to list
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    
# Line 145  sub add_member_to_list { Line 146  sub add_member_to_list {
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    
# Line 167  sub add_member_to_list { Line 169  sub add_member_to_list {
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,
# Line 194  Returns array of hashes with user inform Line 201  Returns array of hashes with user inform
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    
# Line 218  sub list_members { Line 226  sub list_members {
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    
# Line 661  sub new { Line 672  sub new {
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    
# Line 671  sub NewList { Line 683  sub NewList {
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 @_ } );

Legend:
Removed from v.52  
changed lines
  Added in v.56

  ViewVC Help
Powered by ViewVC 1.1.26