spam settings, RT#15987
[freeside.git] / FS / FS / part_export / status_shellcommands.pm
1 package FS::part_export::status_shellcommands;
2 use base qw( FS::part_export::shellcommands );
3
4 use vars qw( %info );
5 use Tie::IxHash;
6 use String::ShellQuote;
7
8 tie my %options, 'Tie::IxHash',
9   'user' => { label=>'Remote username', default=>'root' },
10
11   'spam_enable'     => { label=>'Spam filtering enable command', },
12   'spam_disable'    => { label=>'Spam filtering disable command', },
13   'spam_tag2_level'  => { label=>'Spam set tag2 level command', },
14   'spam_kill_level' => { label=>'Spam set kill level command', },
15
16   'ignore_all_output' => {
17     label => 'Ignore all output and errors from the command',
18     type  => 'checkbox',
19   },
20 ;
21
22 %info = (
23   'svc'      => 'svc_acct',
24   'desc'     => 'Set mailbox status via shell commands',
25   'options'  => \%options,
26   'nodomain' => '',
27   'notes'    => <<END
28 Set mailbox status information (vacation and spam settings) with shell commands.
29 END
30 );
31
32 #don't want to inherit these from shellcommands
33 sub _export_insert    {}
34 sub _export_replace   {}
35 sub _export_delete    {}
36 sub _export_suspend   {}
37 sub _export_unsuspend {}
38
39 sub export_setstatus {
40   my($self, $svc_acct, $hashref) = @_;
41
42   my @shellargs = (
43     $svc_acct->svcnum,
44     user          => $self->option('user') || 'root',
45     host          => $self->machine,
46     #stdin_string  => $stdin_string,
47     ignore_all_output => $self->option('ignore_all_output'),
48     #ignored_errors    => $self->option('ignored_errors') || '',
49   );
50
51   $self->shellcommands_queue( @shallargs, 'command' =>
52     $self->option('spam_enable'). ' '.
53     shell_quote($svc_acct->email)
54   );
55
56   $self->shellcommands_queue( @shallargs, 'command' =>
57     $self->option('spam_tag2_level'). ' '.
58     shell_quote($svc_acct->email). ' '.
59     $hashref->{'spam_tag2_level'}
60   );
61
62   $self->shellcommands_queue( @shallargs, 'command' =>
63     $self->option('spam_kill_level'). ' '.
64     shell_quote($svc_acct->email). ' '.
65     $hashref->{'spam_kill_level'}
66   );
67
68 }
69
70 1;