summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2012-04-16 18:13:29 -0700
committerIvan Kohler <ivan@freeside.biz>2012-04-16 18:13:29 -0700
commit71cbdde5012550846390e9f0ebafdb48e06da5e8 (patch)
treef79e26df553e28abf955e982c7b813e25a9ea2eb
parent6f01c7cd5ed2945e9a999d8dd0ec5f27a26358b0 (diff)
add default feature list to netsapiens export, RT#17319
-rw-r--r--FS/FS/part_export/netsapiens.pm57
-rw-r--r--httemplate/edit/part_export.cgi3
2 files changed, 57 insertions, 3 deletions
diff --git a/FS/FS/part_export/netsapiens.pm b/FS/FS/part_export/netsapiens.pm
index 775e374..adc1942 100644
--- a/FS/FS/part_export/netsapiens.pm
+++ b/FS/FS/part_export/netsapiens.pm
@@ -33,6 +33,15 @@ tie my %dialplan_fields, 'Tie::IxHash',
'from_user' => { label=>'Source User Translation' },
;
+my %features = (
+ 'for' => 'Forward',
+ 'fnr' => 'Forward Not Registered',
+ 'fna' => 'Forward No Answer',
+ 'fbu' => 'Forward Busy',
+ 'dnd' => 'Do-Not-Disturb',
+ 'sim' => 'Simultaneous Ring',
+);
+
tie my %options, 'Tie::IxHash',
'login' => { label=>'NetSapiens tac2 User API username' },
'password' => { label=>'NetSapiens tac2 User API password' },
@@ -44,6 +53,12 @@ tie my %options, 'Tie::IxHash',
'domain_no_tld' => { label=>'Omit TLD from domains', type=>'checkbox' },
'debug' => { label=>'Enable debugging', type=>'checkbox' },
%subscriber_fields,
+ 'features' => { label => 'Default features',
+ type => 'select',
+ multiple => 1,
+ options => [ keys %features ],
+ option_label => sub { $features{$_[0]}; },
+ },
%registrar_fields,
%dialplan_fields,
'did_countrycode' => { label=>'Use country code in DID destination',
@@ -61,6 +76,8 @@ from CPAN.
END
);
+# http://devguide.netsapiens.com/
+
sub rebless { shift; }
sub ns_command {
@@ -130,6 +147,14 @@ sub ns_registrar {
'/registrar_config/'. $self->ns_devicename($svc_phone);
}
+sub ns_feature {
+ my($self, $svc_phone, $feature) = (shift, shift, shift);
+
+ $self->ns_subscriber($svc_phone).
+ "/feature_config/$feature,*,*,*,*";
+
+}
+
sub ns_devicename {
my( $self, $svc_phone ) = (shift, shift);
@@ -186,7 +211,9 @@ sub ns_create_or_update {
my ($email) = ($cust_main->invoicing_list_emailonly, '');
my $custnum = $cust_main->custnum;
+ ###
# Piece 1 (already done) - User creation
+ ###
$phonenum =~ /^(\d{3})/;
my $area_code = $1;
@@ -213,7 +240,31 @@ sub ns_create_or_update {
join(', ', $self->ns_parse_response( $ns->responseContent ) );
}
- #Piece 2 - sip device creation
+ ###
+ # Piece 1.5 - feature creation
+ ###
+ foreach $feature (split /\s+/, $self->option('features') ) {
+
+ my $nsf = $self->ns_command( 'PUT', $self->ns_feature($feature),
+ 'control' => 'd', #User Control, disable
+ 'expires' => 'never',
+ #'ts' => '', #?
+ #'parameters' => '',
+ 'hour_match' => '*',
+ 'time_frame' => '*',
+ 'activation' => 'now',
+ );
+
+ if ( $nsf->responseCode !~ /^2/ ) {
+ return $nsf->responseCode. ' '.
+ join(', ', $self->ns_parse_response( $ns->responseContent ) );
+ }
+
+ }
+
+ ###
+ # Piece 2 - sip device creation
+ ###
my $ns2 = $self->ns_command( 'PUT', $self->ns_registrar($svc_phone),
'termination_match' => $self->ns_devicename($svc_phone),
@@ -227,7 +278,9 @@ sub ns_create_or_update {
join(', ', $self->ns_parse_response( $ns2->responseContent ) );
}
- #Piece 3 - DID mapping to user
+ ###
+ # Piece 3 - DID mapping to user
+ ###
my $ns3 = $self->ns_command( 'PUT', $self->ns_dialplan($svc_phone),
'to_user' => $phonenum,
diff --git a/httemplate/edit/part_export.cgi b/httemplate/edit/part_export.cgi
index 1450ac3..d7219b7 100644
--- a/httemplate/edit/part_export.cgi
+++ b/httemplate/edit/part_export.cgi
@@ -106,7 +106,8 @@ my $widget = new HTML::Widgets::SelectLayers(
}
if ( $type eq 'select' ) {
my $size = defined($optinfo->{size}) ? " SIZE=" . $optinfo->{size} : '';
- my $multi = defined($optinfo->{multi}) ? ' MULTIPLE' : '';
+ my $multi = ($optinfo->{multi} || $optinfo->{multiple})
+ ? ' MULTIPLE' : '';
$html .= qq!<SELECT NAME="$option"$multi$size>!;
my @values = split '\s+', $value if $multi;
my @options;