<?php

/* get possible modules */
// FIXME use MGW->modules instead of DB call!
$sql = "SELECT * FROM mgw_modules WHERE active=1 ORDER BY modulename";
if(!$res = $conn->Execute($sql)) exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__));
$avail_modules = array();
while($row = $res->fetchRow()) {
	$mname = $row["modulename"];
	$filename = ROOTPATH."/modules/".$row["modulename"]."/inc/overview.inc.php";
	if(query_access_module($mname) && file_exists($filename)){
		$avail_modules[] = array("name" => $mname, "value" => $mname); 
	}
}

/* HOW IT WORKS 
 *
 * option key:	defines the name of the configtag that will be used to insert
 *				into te database
 * method: 	defines what form input type is used to display the settings
 *				if not defined a text input will be shown
 * choices: 	defines the names and value to be given to the form inputs
 *          	if not defined there wil be no names and empty values
 *				- the value of a choice is an array of selectbox options and values
 *				- names of choices are only translated if a valid translation is found
 * type: 		defines in which value column the 'value' is inserted into the db
 *				this must be defined
 * name:		defines the language string associated with the option
 *				if not defined the key of the setting we be used a language string
 * translate	for select boxes only. defines if the values of the options of the select 
 * 				box are to be translated. defualt is true
 */ 

/* settings array */
$settings["overview"] = array(
		"settings" => array(
				"overview_get_modules" => array (
						"method" => "checkbox",
						"choices" => $avail_modules,
						"name" => "overview_get_modules", // [optionable] name of the option (will be translated on runtime)
						"type" => "str",
		    			"description" => "What modules show in overview",
						"selections" => 1,
						"dimensions" => 1,
					    "default" => array("news","todo","calendar")
				),
        "title" => "edit_overview"
		)
);

if (is_array($settings["overview"])) foreach ($settings["overview"] as $my_module_settings) {
  if (is_array($my_module_settings)) foreach ($my_module_settings as $key=>$key2) {
    if (!isset($_SESSION["MGW"]->settings[$key]) and isset($key2["default"])) {
	  $_SESSION["MGW"]->settings[$key] = $key2["default"];
	}
  }
}
?>
