agents can be disabled (auto-sensing based on schema)
[freeside.git] / FS / FS / agent.pm
index 27e9aed..bcba602 100644 (file)
@@ -40,7 +40,7 @@ from FS::Record.  The following fields are currently supported:
 
 =over 4
 
-=item agemtnum - primary key (assigned automatically for new agents)
+=item agentnum - primary key (assigned automatically for new agents)
 
 =item agent - Text name of this agent
 
@@ -50,6 +50,12 @@ from FS::Record.  The following fields are currently supported:
 
 =item freq - For future use.
 
+=item disabled - Disabled flag, empty or 'Y'
+
+=item username - Username for the Agent interface
+
+=item _password - Password for the Agent interface
+
 =back
 
 =head1 METHODS
@@ -110,11 +116,25 @@ sub check {
   ;
   return $error if $error;
 
+  if ( $self->dbdef_table->column('disabled') ) {
+    $error = $self->ut_enum('disabled', [ '', 'Y' ] );
+    return $error if $error;
+  }
+
+  if ( $self->dbdef_table->column('username') ) {
+    $error = $self->ut_alphan('username');
+    return $error if $error;
+    if ( length($self->username) ) {
+      $error = $self->ut_text('password'); # ut_text... arbitrary choice
+    } else {
+      $self->_password('');
+    }
+  }
+
   return "Unknown typenum!"
     unless $self->agent_type;
 
-  '';
-
+  $self->SUPER::check;
 }
 
 =item agent_type
@@ -131,7 +151,7 @@ sub agent_type {
 =item pkgpart_hashref
 
 Returns a hash reference.  The keys of the hash are pkgparts.  The value is
-true iff this agent may purchase the specified package definition.  See
+true if this agent may purchase the specified package definition.  See
 L<FS::part_pkg>.
 
 =cut
@@ -145,7 +165,7 @@ sub pkgpart_hashref {
 
 =head1 VERSION
 
-$Id: agent.pm,v 1.1 1999-08-04 09:03:53 ivan Exp $
+$Id: agent.pm,v 1.5 2003-09-29 05:51:50 ivan Exp $
 
 =head1 BUGS