--- trunk/Nos.pm 2005/05/25 15:03:10 52 +++ trunk/Nos.pm 2005/06/21 09:14:54 56 @@ -16,7 +16,7 @@ our @EXPORT = qw( ); -our $VERSION = '0.4'; +our $VERSION = '0.5'; use Class::DBI::Loader; use Email::Valid; @@ -129,9 +129,10 @@ list => "My list", email => "john.doe@example.com", name => "John A. Doe", + ext_id => 42, ); -C parametar is optional. +C and C parametars are optional. Return member ID if user is added. @@ -145,6 +146,7 @@ my $email = lc($arg->{'email'}) || croak "can't add user without e-mail"; my $name = $arg->{'name'} || ''; my $list_name = lc($arg->{'list'}) || croak "need list name"; + my $ext_id = $arg->{'ext_id'}; my $list = $self->_get_list($list_name) || croak "list $list_name doesn't exist"; @@ -167,6 +169,11 @@ $this_user->update; } + if (defined($ext_id) && ($this_user->ext_id || '') ne $ext_id) { + $this_user->ext_id($ext_id); + $this_user->update; + } + my $user_on_list = $user_list->find_or_create({ user_id => $this_user->id, list_id => $list->id, @@ -194,7 +201,8 @@ email => 'dpavlin@rot13.org } -If list is not found, returns false. +If list is not found, returns false. If there is C in user data, +that will also be returned. =cut @@ -218,6 +226,9 @@ email => $user_on_list->user_id->email, }; + my $ext_id = $user_on_list->user_id->ext_id; + $row->{'ext_id'} = $ext_id if (defined($ext_id)); + push @results, $row; } @@ -661,6 +672,7 @@ $message_id = NewList( list => 'My list', + from => 'Name of my list', email => 'my-list@example.com' ); @@ -671,7 +683,7 @@ if ($_[0] !~ m/^HASH/) { return $nos->new_list( - list => $_[0], email => $_[1], + list => $_[0], from => $_[1], email => $_[2], ); } else { return $nos->new_list( %{ shift @_ } );