/[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 76 by dpavlin, Wed Aug 24 22:11:00 2005 UTC revision 77 by dpavlin, Thu Aug 25 00:37:48 2005 UTC
# Line 27  use Email::Simple; Line 27  use Email::Simple;
27  use Email::Address;  use Email::Address;
28  use Mail::DeliveryStatus::BounceParser;  use Mail::DeliveryStatus::BounceParser;
29  use Class::DBI::AbstractSearch;  use Class::DBI::AbstractSearch;
30    use SQL::Abstract;
31  use Mail::Alias;  use Mail::Alias;
32  use Cwd qw(abs_path);  use Cwd qw(abs_path);
33    
# Line 116  sub new { Line 117  sub new {
117    
118          $self->{'hash_len'} ||= 8;          $self->{'hash_len'} ||= 8;
119    
         $self->{'loader'}->find_class('received')->set_sql(  
                 'received' => qq{  
                         select  
                                 received.id as id,  
                                 lists.name as list,  
                                 users.ext_id as ext_id,  
                                 users.email as email,  
                                 bounced,received.date as date  
                         from received  
                         join lists on lists.id = list_id  
                         join users on users.id = user_id  
                 },  
         );  
   
120          $self ? return $self : return undef;          $self ? return $self : return undef;
121  }  }
122    
# Line 744  Each element in returned array will have Line 731  Each element in returned array will have
731  sub received_messages {  sub received_messages {
732          my $self = shift;          my $self = shift;
733    
734          my $arg = {@_};          my $arg = {@_} if (@_);
735    
736          croak "need list name or email" unless ($arg->{'list'} || $arg->{'email'});  #       croak "need list name or email" unless ($arg->{'list'} || $arg->{'email'});
737    
738          $arg->{'list'} = lc($arg->{'list'});          my $sql = qq{
739          $arg->{'email'} = lc($arg->{'email'});                          select
740                                    received.id as id,
741                                    lists.name as list,
742                                    users.ext_id as ext_id,
743                                    users.email as email,
744                                    bounced,received.date as date
745                            from received
746                            join lists on lists.id = list_id
747                            join users on users.id = user_id
748            };
749    
750            my $where;
751    
752            $where->{'lists.name'} = lc($arg->{'list'}) if ($arg->{'list'});
753            $where->{'users.email'} = lc($arg->{'email'}) if ($arg->{'email'});
754    
755            # hum, yammy one-liner
756            my($stmt, @bind)  = SQL::Abstract->new->where($where);
757    
758          my @out;          my $dbh = $self->{'loader'}->find_class('received')->db_Main;
759    
760          my $sth = $self->{'loader'}->find_class('received')->sql_received;          my $sth = $dbh->prepare($sql . $stmt);
761          $sth->execute();          $sth->execute(@bind);
762          return $sth->fetchall_hash;          return $sth->fetchall_hash;
763  }  }
764    

Legend:
Removed from v.76  
changed lines
  Added in v.77

  ViewVC Help
Powered by ViewVC 1.1.26