add selfservice_server-single_domain config, and login_info self-service method to...
[freeside.git] / fs_selfservice / FS-SelfService / SelfService.pm
index 0492b09..56c96f6 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;
@@ -24,6 +25,7 @@ $socket .= '.'.$tag if defined $tag && length($tag);
   'passwd'                    => 'passwd/passwd',
   'chfn'                      => 'passwd/passwd',
   'chsh'                      => 'passwd/passwd',
+  'login_info'                => 'MyAccount/login_info',
   'login'                     => 'MyAccount/login',
   'logout'                    => 'MyAccount/logout',
   'customer_info'             => 'MyAccount/customer_info',
@@ -58,8 +60,15 @@ $socket .= '.'.$tag if defined $tag && length($tag);
   '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 regionselector_hashref
+      expselect popselector domainselector didselector )
 );
-@EXPORT_OK = ( keys(%autoload), qw( regionselector expselect popselector domainselector didselector) );
 
 $ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin';
 $ENV{'SHELL'} = '/bin/sh';
@@ -68,8 +77,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!";
@@ -601,11 +613,17 @@ Array reference with three elements:
 
 =over 4
 
-=item Name of this service
+=item
+
+Name of this service
+
+=item
+
+Meaningful user-specific identifier for the service (i.e. username, domain or mail alias)
 
-=item Meaningful user-specific identifier for the service (i.e. username, domain or mail alias)
+=item
 
-=item Table name of this service
+Table name of this service
 
 =back
 
@@ -1176,24 +1194,45 @@ END
   }
   $state_html .= '</SELECT>';
 
-  $state_html .= '</SELECT>';
+  my $country_html = '';
+  if ( scalar( keys %cust_main_county ) > 1 )  {
+
+    $country_html = qq(<SELECT NAME="${prefix}country" ).
+                    qq(onChange="${prefix}country_changed(this); ).
+                                 $param->{'onchange'}.
+                               '"'.
+                      '>';
+    my $countrydefault = $param->{default_country} || 'US';
+    foreach my $country (
+      sort { ($b eq $countrydefault) <=> ($a eq $countrydefault) or $a cmp $b }
+        keys %cust_main_county
+    ) {
+      my $selected = $country eq $param->{'selected_country'}
+                       ? ' SELECTED'
+                       : '';
+      $country_html .= "\n<OPTION$selected>$country</OPTION>"
+    }
+    $country_html .= '</SELECT>';
+  } else {
+
+    $country_html = qq(<INPUT TYPE="hidden" NAME="${prefix}country" ).
+                            ' VALUE="'. (keys %cust_main_county )[0]. '">';
 
-  my $country_html = qq!<SELECT NAME="${prefix}country" !.
-                     qq!onChange="${prefix}country_changed(this); $param->{'onchange'}">!;
-  my $countrydefault = $param->{default_country} || 'US';
-  foreach my $country (
-    sort { ($b eq $countrydefault) <=> ($a eq $countrydefault) or $a cmp $b }
-      keys %cust_main_county
-  ) {
-    my $selected = $country eq $param->{'selected_country'} ? ' SELECTED' : '';
-    $country_html .= "\n<OPTION$selected>$country</OPTION>"
   }
-  $country_html .= '</SELECT>';
 
   ($county_html, $state_html, $country_html);
 
 }
 
+sub regionselector_hashref {
+  my ($county_html, $state_html, $country_html) = regionselector(@_);
+  {
+    'county_html'  => $county_html,
+    'state_html'   => $state_html,
+    'country_html' => $country_html,
+  };
+}
+
 #=item expselect HASHREF | LIST
 #
 #Takes as input a hashref or list of key/value pairs with the following keys: