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

	$ins_id 	= -1;

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

	$institution = ($ins_id == -1)? "" : " and institution.id=".$ins_id;
		
	$conn = get_dbconnection();
	
	$answer = "<tags>";
	
	if ( $conn )
	{
		$sql = "select id, name from tag where type != 'OR' and removed = false order by name";
		
		if ( $query = pg_query($conn,$sql) )
		{
			while ( $row = pg_fetch_row($query) )
			{
				$row[1]=trim(preg_replace('/[[:cntrl:]]/', '', htmlspecialchars($row[1],ENT_QUOTES)));

				$answer .= "<tag id=\"".$row[0]."\" name=\"".$row[1]."\" ></tag>";
			}
		}
	}
	
	$answer .= "</tags>";

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