/[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 79 by dpavlin, Thu Aug 25 11:58:15 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 731  Each element in returned array will have Line 718  Each element in returned array will have
718    
719   {   {
720          id => 42,                       # unique ID of received message          id => 42,                       # unique ID of received message
721          list => 'My list',              # useful only of filtering by email          list => 'My list',              # useful if filtering by email
722          ext_id => 9999,                 # ext_id from message user          ext_id => 9999,                 # ext_id from message sender
723          email => 'jdoe@example.com',    # e-mail of user          email => 'jdoe@example.com',    # e-mail of message sender
724          bounced => 0,                   # true value if message is bounce          bounced => 0,                   # true if message is bounce
725          date => '2005-08-24 18:57:24',  # date of recival in ISO format          date => '2005-08-24 18:57:24',  # date of receival in ISO format
726   }   }
727    
728    
# 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    
# Line 1151  sub AddMessageToList { Line 1155  sub AddMessageToList {
1155          }          }
1156  }  }
1157    
 =head1 UNIMPLEMENTED FUNCTIONS  
   
 This is a stub for documentation of unimplemented functions.  
   
1158  =head2 MessagesReceived  =head2 MessagesReceived
1159    
1160    Return statistics about received messages.
1161    
1162   my @result = MessagesReceived(   my @result = MessagesReceived(
1163          list => 'My list',          list => 'My list',
1164          email => 'jdoe@example.com',          email => 'jdoe@example.com',
1165   );   );
1166    
1167  You can specify just C<list> or C<email> or any combination of those.  You must specify C<list> or C<email> or any combination of those.
1168    
1169  For format of returned array element see C<received_messages>.  For format of returned array element see C<received_messages>.
1170    
1171    =cut
1172    
1173    sub MessagesReceived {
1174            my $self = shift;
1175    
1176            if ($_[0] !~ m/^HASH/) {
1177                    die "need at least list or email" unless (scalar @_ < 2);
1178                    return $nos->received_messages(
1179                            list => $_[0], email => $_[1],
1180                    );
1181            } else {
1182                    my $arg = shift;
1183                    die "need list or email argument" unless ($arg->{'list'} || $arg->{'email'});
1184                    return $nos->received_messages( $arg );
1185            }
1186    }
1187    
1188    ###
1189    
1190    =head1 UNIMPLEMENTED SOAP FUNCTIONS
1191    
1192    This is a stub for documentation of unimplemented functions.
1193    
1194  =head2 MessagesReceivedByDate  =head2 MessagesReceivedByDate
1195    
1196  =head2 MessagesReceivedByDateWithContent  =head2 MessagesReceivedByDateWithContent
1197    
1198  =head2 ReceivedMessasgeContent  =head2 ReceivedMessageContent
1199    
1200  Return content of received message.  Return content of received message.
1201    
1202   my $mail_body = ReceivedMessageContent( id => 42 );   my $mail_body = ReceivedMessageContent( id => 42 );
1203    
 =cut  
   
   
1204    
1205    
 ###  
1206    
1207  =head1 NOTE ON ARRAYS IN SOAP  =head1 NOTE ON ARRAYS IN SOAP
1208    

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

  ViewVC Help
Powered by ViewVC 1.1.26