rlm_perl hook for prepaid voip radius, RT#4100
[freeside.git] / fs_selfservice / FS-SelfService / SelfService.pm
index ec4668f..cba85e0 100644 (file)
@@ -1,7 +1,8 @@
 package FS::SelfService;
 
 use strict;
-use vars qw($VERSION @ISA @EXPORT_OK $DEBUG $dir $socket %autoload $tag);
+use vars qw( $VERSION @ISA @EXPORT_OK $DEBUG
+             $skip_uid_check $dir $socket %autoload $tag );
 use Exporter;
 use Socket;
 use FileHandle;
@@ -57,8 +58,12 @@ $socket .= '.'.$tag if defined $tag && length($tag);
   'agent_logout'              => 'Agent/agent_logout',
   'agent_info'                => 'Agent/agent_info',
   'agent_list_customers'      => 'Agent/agent_list_customers',
+  'mason_comp'                => 'MasonComponent/mason_comp',
+  'call_time'                 => 'PrepaidPhone/call_time',
+  'call_time_nanpa'           => 'PrepaidPhone/call_time_nanpa',
+  'phonenum_balance'          => 'PrepaidPhone/phonenum_balance',
 );
-@EXPORT_OK = ( keys(%autoload), qw( regionselector expselect popselector domainselector) );
+@EXPORT_OK = ( keys(%autoload), qw( regionselector expselect popselector domainselector didselector) );
 
 $ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin';
 $ENV{'SHELL'} = '/bin/sh';
@@ -67,8 +72,11 @@ $ENV{'CDPATH'} = '';
 $ENV{'ENV'} = '';
 $ENV{'BASH_ENV'} = '';
 
+#you can add BEGIN { $FS::SelfService::skip_uid_check = 1; } 
+#if you grant appropriate permissions to whatever user
 my $freeside_uid = scalar(getpwnam('freeside'));
-die "not running as the freeside user\n" if $> != $freeside_uid;
+die "not running as the freeside user\n"
+  if $> != $freeside_uid && ! $skip_uid_check;
 
 -e $dir or die "FATAL: $dir doesn't exist!";
 -d $dir or die "FATAL: $dir isn't a directory!";
@@ -192,11 +200,16 @@ FS::SelfService - Freeside self-service API
                         'payname'          => $payname,
                         'invoicing_list'   => $invoicing_list,
                         'referral_custnum' => $referral_custnum,
+                        'agentnum'         => $agentnum,
                         'pkgpart'          => $pkgpart,
+
                         'username'         => $username,
                         '_password'        => $password,
                         'popnum'           => $popnum,
-                        'agentnum'         => $agentnum,
+                        #OR
+                        'countrycode'      => 1,
+                        'phonenum'         => $phonenum,
+                        'pin'              => $pin,
                       }
                     );
   
@@ -595,11 +608,17 @@ Array reference with three elements:
 
 =over 4
 
-=item Name of this service
+=item
+
+Name of this service
+
+=item
 
-=item Meaningful user-specific identifier for the service (i.e. username, domain or mail alias)
+Meaningful user-specific identifier for the service (i.e. username, domain or mail alias)
 
-=item Table name of this service
+=item
+
+Table name of this service
 
 =back
 
@@ -972,6 +991,10 @@ comma-separated list of email addresses for email invoices.  The special value '
 
 referring customer number
 
+=item agentnum
+
+Agent number
+
 =item pkgpart
 
 pkgpart of initial package
@@ -992,9 +1015,17 @@ Security phrase
 
 Access number (index, not the literal number)
 
-=item agentnum
+=item countrycode
 
-Agent number
+Country code (to be provisioned as a service)
+
+=item phonenum
+
+Phone number (to be provisioned as a service)
+
+=item pin
+
+Voicemail PIN
 
 =back
 
@@ -1412,7 +1443,7 @@ sub domainselector {
 
   return '<INPUT TYPE="hidden" NAME="domsvc" VALUE="">'
     unless scalar(keys %$domains);
-    
+
   if (scalar(keys %$domains) == 1) {
     my $key;
     foreach(keys %$domains) {
@@ -1437,6 +1468,39 @@ sub domainselector {
 
 }
 
+=item didselector HASHREF | LIST
+
+Takes as input a hashref or list of key/value pairs with the following keys:
+
+=over 4
+
+=item field
+
+=item svcpart
+
+=back
+
+Returns an HTML fragment for DID selection.
+
+=cut
+
+sub didselector {
+  my $param;
+  if ( ref($_[0]) ) {
+    $param = shift;
+  } else {
+    $param = { @_ };
+  }
+
+  my $rv = mason_comp( 'comp'=>'/elements/select-did.html',
+                       'args'=>[ %$param ],
+                     );
+
+  #hmm.
+  $rv->{'error'} || $rv->{'output'};
+
+}
+
 =back
 
 =head1 RESELLER FUNCTIONS