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