<?

define
("NO_NAME","No name entered");
define("NO_ID","NONE");
define("OPTION_ID","OPTION");
define("MODULE_BASE","MODULE_BASE");

/**
 * ModuleBase Ancestor of all objects
 *
 * This class is the superclass of most of the classes used within this
 * package. All defined variables and methods are aveilable to all these
 * classes.
 * @package   Modules
 * @author    Herman Suijs
 */
class ModuleBase {
  var 
$name NO_NAME;
  var 
$id NO_ID;
  var 
$enabled true// Modules are enabled by default

  
function ModuleBase() {
    global 
$debug,$name;

    
$message $this->name " was created";
    if (
$this->id == OPTION_ID) {
      
$message OPTION_ID " " $message;
    } 
/* if ($this->id == OPTION_ID) */

    
if ($this->id == MES_DEBUG) {
      
/*
      if ($this->enabled) {
    echo "DEBUG: $message<br>\n";
      }
      */
    
} else { /* if ($this->id == MES_DEBUG) */
      
if ($this->id == NO_ID) {
    
$debug->add(-1,MODULE_BASE,"No proper id for object %s",$this->name);
      } 
/* if ($this->id == NO_ID) */
      
if ($this->name == NO_NAME) {
    
$debug->add(-1,MODULE_BASE,"No proper name for object %s",$this->name);
      } 
/* if ($this->name == NO_NAME) */
      
$debug->add(-1,MODULE_BASE,$message);
   
/* if ($this->id == MES_DEBUG) { ... */  }
   
/* if ($this->id == MES_DEBUG) { ... */}

  function 
enable($bool=true) {
    
$this->enabled=$bool;
  } 
/* function enable($bool=true) */

  
function disable() {
    
$this->enabled=false;
  } 
/* function disable() */

  /*
  function turn() {
    $this->enabled = !$this->enabled;
  }
  */

  
function is_enabled() {
    return 
$this->enabled;
  } 
/* function is_enabled() */

  
function name() {
    return 
$this->name;
  } 
/* function name() */

  
function wrap_up() {
    global 
$debug;
    
$debug->add(DB_XFLOW,$this->name,"Module destructor called");
  } 
/* function wrap_up() */
/* if ($this->id == MES_DEBUG) { ... */