<?php
	require_once '../autoload.php';
	
	$whereclause2='';
  
	$conn = get_dbconnection();
	
	$answer = "<results>";
	
	if ( $conn )
	{
		$wherecond = '';
		if(isset($_GET['operator']) && $_GET['operator'] == 'true')
		{
			$wherecond .= ' and operator = true';
		}

		$sql = "select  firstname || ' ' || lastname as name, acc_id from account where removed = false {$wherecond} union select '',-1 order by name asc";

		if ( $query = pg_query($conn,$sql) )
		{
			while ( $row = pg_fetch_row($query) )
			{
				$answer .= "<user id=\"".$row[1]."\" name=\"".$row[0]."\"></user>";
			}
		}
	}
	
	$answer .= "</results>";
	
	header ('Content-type: text/xml' );
	
	echo $answer;
?>