[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 1d290564e5fe8cb9468d3369665f9587e0c06cf5

Ivan ivan at 420.am
Mon Apr 16 18:13:31 PDT 2012


The branch, FREESIDE_2_3_BRANCH has been updated
       via  1d290564e5fe8cb9468d3369665f9587e0c06cf5 (commit)
      from  7274cc188efe722c252c22489123f728331852a5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1d290564e5fe8cb9468d3369665f9587e0c06cf5
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Apr 16 18:13:30 2012 -0700

    add default feature list to netsapiens export, RT#17319

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;

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/part_export/netsapiens.pm |   57 +++++++++++++++++++++++++++++++++++++-
 httemplate/edit/part_export.cgi |    3 +-
 2 files changed, 57 insertions(+), 3 deletions(-)




More information about the freeside-commits mailing list