<?php
	include '../../autoload.php';
	$answer="<root>";
	$action=$_POST['action'];		// true : update, false : insert
	$point_id=$_POST['point_id'];
	$language=$_POST['language'];
	$name=pg_escape_string($_POST['name']);
	$description=pg_escape_string($_POST['description']);

	if($point_id >= 0)
	{
		$conn = get_dbconnection();
	
		if($action == 'true')
			$sql = "update quaad_description set description_summary='".$name."', description='".$description."' where id_quaadpoint=".$point_id." and language='".$language."'";
		else
			$sql = "insert into quaad_description ( id_quaadpoint, language, description_summary, description ) values (".$point_id.",'".$language."','".$name."', '".$description."')";
		
		$query = pg_query($conn, $sql);
		if(!$query)
		{
			$err = pg_last_error($conn);
			$answer .= "<status value=\"".$err."\"></status>";
		}
		else
			$answer .= "<status value=\"ok\"></status>";
	}
	
	$answer.="</root>";
	header('Content-Type: text/xml');
	echo $answer;
?>