display spam status on account view, RT#15987
[freeside.git] / FS / FS / part_export / acct_sql_status.pm
1 package FS::part_export::acct_sql_status;
2 use base qw( FS::part_export::sql_Common );
3
4 use strict;
5 use warnings;
6 use vars qw( %info );
7 use Tie::IxHash;
8
9 tie my %options, 'Tie::IxHash', %{__PACKAGE__->sql_options};
10 delete $options{$_} for qw( table schema static primary_key );
11
12 %info = (
13   'svc'      => 'svc_acct',
14   'desc'     => 'Mailbox status information from SQL',
15   'options'  => \%options,
16   'nodomain' => '',
17   'notes'    => <<END
18 Read mailbox status information (vacation and spam settings) from an SQL
19 database, tables "vacation" and "users" respectively.
20 END
21 );
22
23 sub rebless { shift; }
24
25 #don't want to inherit these from sql_Common
26 sub _export_insert    {}
27 sub _export_replace   {}
28 sub _export_delete    {}
29 sub _export_suspend   {}
30 sub _export_unsuspend {}
31
32 sub export_getstatus {
33   my($self, $svc_acct, $htmlref, $hashref) = @_;
34
35   my $dbh = DBI->connect( map $self->option($_), qw(datasrc username password) )
36     or return "can't connect: ".  $DBI::errstr;
37
38   ###
39   #vacation settings
40   ###
41
42   my $vsth = $dbh->prepare('SELECT * FROM vacation WHERE email = ?')
43     or return "can't prepare: ". $dbh->errstr;
44   $vsth->execute( $svc_acct->email )
45     or return "can't execute: ". $vsth->errstr;
46
47   my $vrow = $vsth->fetchrow_hashref;
48   if ( $vrow ) {
49     $hashref->{'vacation_active'}  = $vrow->{'active'};
50     $hashref->{'vacation_subject'} = $vrow->{'subject'};
51     $hashref->{'vacation_body'}    = $vrow->{'body'};
52 #what about these?
53 #| cache   | text         | NO   |     | NULL                |       |
54 #| domain  | varchar(255) | NO   |     | NULL                |       |
55 #and disabling "Sender e-mail address for auto-reply message:", no place for it
56   }
57
58   ###
59   #spam settings
60   ###
61
62   my $ssth = $dbh->prepare('SELECT * FROM users WHERE address = ?')
63     or return "can't prepare: ". $dbh->errstr;
64   $ssth->execute( $svc_acct->email )
65     or return "can't execute: ". $ssth->errstr;
66
67   my $srow = $ssth->fetchrow_hashref;
68   if ( $srow ) {
69     $hashref->{'spam_tag_level'}     = $srow->{'spam_tag_level'};
70     $hashref->{'spam_tag2_level'}    = $srow->{'spam_tag2_level'};
71     $hashref->{'spam_kill_level'}    = $srow->{'spam_kill_level'};
72     $hashref->{'bypass_spam_checks'} = $srow->{'bypass_spam_checks'};
73     $hashref->{'spam_tag2_level'}    = $srow->{'spam_tag2_level'};
74   }
75
76   ###
77   # spam allow/deny list
78   ###
79
80   #my $lsth = $dbh->prepare('SELECT * FROM 
81
82   #htmlref not implemented/used for this status export
83
84
85   ''; #no errors
86
87 }
88
89 1;