<?php
	require_once '../../autoload.php';

	RightsCheck ("VIEW_AUDIT");
	
	$type 	= -1;

	if ( isset($_GET['type']) )
		$type	= $_GET['type'];

	$type = ($type == -1)? "" : $type;
		
	$conn = get_dbconnection();
	
	$answer = "<results>";
	
	if ( $conn )
	{
		$sql = "select id,name,maintype from audit_type where removed='false' order by name";

		if ( $query = pg_query($conn,$sql) )
		{
			while ( $row = pg_fetch_row($query) )
			{
				error_log ( "Audit : ".$row[1] );
				$answer .= "<audit_type id=\"".$row[0]."\" name=\"".$row[1]."\" maintype=\"".$row[2]."\"></audit_type>";
			}
		}
	}
	
	$answer .= "</results>";

	header ('Content-type: text/xml' );
	
	echo $answer;
?>