Started on the dx cluster database stuff
[spider.git] / perl / DXUser.pm
index 60abaeda3098f77598b67e2603f33790c3661c75..f5f7e0491f561351c0a146c5c98cdbcf3b1993b6 100644 (file)
@@ -29,12 +29,24 @@ $filename = undef;
   qra => 'Locator',
   email => 'E-mail Address',
   priv => 'Privilege Level',
-  sort => 'Type of User',
   lastin => 'Last Time in',
   passwd => 'Password',
-  addr => 'Full Address'
+  addr => 'Full Address',
+  'sort' => 'Type of User',  # A - ak1a, U - User, S - spider cluster, B - BBS 
 );
 
+sub AUTOLOAD
+{
+  my $self = shift;
+  my $name = $AUTOLOAD;
+  
+  return if $name =~ /::DESTROY$/;
+  $name =~ s/.*:://o;
+  
+  die "Non-existant field '$AUTOLOAD'" if !$valid{$name};
+  @_ ? $self->{$name} = shift : $self->{$name} ;
+}
+
 #
 # initialise the system
 #
@@ -42,8 +54,8 @@ sub init
 {
   my ($pkg, $fn) = @_;
   
-  die "need a filename in User\n" if !$fn;
-  $dbm = tie %u, MLDBM, $fn, O_CREAT|O_RDWR, 0666 or die "can't open user file: $fn ($!)\n";
+  die "need a filename in User" if !$fn;
+  $dbm = tie %u, MLDBM, $fn, O_CREAT|O_RDWR, 0666 or die "can't open user file: $fn ($!)";
   $filename = $fn;
 }
 
@@ -78,7 +90,7 @@ sub new
 
 sub get
 {
-  my $call = shift;
+  my ($pkg, $call) = @_;
   return $u{$call};
 }
 
@@ -119,19 +131,19 @@ sub close
 # return a list of valid elements 
 # 
 
-sub elements
+sub fields
 {
   return keys(%valid);
 }
 
 #
-# return a prompt together with the existing value
+# return a prompt for a field
 #
 
-sub prompt
+sub field_prompt
 { 
   my ($self, $ele) = @_;
-  return "$valid{$ele} [$self->{$ele}]";
+  return $valid{$ele};
 }
 
 #
@@ -167,5 +179,12 @@ sub enter
   }
   return 0;
 }
+
+# some variable accessors
+sub sort
+{
+  my $self = shift;
+  @_ ? $self->{sort} = shift : $self->{sort} ;
+}
 1;
 __END__