cardfortress backend support
authorivan <ivan>
Fri, 10 Dec 2010 22:08:36 +0000 (22:08 +0000)
committerivan <ivan>
Fri, 10 Dec 2010 22:08:36 +0000 (22:08 +0000)
FS/FS/Conf.pm
FS/FS/Schema.pm
FS/FS/part_export/cardfortress.pm [new file with mode: 0644]
FS/FS/svc_acct.pm
httemplate/edit/process/svc_acct.cgi
httemplate/view/svc_acct.cgi
httemplate/view/svc_acct/cardfortress.html [new file with mode: 0644]

index ebeebb2..a05ad03 100644 (file)
@@ -4103,6 +4103,13 @@ and customer address. Include units.',
                     ],
   },
 
+  {
+    'key'         => 'svc_acct-cf_privatekey-message',
+    'section'     => '',
+    'description' => 'For internal use: HTML displayed when cf_privatekey field is set.',
+    'type'        => 'textarea',
+  },
+
   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
index 70aab43..b48e5af 100644 (file)
@@ -1746,6 +1746,8 @@ sub tables_hashref {
         'pbxsvc',    'int', 'NULL', '', '', '',
         'last_login',  @date_type, '', '', 
         'last_logout', @date_type, '', '', 
+        #cardfortress field(s)
+        'cf_privatekey',      'text', 'NULL',      '', '', '',
         #communigate pro fields (quota = MaxAccountSize)
         'cgp_aliases',     'varchar', 'NULL',     255, '', '',
         #settings
@@ -3094,7 +3096,43 @@ sub tables_hashref {
       'unique' => [],
       'index'  => [], #recnum
     },
+
+    'nms_device' => {
+      'columns' => [
+        'nms_devicenum', 'serial',     '',      '', '', '',
+        #'agentnum',         'int', 'NULL',      '', '', '',
+        'devicename',   'varchar',     '', $char_d, '', '',
+        'ip',           'varchar',     '',      15, '', '', 
+        'protocol',     'varchar',     '', $char_d, '', '',
+#        'last',     'int',     '',    '', '', '', 
+      ],
+      'primary_key' => 'nms_devicenum',
+      'unique' => [],
+      'index'  => [],
+    },
    
+    'nms_deviceport' => {
+      'columns' => [
+        'portnum',       'serial',     '', '', '', '', 
+        'nms_devicenum',    'int',     '', '', '', '', 
+        'deviceport',       'int',     '', '', '', '', 
+        #'ip',       'varchar', 'NULL', 15, '', '', 
+        'svcnum',           'int', 'NULL', '', '', '',
+      ],
+      'primary_key' => 'portnum',
+      'unique'      => [ [ 'nms_devicenum', 'deviceport' ] ],
+      'index'       => [ [ 'svcnum' ] ],
+    },
+
+    'svc_port' => {
+      'columns' => [
+        'svcnum',                'int',     '',      '', '', '', 
+      ],
+      'primary_key' => 'svcnum',
+      'unique' => [],
+      'index'  => [], #recnum
+    },
+
 
     # name type nullability length default local
 
diff --git a/FS/FS/part_export/cardfortress.pm b/FS/FS/part_export/cardfortress.pm
new file mode 100644 (file)
index 0000000..4916a6e
--- /dev/null
@@ -0,0 +1,64 @@
+package FS::part_export::cardfortress;
+
+use strict;
+use base 'FS::part_export';
+use vars qw( %info );
+use String::ShellQuote;
+
+#tie my %options, 'Tie::IxHash';
+#;
+
+%info = (
+  'svc'      => 'svc_acct',
+  'desc'     => 'CardFortress',
+  'options'  => {}, #\%options,
+  'nodomain' => 'Y',
+  'notes'    => '',
+);
+
+sub rebless { shift; }
+
+sub _export_insert {
+  my($self, $svc_acct) = (shift, shift);
+
+  eval "use Net::OpenSSH;";
+  return $@ if $@;
+
+  open my $def_in, '<', '/dev/null' or die "unable to open /dev/null";
+  my $ssh = Net::OpenSSH->new( $self->machine,
+                               default_stdin_fh => $def_in );
+
+  my $private_key = $ssh->capture(
+    { 'stdin_data' => $svc_acct->_password. "\n" },
+    '/usr/local/bin/merchant_create', map $svc_acct->$_, qw( username finger )
+  );
+  return $ssh->error if $ssh->error;
+
+  $svc_acct->cf_privatekey($private_key);
+
+  $svc_acct->replace;
+
+}
+
+sub _export_replace {
+  my( $self, $new, $old ) = (shift, shift, shift);
+
+  return 'username changes not yet supported'
+    if $old->username ne $new->username;
+
+  return 'password changes not yet supported'
+    if $old->_password ne $new->_password;
+
+  return 'Real name changes not yet supported'
+    if $old->finger ne $new->finger;
+
+  '';
+}
+
+sub _export_delete {
+  #my( $self, $svc_x ) = (shift, shift);
+
+  return 'deletion not yet supproted';
+}
+
+1;
index f2b13c3..ac336b8 100644 (file)
@@ -1207,16 +1207,19 @@ sub check {
               || $self->ut_enum('_password_encoding', ['',qw(plain crypt ldap)])
               || $self->ut_enum('password_selfchange', [ '', 'Y' ])
               || $self->ut_enum('password_recover',    [ '', 'Y' ])
+              #cardfortress
+              || $self->ut_anything('cf_privatekey')
+              #communigate
               || $self->ut_textn('cgp_accessmodes')
               || $self->ut_alphan('cgp_type')
               || $self->ut_textn('cgp_aliases' ) #well
-              #settings
+              # settings
               || $self->ut_alphasn('cgp_rulesallowed')
               || $self->ut_enum('cgp_rpopallowed', [ '', 'Y' ])
               || $self->ut_enum('cgp_mailtoall', [ '', 'Y' ])
               || $self->ut_enum('cgp_addmailtrailer', [ '', 'Y' ])
               || $self->ut_snumbern('cgp_archiveafter')
-              #preferences
+              # preferences
               || $self->ut_alphasn('cgp_deletemode')
               || $self->ut_enum('cgp_emptytrash', $self->cgp_emptytrash_values)
               || $self->ut_alphan('cgp_language')
@@ -1224,7 +1227,6 @@ sub check {
               || $self->ut_textn('cgp_skinname')
               || $self->ut_textn('cgp_prontoskinname')
               || $self->ut_alphan('cgp_sendmdnmode')
-              #XXX RPOP settings
   ;
   return $error if $error;
 
index ba21ab4..52701df 100755 (executable)
@@ -44,11 +44,14 @@ unless ( $cgi->param('cgp_accessmodes') ) {
 }
 
 my %hash = $svcnum ? $old->hash : ();
-map {
+for ( fields('svc_acct'), qw( pkgnum svcpart usergroup ) ) {
     $hash{$_} = scalar($cgi->param($_));
-  #} qw(svcnum pkgnum svcpart username _password popnum uid gid finger dir
-  #  shell quota slipip)
-  } (fields('svc_acct'), qw ( pkgnum svcpart usergroup ));
+}
+if ( $svcnum ) {
+  for ( grep $old->$_, qw( cf_privatekey ) ) {
+    $hash{$_} = $old->$_;
+  }
+}
 my $new = new FS::svc_acct ( \%hash );
 
 my $error = '';
index 9135e67..4e82569 100755 (executable)
@@ -56,6 +56,12 @@ Service #<B><% $svcnum %></B>
 </FORM>
 <BR>
 
+<% include( 'svc_acct/cardfortress.html',
+              'svc_acct' => $svc_acct,
+              %gopt,
+          )
+%>
+
 <% include( 'svc_acct/hosting.html',
               %gopt,
           )
diff --git a/httemplate/view/svc_acct/cardfortress.html b/httemplate/view/svc_acct/cardfortress.html
new file mode 100644 (file)
index 0000000..d010fcd
--- /dev/null
@@ -0,0 +1,27 @@
+% if ( $svc_acct->cf_privatekey ) {
+
+<div class="fscontainer">
+<div class="fsbox">
+<div class="fsbox-title">
+  <span class="left">Card Fortress</span>
+</div>
+
+  <PRE><FONT STYLE="font-family:monospace"><% $svc_acct->cf_privatekey %></FONT></PRE>
+
+  <% $conf->config('svc_acct-cf_privatekey-message') %>
+
+%#XXX and then there should be a remove link to get rid of it
+
+% }
+
+</div>
+</div>
+<%init>
+
+my %opt = @_;
+
+my $svc_acct = $opt{'svc_acct'};
+
+my $conf = new FS::Conf;
+
+</%init>