<?

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

/**
 * Module name
 */
define("MOD_ENV",$name);

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

/**
 * EnvModule
 *
 * This module makes it possible to view environment variables from the
 * webserver in the mail that is send. This way it is possible to get extra
 * information on the submitter.
 * @package   Modules
 * @author    Herman Suijs
 */
class EnvModule extends Module {
  var 
$name "EnvModule";
  var 
$id MOD_ENV;
  var 
$execlevel 16;
  var 
$vars = array();

  
/**
   * Constructor
   *
   * Set options and call the superConstructor
   */
  
function EnvModule() {
    
$this->options[] = new Option("env:env_report","",false,true,DEFAULT_ENV);
    
$this->Module();
  } 
/* function EnvModule() */
  
  /**
   * Before action
   *
   * Check options and set the vars array
   */
  
function before_action() {
    
$this->check_options();
    
$this->vars explode(ENV_SEPERATOR,$this->options[0]->value);
  } 
/* function before_action() */

  /**
   * Do action
   *
   * Get the values and add them to the variables in formhandler
   */
  
function do_action() {
    global 
$formHandler,$debug;
    
$this->action();

    
//$content = MAIL_CONTENT;
    //$formHandler->addto_content("Environment variables:\n",$content);
    
$env="Environment variables  :\n";
    
$extra_vars=array();
    while (list(,
$name) = each($this->vars)) {
      global $
$name;
      
$value = $$name;
      if (
is_array($value)) {
    
// This needs to be formatted
    
$value fh_serialize($value);
      } 
/* if (is_array($value)) */
      //$formHandler->addto_vars($name,$value);
      
$extra_vars[$name]=$value;
      
$env.="$name: $value\n\n";
    } 
/* while (list(,$name) = each($th... */
    //$formHandler->addto_vars($this->options[0]->name,$env);
    
$extra_vars[$this->options[0]->name]=$env;
    
$formHandler->addto_vars($extra_vars,REPLACE);
  } 
/* function do_action() */

  /**
   * After action
   *
   * Cleanup
   */
  
function after_action() {
    
$this->clean_up();
  } 
/* function after_action() */
/* class EnvModule extends Module */