From 71cbdde5012550846390e9f0ebafdb48e06da5e8 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Mon, 16 Apr 2012 18:13:29 -0700 Subject: [PATCH] add default feature list to netsapiens export, RT#17319 --- FS/FS/part_export/netsapiens.pm | 57 +++++++++++++++++++++++++++++++++++++++-- httemplate/edit/part_export.cgi | 3 ++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/FS/FS/part_export/netsapiens.pm b/FS/FS/part_export/netsapiens.pm index 775e374ca..adc19427b 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 1450ac3b3..d7219b74a 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!