<?php
/*
Officity - Web application platform - Version 6.0 - 2011-07-05

François Dispaux, Boris Verdeyen, Thomas Hermant,
Jérémie Roy, Grégory Meurice, Abdelila Harbi, 
Marc Mignonsin, Jonathan Sanchez, Julien Gonzalez, Pierre Fouchez

Sushee and Officity is © Copyright 2011 Nectil SA.

`/sushee-source/sushee/private/searchPropertiesConfig.inc.php` is part of Officity.

Sushee is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Officity and Sushee are distributed in the hope that they will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Sushee. If not, see <http://www.gnu.org/licenses/>.
*/
function searchPropertiesConfig($name,&$xml,$requestName,$current_path,$firstNode,$firstNodePath){
	$db_conn = db_connect();
	$moduleInfo = moduleInfo($xml->getData($firstNodePath."/@module"));
	if(!$moduleInfo->loaded)
		return generateMsgXML(1,'Module name is incorrect.',0,'',$name);
	$moduleID = $moduleInfo->ID;
	$languageID = $xml->getData($firstNodePath."/@languageID");
	if(!$languageID)
		$languageID = $GLOBALS['NectilLanguage'];
	if ($name)
		$attributes.=" name='$name'";
	$external_file = $xml->getData($current_path.'/@fromFile');
	if($external_file)
		$attributes.=" fromFile='".$external_file."'";
	$query_result='<RESULTS'.$attributes.'>';
	
	$config_sql = 'SELECT * FROM `propertiesconfig` WHERE `ModuleID`=\''.$moduleID.'\'';
	$config_rs = $db_conn->Execute($config_sql);
	while($config = $config_rs->FetchRow()){
		$query_result.="<PROPERTY>";
		$query_result.="<NAME>".encode_to_xml($config['Denomination'])."</NAME>";
		$query_result.="<TYPE>".$config['Type']."</TYPE>";
		$query_result.="<DEFAULTVALUE>".$config['DefaultValue']."</DEFAULTVALUE>";
		$query_result.="<VIRTUALID>".$config['VirtualID']."</VIRTUALID>";
		$trad_sql = 'SELECT * FROM `propertiestraductions` WHERE `LanguageID`="'.$languageID.'" AND `PropertyID`=\''.$config['ID'].'\'';
		$trad = $db_conn->GetRow($trad_sql);
		$query_result.="<LABEL languageID=\"".$languageID."\">";
		$query_result.="<TITLE>".encode_to_xml($trad['Title'])."</TITLE>";
		$query_result.="<UNIT>".encode_to_xml($trad['Unit'])."</UNIT>";
		$query_result.="<COMMENT>".encode_to_xml($trad['Comment'])."</COMMENT>";
		$query_result.="</LABEL>";
		$query_result.="</PROPERTY>";
	}
	$query_result.="</RESULTS>";
	return $query_result;
}
?>
