summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2005-08-08 15:15:50 +0000
committerivan <ivan>2005-08-08 15:15:50 +0000
commit7600393bd5aa643ae776a2149174fc63d372dd8f (patch)
tree35def851dc34971baf4ffd5462f05d34e2774f1d
parenta8f346a5aeb4f32fa40cfd9c08bf2631ff79286b (diff)
add export to everyone.net outsource mail service
-rw-r--r--Changes.1.5.81
-rw-r--r--FS/FS/part_export/everyone_net.pm129
2 files changed, 130 insertions, 0 deletions
diff --git a/Changes.1.5.8 b/Changes.1.5.8
index 06b512a..9551d68 100644
--- a/Changes.1.5.8
+++ b/Changes.1.5.8
@@ -3,3 +3,4 @@
- add unlinked mail forward (svc_forward) report
- move cust_pkg search (httemplate/search/cust_pkg.cgi) to new template
- add active/suspended/cancelled customer packages to agent browse
+- add export to everyone.net outsource mail service
diff --git a/FS/FS/part_export/everyone_net.pm b/FS/FS/part_export/everyone_net.pm
new file mode 100644
index 0000000..5a85b8d
--- /dev/null
+++ b/FS/FS/part_export/everyone_net.pm
@@ -0,0 +1,129 @@
+package FS::part_export::everyone_net;
+
+use vars qw(@ISA %info);
+use Tie::IxHash;
+use FS::part_export;
+
+@ISA = qw(FS::part_export);
+
+tie my %options, 'Tie::IxHash',
+ 'clientID' => { label=>'clientID' },
+ 'password' => { label=>'Password' },
+ #'workgroup' => { label=>'Default Workgroup' },
+;
+
+%info = (
+ 'svc' => 'svc_acct',
+ 'desc' => 'Real-time export to Everyone.net outsourced mail service',
+ 'options'=> \%options,
+ 'notes' => <<'END'
+Real-time export to
+<a href="http://www.cp.net/">Everyone.net</a> via the XRC Remote API.
+Requires installation of
+<a href="http://search.cpan.org/dist/Net-XRC">Net::XRC</a>
+from CPAN.
+END
+);
+
+sub rebless { shift; }
+
+# experiement: want the status of these right away (don't want account to
+# create or whatever and then get error in the queue from dup username or
+# something), so no queueing
+
+sub _export_insert {
+ my( $self, $svc_acct ) = (shift, shift);
+
+ eval "use Net::XRC qw(:types);";
+ return $@ if $@;
+
+ $self->_xrc_command( 'createUser',
+ $svc_acct->domain,
+ [],
+ string($svc_acct->username),
+ string($svc_acct->_password),
+ );
+}
+
+sub _xrc_command {
+ my( $self, $method, $domain, @args ) = @_;
+
+ eval "use Net::XRC qw(:types);";
+ return $@ if $@;
+
+ my $xrc = new Net::XRC (
+ 'clientID' => $self->option('clientID'),
+ 'password' => $self->option('password'),
+ );
+
+ my $dresponse = $xrc->lookupMXReadyClientIDByEmailDomain( string($domain) );
+ return $response->error unless $response->is_success;
+ my $clientID = $response->content;
+ return "clientID for domain $domain not found"
+ if $clientID == -1;
+
+ my $response = $xrc->$method($clientID, @args);
+ return $response->error unless $response->is_success;
+ '';
+
+}
+
+sub _export_replace {
+ my( $self, $new, $old ) = (shift, shift, shift);
+
+ eval "use Net::XRC qw(:types);";
+ return $@ if $@;
+
+ return "can't change domain with Everyone.net"
+ if $old->domain ne $new->domain;
+ return "can't change username with Everyone.net"
+ if $old->username ne $new->username;
+ return '' unless $old->_password ne $new->_password;
+
+ $self->_xrc_command( 'setUserPassword',
+ $new->domain,
+ $domain_clientID,
+ string($new->username),
+ string($new->_password),
+ );
+}
+
+sub _export_delete {
+ my( $self, $svc_acct ) = (shift, shift);
+
+ eval "use Net::XRC qw(:types);";
+ return $@ if $@;
+
+ $self->_xrc_command( 'deleteUser',
+ $svc_acct->domain,
+ string($svc_acct->username),
+ );
+}
+
+sub _export_suspend {
+ my( $self, $svc_acct ) = (shift, shift);
+
+ eval "use Net::XRC qw(:types);";
+ return $@ if $@;
+
+ $self->_xrc_command( 'suspendUser',
+ $svc_acct->domain,
+ $domain_clientID,
+ string($svc_acct->username),
+ );
+}
+
+sub _export_unsuspend {
+ my( $self, $svc_acct ) = (shift, shift);
+
+ eval "use Net::XRC qw(:types);";
+ return $@ if $@;
+
+ $self->_xrc_command( 'unsuspendUser',
+ $svc_acct->domain,
+ string($svc_acct->username),
+ );
+}
+
+1;
+