/[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 32 by dpavlin, Mon May 16 22:32:58 2005 UTC revision 33 by dpavlin, Tue May 17 11:09:08 2005 UTC
# Line 77  sub new { Line 77  sub new {
77  }  }
78    
79    
80    =head2 new_list
81    
82    Create new list
83    
84     $nos->new_list(
85            list => 'My list",
86            email => 'my-list@example.com',
87     );
88    
89    Returns ID of newly created list.
90    
91    =cut
92    
93    sub new_list {
94            my $self = shift;
95    
96            my $arg = {@_};
97    
98            confess "need list name" unless ($arg->{'list'});
99            confess "need list email" unless ($arg->{'list'});
100    
101            my $l = $self->_get_list($arg->{'list'}) ||
102                    $self->_add_list( @_ ) ||
103                    return undef;
104    
105            return $l->id;
106    }
107    
108    
109  =head2 add_member_to_list  =head2 add_member_to_list
110    
111  Add new member to list  Add new member to list
# Line 105  sub add_member_to_list { Line 134  sub add_member_to_list {
134          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";
135    
136          if (! Email::Valid->address($email)) {          if (! Email::Valid->address($email)) {
137                  carp "SKIPPING $name <$email>\n" if ($self->{'verbose'});                  carp "SKIPPING $name <$email>\n";
138                  return 0;                  return 0;
139          }          }
140    
# Line 116  sub add_member_to_list { Line 145  sub add_member_to_list {
145    
146          my $this_user = $users->find_or_create({          my $this_user = $users->find_or_create({
147                  email => $email,                  email => $email,
                 full_name => $name,  
148          }) || croak "can't find or create member\n";          }) || croak "can't find or create member\n";
149    
150            if ($name && $this_user->full_name ne $name) {
151                    $this_user->full_name($name || '');
152                    $this_user->update;
153            }
154    
155          my $user_on_list = $user_list->find_or_create({          my $user_on_list = $user_list->find_or_create({
156                  user_id => $this_user->id,                  user_id => $this_user->id,
157                  list_id => $list->id,                  list_id => $list->id,

Legend:
Removed from v.32  
changed lines
  Added in v.33

  ViewVC Help
Powered by ViewVC 1.1.26