summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2010-02-21 22:54:10 +0000
committerivan <ivan>2010-02-21 22:54:10 +0000
commit16941ee3099833522bb8b7ac3cdf88b4a5f0ad89 (patch)
tree2cf1833942bbec40d369f476549f00a05bd4016c
parent61ec626ec5e6493a16dcb9d4cabcd826f1306b5b (diff)
communigate forwarders, RT#7083
-rw-r--r--FS/FS/Conf.pm7
-rw-r--r--FS/FS/part_export/communigate_pro.pm55
-rwxr-xr-xhttemplate/edit/svc_forward.cgi45
-rwxr-xr-xhttemplate/view/svc_forward.cgi32
4 files changed, 107 insertions, 32 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 0b4000e4c..54b173ab3 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -2418,6 +2418,13 @@ worry that config_items is freeside-specific and icky.
},
{
+ 'key' => 'svc_forward-no_srcsvc',
+ 'section' => '',
+ 'description' => "Don't allow forwards from existing accounts, only arbitrary addresses. Useful when exporting to systems such as Communigate Pro which treat forwards in this fashion.",
+ 'type' => 'checkbox',
+ },
+
+ {
'key' => 'svc_forward-arbitrary_dst',
'section' => '',
'description' => "Allow forwards to point to arbitrary strings that don't necessarily look like email addresses. Only used when using forwards for weird, non-email things.",
diff --git a/FS/FS/part_export/communigate_pro.pm b/FS/FS/part_export/communigate_pro.pm
index e07010b0b..855651370 100644
--- a/FS/FS/part_export/communigate_pro.pm
+++ b/FS/FS/part_export/communigate_pro.pm
@@ -94,7 +94,6 @@ sub _export_insert_svc_acct {
#let's do the create realtime too, for much the same reasons, and to avoid
#pain of trying to queue w/dep the prefs & aliases
- #my $r=
eval { $self->communigate_pro_runcommand( @options ) };
return $@ if $@;
@@ -142,8 +141,18 @@ sub _export_insert_svc_domain {
$self->communigate_pro_queue( @options );
}
-#sub _export_insert_svc_forward {
-#}
+sub _export_insert_svc_forward {
+ my( $self, $svc_forward ) = (shift, shift);
+
+ my $src = $svc_forward->src || $svc_forward->srcsvc_acct->email;
+ my $dst = $svc_forward->dst || $svc_forward->dstsvc_acct->email;
+
+ #real-time here, presuming CGP does some dup detection?
+ eval { $self->communigate_pro_runcommand( 'CreateForwarder', $src, $dst); };
+ return $@ if $@;
+
+ '';
+}
sub _export_replace {
my( $self, $new, $old ) = (shift, shift, shift);
@@ -160,7 +169,6 @@ sub _export_replace_svc_acct {
#w/dependencies. we don't want FS winding up out-of-sync with the wrong
#username and a queued job anyway. right??
if ( $self->export_username($old) ne $self->export_username($new) ) {
- #my $r =
eval { $self->communigate_pro_runcommand(
'RenameAccount',
$self->export_username($old),
@@ -258,6 +266,35 @@ sub _export_replace_svc_domain {
'';
}
+sub _export_replace_svc_forward {
+ my( $self, $new, $old ) = (shift, shift, shift);
+
+ my $osrc = $old->src || $old->srcsvc_acct->email;
+ my $nsrc = $new->src || $new->srcsvc_acct->email;
+ my $odst = $old->dst || $old->dstsvc_acct->email;
+ my $ndst = $new->dst || $new->dstsvc_acct->email;
+
+ if ( $odst ne $ndst ) {
+
+ #no change command, so delete and create (real-time)
+ eval { $self->communigate_pro_runcommand('DeleteForwarder', $osrc) };
+ return $@ if $@;
+ eval { $self->communigate_pro_runcommand('CreateForwarder', $nsrc, $ndst)};
+ return $@ if $@;
+
+ } elsif ( $osrc ne $nsrc ) {
+
+ #real-time here, presuming CGP does some dup detection?
+ eval { $self->communigate_pro_runcommand( 'RenameForwarder', $osrc, $nsrc)};
+ return $@ if $@;
+
+ } else {
+ warn "communigate replace called for svc_forward with no changes\n";#confess
+ }
+
+ '';
+}
+
sub _export_delete {
my( $self, $svc_x ) = (shift, shift);
@@ -272,7 +309,6 @@ sub _export_delete_svc_acct {
$self->communigate_pro_queue( $svc_acct->svcnum, 'DeleteAccount',
$self->export_username($svc_acct),
);
-
}
sub _export_delete_svc_domain {
@@ -282,7 +318,14 @@ sub _export_delete_svc_domain {
$svc_domain->domain,
#XXX turn on force option for domain deletion?
);
+}
+
+sub _export_delete_svc_forward {
+ my( $self, $svc_forward ) = (shift, shift);
+ $self->communigate_pro_queue( $svc_forward->svcnum, 'DeleteForwarder',
+ ($svc_forward->src || $svc_forward->srcsvc_acct->email),
+ );
}
sub _export_suspend {
@@ -597,7 +640,7 @@ sub communigate_pro_command { #subroutine, not method
#warn "$method ". Dumper(@args) if $DEBUG;
my $return = $cli->$method(@args)
- or die "Communigate Pro error: ". $cli->getErrMessage;
+ or die "Communigate Pro error: ". $cli->getErrMessage. "\n";
$cli->Logout; # or die "Can't logout of CGPro: $CGP::ERR_STRING\n";
diff --git a/httemplate/edit/svc_forward.cgi b/httemplate/edit/svc_forward.cgi
index 96a00a5aa..73f6465b9 100755
--- a/httemplate/edit/svc_forward.cgi
+++ b/httemplate/edit/svc_forward.cgi
@@ -32,24 +32,35 @@ function dstchanged(what) {
</SCRIPT>
<% ntable("#cccccc",2) %>
-<TR><TD ALIGN="right">Email to</TD>
-<TD><SELECT NAME="srcsvc" SIZE=1 onChange="srcchanged(this)">
-% foreach $_ (keys %email) {
-
- <OPTION<% $_ eq $srcsvc ? " SELECTED" : "" %> VALUE="<% $_ %>"><% $email{$_} %></OPTION>
-% }
-% if ( $svc_forward->dbdef_table->column('src') ) {
-
- <OPTION <% $src ? 'SELECTED' : '' %> VALUE="0">(other email address)</OPTION>
-% }
-</SELECT>
-% if ( $svc_forward->dbdef_table->column('src') ) {
-
-<INPUT TYPE="text" NAME="src" VALUE="<% $src %>" <% ( $src || !scalar(%email) ) ? '' : 'DISABLED STYLE="background-color: lightgrey"' %>>
-% }
-
-</TD></TR>
+<TR>
+ <TD ALIGN="right">Email to</TD>
+ <TD>
+% if ( $conf->exists('svc_forward-no_srcsvc') ) {
+ <INPUT NAME="srcsrc" TYPE="hidden" VALUE="0">
+% } else {
+ <SELECT NAME="srcsvc" SIZE=1 onChange="srcchanged(this)">
+% foreach $_ (keys %email) {
+ <OPTION VALUE="<% $_ %>"
+ <% $_ eq $srcsvc ? 'SELECTED' : '' %>
+ ><% $email{$_} %></OPTION>
+% }
+ <OPTION VALUE="0" <% $src ? 'SELECTED' : '' %>
+ >(other email address)</OPTION>
+ </SELECT>
+% }
+
+% my $src_disabled = $src
+% || $conf->exists('svc_forward-no_srcsvc')
+% || !scalar(%email);
+ <INPUT NAME = "src"
+ TYPE = "text"
+ VALUE = "<% $src %>"
+ <% $src_disabled ? '' : 'DISABLED STYLE="background-color: lightgrey"' %>
+ >
+
+ </TD>
+</TR>
<TR><TD ALIGN="right">Forwards to</TD>
<TD><SELECT NAME="dstsvc" SIZE=1 onChange="dstchanged(this)">
diff --git a/httemplate/view/svc_forward.cgi b/httemplate/view/svc_forward.cgi
index 0847a5e65..43d8a4e8b 100755
--- a/httemplate/view/svc_forward.cgi
+++ b/httemplate/view/svc_forward.cgi
@@ -1,12 +1,26 @@
-<% include('/elements/header.html', 'Mail Forward View', menubar(
- ( ( $pkgnum || $custnum )
- ? ( "View this customer (#$display_custnum)" => "${p}view/cust_main.cgi?$custnum",
- )
- : ( "Cancel this (unaudited) mail forward" =>
- "${p}misc/cancel-unaudited.cgi?$svcnum" )
- )
-))
-%>
+% if ( $custnum ) {
+
+ <% include("/elements/header.html","View mail forward") %>
+ <% include( '/elements/small_custview.html', $custnum, '', 1,
+ "${p}view/cust_main.cgi") %>
+ <BR>
+
+% } else {
+
+ <% include("/elements/header.html",'View mail forward', menubar(
+ "Cancel this (unaudited) mail forward" =>
+ "javascript:areyousure('${p}misc/cancel-unaudited.cgi?$svcnum')",
+ ))
+ %>
+
+ <SCRIPT>
+ function areyousure(href) {
+ if (confirm("Permanently delete this mail forward?") == true)
+ window.location.href = href;
+ }
+ </SCRIPT>
+
+% }
<A HREF="<% $p %>edit/svc_forward.cgi?<% $svcnum %>">Edit this information</A>