<?

/**
 * debug.mod.php
 * @package   Modules
 */

/**
 * Name of this module
 */
define("MOD_DEBUG",$name);

/**
 * Optionname debug
 */
define("OPT_DEBUG",0);
/**
 * Optionname No Operation
 */
define("OPT_NOOP",1);
/** 
 * Optionname DebugLevel
 */
define("OPT_LEVEL",2);

/**
 * DebugModule
 *
 * This module takes the debug and noop options to control the
 * debug-messages.
 * Options:
 * debug: show debug-message.
 * noop: no action (don't send mail)
 * @package   Modules
 * @author    Herman Suijs
 */
class DebugModule extends Module {
  var 
$name "DebugModule";
  var 
$id MOD_DEBUG;
  var 
$execlevel 1;

  
/**
   * Constructor
   *
   * Define options and call the superConstructor
   */
  
function DebugModule() {
    
$this->options[OPT_DEBUG] = new Option("debug");
    
$this->options[OPT_NOOP] = new Option("noop");
    
$this->options[OPT_LEVEL] = new Option("level:debuglevel:debug-level:debug_level");

    
/* call super-constructor */
    
$this->Module();
  } 
/* function DebugModule() */

  /**
   * Before action
   *
   * Check the options and set the specified values
   */
  
function before_action() {
    global 
$debug;

    
$this->check_options();

    if(isset(
$this->options[OPT_DEBUG])) {
      
$debug->add_message("Option: " $this->options[OPT_DEBUG]->name " "$this->options[OPT_DEBUG]->value,$this->name);
      
//$switch = (is_true($this->options[OPT_DEBUG]->value)) ? false : true;
      
$debug->enable(is_true($this->options[OPT_DEBUG]->value));
    } 
/* if(isset($this->options[OPT_DE... */
    
unset($this->options[OPT_DEBUG]);

    if(isset(
$this->options[OPT_NOOP])) {
      
$debug->add_message("Option: " $this->options[OPT_NOOP]->name " "$this->options[OPT_NOOP]->value,$this->name);
      
//$switch = (is_true($this->options[OPT_NOOP]->value)) ? false : true;
      
$debug->set_noop($this->options[OPT_NOOP]->value);
    } 
/* if(isset($this->options[OPT_NO... */
    
unset($this->options[OPT_NOOP]);

    if(isset(
$this->options[OPT_LEVEL])) {
      
$debug->set_level($this->options[OPT_LEVEL]);
    } 
/* if(isset($this->options[OPT_LE... */
    
unset($this->options[OPT_LEVEL]);

  } 
/* function before_action() */

  /**
   * Do action
   */
  
function do_action() {
    
$this->action();
  } 
/* function do_action() */

  /**
   * After action
   *
   * Cleanup
   */
  
function after_action() {
    
$this->clean_up();
  } 
/* function after_action() */
/* class DebugModule extends Modu... */

$modules[$name]= new DebugModule();