vpopmail restart export option
[freeside.git] / eg / export_template.pm
1 package FS::part_export::myexport;
2
3 use vars qw(@ISA);
4 use FS::part_export;
5
6 @ISA = qw(FS::part_export);
7
8 sub rebless { shift; }
9
10 sub _export_insert {
11   my($self, $svc_something) = (shift, shift);
12   $err_or_queue = $self->myexport_queue( $svc_something->svcnum, 'insert',
13     $svc_something->username, $svc_something->_password );
14   ref($err_or_queue) ? '' : $err_or_queue;
15 }
16
17 sub _export_replace {
18   my( $self, $new, $old ) = (shift, shift, shift);
19   #return "can't change username with myexport"
20   #  if $old->username ne $new->username;
21   #return '' unless $old->_password ne $new->_password;
22   $err_or_queue = $self->myexport_queue( $new->svcnum,
23     'replace', $new->username, $new->_password );
24   ref($err_or_queue) ? '' : $err_or_queue;
25 }
26
27 sub _export_delete {
28   my( $self, $svc_something ) = (shift, shift);
29   $err_or_queue = $self->myexport_queue( $svc_something->svcnum,
30     'delete', $svc_something->username );
31   ref($err_or_queue) ? '' : $err_or_queue;
32 }
33
34 #a good idea to queue anything that could fail or take any time
35 sub myexport_queue {
36   my( $self, $svcnum, $method ) = (shift, shift, shift);
37   my $queue = new FS::queue {
38     'svcnum' => $svcnum,
39     'job'    => "FS::part_export::myexport::myexport_$method",
40   };
41   $queue->insert( @_ ) or $queue;
42 }
43
44 sub myexport_insert { #subroutine, not method
45   my( $username, $password ) = @_;
46   #do things with $username and $password
47 }
48
49 sub myexport_replace { #subroutine, not method
50 }
51
52 sub myexport_delete { #subroutine, not method
53   my( $username ) = @_;
54   #do things with $username
55 }
56