<?php

/**------------------------------------------------
*
* Rooty, 2018 <rooty@rooty.me>
*
*
* This software is protected by copyright, please
* read the file COPYRIGHT.
* This program is distributed in the hope that it
* will be useful, but without any warranty; without
* even the implied warranty of merchantability or
* fitness for a particular purpose. Please
* read the file LICENCE.
*
* Ce fichier contient la classe Home
*
* @author Initiance <www.initiance.com|martial@initiance.com>
* @since 2004/06/07
* @version 0.1
* @link www.granilim.org
* @package object_coordination
* @subpackage Home
* @copyright Copyright &copy; 2004-2006, Limousin expansion
*/

/**
* Modified by Guillaume Tessier <gui.tessier@wanadoo.fr>
* Since 2005/08/01
* Ajout de deux méthodes (setAllRow4Import et getAllRow4Export) concrètes issues 
* de la classe abstraite "CoordinationObj", ces deux méthodes nous servent à restaurer et 
* sauvegarder des données de l'outil.
*/
if ( !defined('SYSTEM_IN') )
{
 die("Hacking attempt");
}

/**
* Classe Home
*
* Classe de du tunnel d'accueil
* @package object_coordination
* @subpackage Home
*/

Class Home extends CoordinationObj
{
	function tabeCreate()
	{
		$tabPictoTabe = array("eye","cogs");
		$tabTabe =  array("TxtTabeView","TxtTabeAdmin");
		$tabAction = array(array("lectureAdmin"), array("actionAdmin"));
		$tabUrlTabe = array(Navigation::formatUrl($this->getId(), "TextInfo", "lectureAdmin"),Navigation::formatUrl($this->getId(), "TextInfo", "actionAdmin"));
		printTabeAdmin("TabeB", $tabTabe, $tabUrlTabe, $tabPictoTabe, $tabAction);
	}
/**
* Function affichant en lecture seule le contenu
* @access public
* @return chaine chaine vide
*/
	function actionLecture()
	{
		$text = getMessage("NoText");

		/*Récupération des messages utilisateurs*/
		addMessageFile("user.ini");
		addMessageFile("object.ini");

		/* gestion du lib en fonction de la langue courante */
		$currentCode=$GLOBALS["SYSTEM_USER_SESSION"]->langue->getCode();
		$defaultCode=$GLOBALS["SYSTEM_DEFAULT_LANGUAGE_CODE"];
		/* fin récupération des codes par defaut */
		
		if( recupCommunity() == 2 ) $currentCommunity = "Qware"; else $currentCommunity = recupCommunity(false, "lib");
		mxPageTitle("methodActionLectureHomeTitlePage", $currentCommunity);
		
		if (file_exists($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_coordination/textinfo/".$_SERVER["HTTP_HOST"]."-landingpage.mxt"))
		{
			$GLOBALS["SYSTEM_TEMPLATE"] = new ModeliXeQware($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_coordination/textinfo/".$_SERVER["HTTP_HOST"]."-landingpage.mxt");

			$GLOBALS["SYSTEM_TEMPLATE"]->SetMxFileParameter($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR'].$GLOBALS['SYSTEM_TEMPLATE_CONF']);
			$GLOBALS["SYSTEM_TEMPLATE"]->SetModeliXe();
			
			
			$GLOBALS['SYSTEM_TEMPLATE']->MxText("faviconlink", "data/image/communities/".$_SERVER["HTTP_HOST"].".ico?v4");
			
			$url =$_SERVER['SCRIPT_NAME'];
			$url.="?system=authSession";
			$url=addIdToUrl($url);
			
			$tabObject	=$this->getObjectSon(eid());
			for ($i=0; $i<count($tabObject);$i++)
			{
				if ($tabObject[$i][0]->getClassName()=="Home")
				{
					$urlArray["id"]=$tabObject[$i][1]->getId();
				}
			}
			
			/* Création de l'URL pour nouveau compte */
			$urlNewAccount = $_SERVER['SCRIPT_NAME'];
			$urlNewAccount.= "?system=authNewAccount";
			$urlNewAccount = addIdToUrl($urlNewAccount);
			
			$GLOBALS['SYSTEM_TEMPLATE']->MxAttribut("urlActionNewAccount", Navigation::formatUrl($urlArray["id"], "Home", "formLecture", "", recupCommunity()));
			$GLOBALS['SYSTEM_TEMPLATE']->MxAttribut("urlActionNewSubscription", Navigation::formatUrl($urlArray["id"], "Home", "formLectureAdh", "", recupCommunity()));

			/* Création de l'URL pour rappel du mot de passe */
			$urlForgotPassword = $_SERVER['SCRIPT_NAME'];
// 			$urlForgotPassword.= "?system=authForgotPassword";
			$urlForgotPassword.= "?msg=forgotPasswordTempDisabled";
			$urlForgotPassword = addIdToUrl($urlForgotPassword);
			
			$GLOBALS['SYSTEM_TEMPLATE']->MxText("pageTitleHome", $GLOBALS['SYSTEM_TEMPLATE_DEFAULT_TITLE']." ".$GLOBALS['SYSTEM_TEMPLATE_DEFAULT_DESCRIPTION']." - Accueil");
			$GLOBALS['SYSTEM_TEMPLATE']->MxText("ogTitle", $GLOBALS['SYSTEM_TEMPLATE_DEFAULT_TITLE']);
			$GLOBALS['SYSTEM_TEMPLATE']->MxText("ogDescription", $GLOBALS['SYSTEM_TEMPLATE_DEFAULT_DESCRIPTION']);
			
// 			$GLOBALS['SYSTEM_TEMPLATE']->MxImage("pictoAuth", $GLOBALS['CONF_DATA_PATH']."data/template/".$GLOBALS['SYSTEM_TEMPLATE_DIR']."media/picto/authorise.png");
			$GLOBALS['SYSTEM_TEMPLATE']->MxText("auth", getMessage("UserPrintAuth"));
			$GLOBALS['SYSTEM_TEMPLATE']->MxText("LOGIN", getMessage("UserPrintLogin"));
			$GLOBALS['SYSTEM_TEMPLATE']->MxFormField("login", "text", "login", "", "title='".getMessage("tipUserPrintLogin")."'");
			$GLOBALS['SYSTEM_TEMPLATE']->MxText("PASSWORD", getMessage("UserPrintPassword"));
			$GLOBALS['SYSTEM_TEMPLATE']->MxFormField("password", "password", "password", "", "title='".getMessage("tipUserPrintPassword")."'");
			$GLOBALS['SYSTEM_TEMPLATE']->MxAttribut("urlActionNewAccount", $urlNewAccount);
			$GLOBALS['SYSTEM_TEMPLATE']->MxText("NEWACCOUNT", getMessage("UserPrintNewAccount"));
			$GLOBALS['SYSTEM_TEMPLATE']->MxText("NEWSUBSCRIPTION", getMessage("UserPrintNewSubscription"));
			$GLOBALS['SYSTEM_TEMPLATE']->MxAttribut("urlActionForgotPassword", $urlForgotPassword);
			$GLOBALS['SYSTEM_TEMPLATE']->MxText("FORGOTPASSWORD", getMessage("UserPrintForgotPassword"));
			$GLOBALS['SYSTEM_TEMPLATE']->MxAttribut("urlActionLogin", $url);
			$GLOBALS['SYSTEM_TEMPLATE']->MxAttribut("BtnEnter", getMessage("UserPrintEnter"));
			$GLOBALS['SYSTEM_TEMPLATE']->MxAttribut("titleButton", getMessage("tipUserPrintEnter"));

			$sql="SELECT * FROM ".DATA_ACCES_TABLE_PREFIX.DATA_ACCES_OBJECT_PREFIX."textentrynode WHERE node_id=".recupCommunity()." AND langue_id=".$GLOBALS["SYSTEM_USER_SESSION"]->langue->getId();
			# Execution de Requete (utilisation de la connexion systeme)
			$result=$GLOBALS['SYSTEM_DATABASE_CONN']->sql_query($sql);

			# Teste si il y a des enregistrements
			if ($GLOBALS['SYSTEM_DATABASE_CONN']->sql_numrows()>0)
			{
				$View = $GLOBALS['SYSTEM_DATABASE_CONN']->sql_fetchrow();
				$text = stripslashes($View['textentrynode_text']);
				# Destruction des resultats
				$GLOBALS['SYSTEM_DATABASE_CONN']->sql_freeresult();
			}else{
				$text = getMessage("NoText");
			}

			# On affecte a la template le texte pour la balise MxText (Template Principale)
			$GLOBALS["SYSTEM_TEMPLATE"]->MxText("text", $text);
		} else {
			if( recupCommunity() == 2 ) $currentCommunity = "Qware"; else $currentCommunity = recupCommunity(false, "lib");
			mxPageTitle("methodActionLectureHomeTitlePage", $currentCommunity);

			/* None CSS or JS added */
			mxCallCss('');
			mxCallJs('');
			mxRawJs('');
			
			/* On inclus la template (voir package.template.php) */
			withBlocPath("Home", "actionLectureInfo");
			
			# Requete sur identifiant de l'objet de coordination correspondant
			$sql="SELECT * FROM ".DATA_ACCES_TABLE_PREFIX.DATA_ACCES_OBJECT_PREFIX."textentrynode WHERE node_id=".recupCommunity()." AND langue_id=".$GLOBALS["SYSTEM_USER_SESSION"]->langue->getId();
			# Execution de Requete (utilisation de la connexion systeme)
			$result=$GLOBALS['SYSTEM_DATABASE_CONN']->sql_query($sql);
			# Teste si il y a des enregistrements
			if ($GLOBALS['SYSTEM_DATABASE_CONN']->sql_numrows()>0)
			{
				$View = $GLOBALS['SYSTEM_DATABASE_CONN']->sql_fetchrow();
				$text = stripslashes($View['textentrynode_text']);
				# Destruction des resultats
				$GLOBALS['SYSTEM_DATABASE_CONN']->sql_freeresult();
			}

			# On affecte a la template le texte pour la balise MxText (Template Principale)
			$GLOBALS["SYSTEM_TEMPLATE"]->MxText("text", $text);
		}
		return "";
	}

/**
* Function permettant d'afficher le formulaire de pré-inscription pour enregistrement dans la bd
* @access public
* @param tableau
* @return chaine chaine html
*/
	function formLecture($tabPOST="", $errorInfo="")
	{
		global $SERVER_NAME, $SCRIPT_NAME, $CONF_PERSISTANT_SECURE, $CONF_DATA_PATH;
		$_SESSION['redirect']=$_SERVER['REQUEST_URI'];

		/*Récupération des messages utilisateurs*/
		addMessageFile("user.ini");
// 		addMessageFile("subscriptions.ini");
// 		addMessageFile("adminaccounting.ini");

		/* gestion du lib en fonction de la langue courante */
		$currentCode=$GLOBALS["SYSTEM_USER_SESSION"]->langue->getCode();
		$defaultCode=$GLOBALS["SYSTEM_DEFAULT_LANGUAGE_CODE"];
		/* fin récupération des codes par defaut */

		// titlPageInscription + ComText
		mxPageTitle("titlPageInscription");

		$arrayCallCss = array();
		$arrayCallCss[] = "data/css/bootstrap-datepicker-current/bootstrap-datepicker3.min.css";
		mxCallCss($arrayCallCss);

		$arrayCallJs = array();
		$arrayCallJs[] = "data/javascript/bootstrap-datepicker-current/bootstrap-datepicker.min.js";
		$arrayCallJs[] = "data/javascript/bootstrap-datepicker-current/locales/bootstrap-datepicker.fr.min.js";
		mxCallJs($arrayCallJs);

		$arrayRawJs[] = "\$(document).ready(function(){ $('.datepicker').datepicker(); });";
		mxRawJs($arrayRawJs);

		/* On inclus la template (voir package.template.php) */
		WithBlocPath("Home", "formlecture");

		if(isset($_GET['param']) && (is_numeric($_GET['param'])))
		{
			$myNoeud = $GLOBALS['SYSTEM_MANAGER']['NODE']->createInstance($_GET['param']);
			$libmyNoeud = $myNoeud->getLibelle($currentCode);
			$messageInscriptionNoeud = "&nbsp;:&nbsp;".$libmyNoeud;
			$GLOBALS['SYSTEM_TEMPLATE']->MxText("messageInscriptionNoeud", $messageInscriptionNoeud);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ComText", $libmyNoeud);

			//On récupère le texte du noeud choisi par l'internaute
			$sql="SELECT * FROM ".DATA_ACCES_TABLE_PREFIX.DATA_ACCES_OBJECT_PREFIX."textentrynode WHERE node_id=".$_GET['param'];
			# Exécution de Requete
			$result=$GLOBALS['SYSTEM_DATABASE_CONN']->sql_query($sql);

			# Teste si il y a des enregistrements
			if ($GLOBALS['SYSTEM_DATABASE_CONN']->sql_numrows()>0)
			{
				$list = $GLOBALS['SYSTEM_DATABASE_CONN']->sql_fetchrow();
				$text = $list['textentrynode_resume'];
				//On masque le texte d'intro affiché par défaut à partir de message
				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("text_resume", $text);
			}
			# Destruction des éléments
			$GLOBALS['SYSTEM_DATABASE_CONN']->sql_freeresult();
			
// 			var_dump($this->getObjectSon(eid()));
			
// 			$tabObject	=$this->getObjectSon(eid());
// 			if (($this->recupCommunauty("ctype") == "asso") && (count($tabObject) >> 0) )
// 			{
// 				for ($i=0; $i<count($tabObject);$i++)
// 				{
// 					if ($tabObject[$i][0]->getClassName()=="CorporateInfos")
// 					{
// 						$urlArray["id"]=$tabObject[$i][1]->getId();
// 						$urlArray["classname"]=$tabObject[$i][0]->getClassName();
// // 						$urlArray["methodname"]=$tabObject[$i][0]->getMethodName();
// 					}
// 				}
// 				$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("blocSubscriptionsForms".".linkStatuts", Navigation::formatUrl($urlArray["id"],$urlArray["classname"],"actionLectureInfo","","2"));
// 				$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("blocSubscriptionsForms".".linkRegInt", Navigation::formatUrl($urlArray["id"],$urlArray["classname"],"actionLectureInfo","","3"));
// 				$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("blocSubscriptionsForms".".linkChartConf", Navigation::formatUrl($urlArray["id"],$urlArray["classname"],"actionLectureInfo","","4"));
// 			}
		}
		# Récupération des étiquette du formulaire
		$GLOBALS["SYSTEM_TEMPLATE"]->MxText("WarnNotSubs", htmlspecialchars(getMessage("WarnNotSubs1")).$libmyNoeud.htmlspecialchars(getMessage("WarnNotSubs2")));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("urlAction", Navigation::formatUrl($this->getId(),"Home","execLecture","",$_GET['param']));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxText("urlReturn",Navigation::formatUrl($this->getId(),"Home","actionLecture"));
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxText("urlQaptcha", Navigation::formatUrl($this->getId(),"Home","formLectureQaptcha"));
		
		# Affichage des champs de formulaire pour l'inscription
		if(!$tabPOST)
		{
			$titre = array(getMessage("mr"),getMessage("mrs"), getMessage("miss"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxSelect("user_title", "user_title", "", $titre, getMessage("user_title"), "", "", "class=\"form\" required=\"false\" title=\"".htmlspecialchars(getMessage("tipSelectTitle"), ENT_QUOTES)."\"");
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_first_name", "text", "user_first_name", "", "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipFirstName"), ENT_QUOTES)."\"", getMessage("user_first_name"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_last_name", "text", "user_last_name", "", "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipLastName"), ENT_QUOTES)."\"", getMessage("user_last_name"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_login", "text", "user_login", "", "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipLogin"), ENT_QUOTES)."\"", getMessage("user_login"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_mail", "email", "user_mail", "", "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipCourriel"), ENT_QUOTES)."\"", getMessage("user_mail"));
			
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_password", "password", "user_password", "", "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipPassword"), ENT_QUOTES)."\"", getMessage("user_password"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_password2", "password", "user_password2", "", "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipPassword2"), ENT_QUOTES)."\"", getMessage("user_password"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_birthdate", "text", "user_birthdate", "jj/mm/aaaa", "class=\"form\" required=\"true\" data-provide=\"datepicker\" data-date-format=\"dd/mm/yyyy\" data-date-language=\"fr\" title=\"".htmlspecialchars(getMessage("tipBirthDate"), ENT_QUOTES)."\"", getMessage("user_birthdate"));
			
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_msn", "text", "user_msn", "", "class=\"form\" title=\"".htmlspecialchars(getMessage("tipUserMsn"), ENT_QUOTES)."\"", getMessage("user_msn"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_jabber", "text", "user_jabber", "", "class=\"form\" title=\"".htmlspecialchars(getMessage("tipUserJabber"), ENT_QUOTES)."\"", getMessage("user_jabber"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_facebook", "text", "user_facebook", "", "class=\"form\" title=\"".htmlspecialchars(getMessage("tipUserFacebook"), ENT_QUOTES)."\"", getMessage("user_facebook"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_mastodon", "text", "user_mastodon", "", "class=\"form\" title=\"".htmlspecialchars(getMessage("tipUserMastodon"), ENT_QUOTES)."\"", getMessage("user_mastodon"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_website", "text", "user_website", "", "class=\"form\" title=\"".htmlspecialchars(getMessage("tipUserWebsite"), ENT_QUOTES)."\"", getMessage("user_website"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_code", "text", "user_postal_code", "", "class=\"form\" required=\"false\" title=\"".htmlspecialchars(getMessage("tipPostalCode"), ENT_QUOTES)."\"", getMessage("user_postal_code"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_adress", "text", "user_postal_adress", "", "class=\"form\" required=\"false\" title=\"".htmlspecialchars(getMessage("tipPostalAddress"), ENT_QUOTES)."\"", getMessage("user_postal_address"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_addressmand", "text", "user_postal_addressmand", "", "class=\"form\" required=\"false\" title=\"".htmlspecialchars(getMessage("tipPostalAddress"), ENT_QUOTES)."\"", getMessage("user_postal_address"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_city", "text", "user_city", "", "class=\"form\" required=\"false\" title=\"".htmlspecialchars(getMessage("tipCity"), ENT_QUOTES)."\"", getMessage("user_city"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_state", "text", "user_state", "", "class=\"form\" required=\"false\" title=\"".htmlspecialchars(getMessage("tipState"), ENT_QUOTES)."\"", getMessage("user_state"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_country", "text", "user_country", "", "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipCountry"), ENT_QUOTES)."\"", getMessage("user_country"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_tel", "text", "user_tel", "", "class=\"form\" required=\"false\" title=\"".htmlspecialchars(getMessage("tipTel"), ENT_QUOTES)."\"", getMessage("user_tel"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_fax", "text", "user_fax", "", "class=\"form\" required=\"false\" title=\"".htmlspecialchars(getMessage("tipFax"), ENT_QUOTES)."\"", getMessage("user_fax"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxCheckerField("charteSite", "checkbox", "charteSite", 1, "", "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipIAccept"), ENT_QUOTES)."\"");
// 			$GLOBALS["SYSTEM_TEMPLATE"]->MxCheckerField("blocSubscriptionsForms".".subscriptionform", "checkbox", "subscriptionform", 1, "", "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipAcceptSubscriptionForm"), ENT_QUOTES)."\"");
// 			for ($i=0; $i<count($allSubscriptionsForms);$i++)
// 			{
// 				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("blocSubscriptionsForms".".subscriptionsforms".".name", getMessage($allSubscriptionsForms[$i]["subscription_type"]));
// 				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("blocSubscriptionsForms".".subscriptionsforms".".amount", $allSubscriptionsForms[$i]["subscription_amount"]);
// 				$GLOBALS["SYSTEM_TEMPLATE"]->MxCheckerField("blocSubscriptionsForms".".subscriptionsforms".".value", "radio", "subscriptiontype", $allSubscriptionsForms[$i]["subscription_type"], "", "");
// 				$GLOBALS['SYSTEM_TEMPLATE']->MxBloc("blocSubscriptionsForms".".subscriptionsforms", "loop");
// 			}
// 			foreach( $arrPaymentMethods as $key => $value )
// 			{
// 				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("blocSubscriptionsForms".".paymentMethods".".name", getMessage("lblPayMtd_".$key));
// 				$GLOBALS["SYSTEM_TEMPLATE"]->MxCheckerField("blocSubscriptionsForms".".paymentMethods".".value", "radio", "paymentMethod", $key, "", "");
// 				$GLOBALS["SYSTEM_TEMPLATE"]->MxBloc("blocSubscriptionsForms".".paymentMethods", "loop");
// 			}
// 			$GLOBALS["SYSTEM_TEMPLATE"]->MxCheckerField("blocSubscriptionsForms".".subsmladh", "checkbox", "subsmladh", 1, "", "title='".htmlspecialchars(getMessage("tipAcceptSubsMLAdh"), ENT_QUOTES)."'");
			if( file_exists($GLOBALS["CONF_DATA_PATH"]."data/message/".$currentCode."/charte_inscription_".$_GET['param'].".inc") )
			{
				$file=new File($GLOBALS["CONF_DATA_PATH"]."data/message/".$currentCode."/charte_inscription_".$_GET['param'].".inc", "r");
				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("charteSiteContent", $file->readAll());
			} else
				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("charteSiteContent", htmlspecialchars(getMessage("textNoCharte")));
		}
		else // On raffiche les données saisies par l'utilisateur
		{
			$titre = array(getMessage("mr"),getMessage("mrs"),getMessage("miss"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxSelect("user_title", "user_title",$_POST['user_title'], $titre, "", "");
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_first_name", "text", "user_first_name", $_POST['user_first_name']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_last_name", "text", "user_last_name", $_POST['user_last_name']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_login", "text", "user_login", $_POST['user_login']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_password", "password", "user_password", "");
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_password2", "password", "user_password2", "");
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_mail", "text", "user_mail", $_POST['user_mail']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_birthdate", "text", "user_birthdate", $_POST['user_birthdate']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_msn", "text", "user_msn", $_POST['user_msn']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_jabber", "text", "user_jabber", $_POST['user_jabber']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_facebook", "text", "user_facebook", $_POST['user_facebook']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_mastodon", "text", "user_mastodon", $_POST['user_mastodon']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_website", "text", "user_website", $_POST['user_website']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_code", "text", "user_postal_code", $_POST['user_postal_code']);
			if( isset($_POST['user_postal_adress']) )
				$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_adress", "text", "user_postal_adress", $_POST['user_postal_adress']);
			else
				$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_adress", "text", "user_postal_adress", $_POST['user_postal_addressmand']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_adressmand", "text", "user_postal_adressmand", $_POST['user_postal_adressmand']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_city", "text", "user_city", $_POST['user_city']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_state", "text", "user_state", $_POST['user_state']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_country", "text", "user_country", $_POST['user_country']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_tel", "text", "user_tel", $_POST['user_tel']);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_fax", "text", "user_fax", $_POST['user_fax']);
			if(  isset($_POST["charteSite"]) && $_POST["charteSite"] == 1 )
				$GLOBALS["SYSTEM_TEMPLATE"]->MxCheckerField("charteSite", "checkbox", "charteSite", 1, "checked=checked");
			else
				$GLOBALS["SYSTEM_TEMPLATE"]->MxCheckerField("charteSite", "checkbox", "charteSite", 1, "");
// 			if(  $_POST["subscriptionform"] == 1 )
// 				$GLOBALS["SYSTEM_TEMPLATE"]->MxCheckerField("blocSubscriptionsForms".".subscriptionform", "checkbox", "subscriptionform", 1, "cheched=checked");
// 			else
// 				$GLOBALS["SYSTEM_TEMPLATE"]->MxCheckerField("blocSubscriptionsForms".".subscriptionform", "checkbox", "subscriptionform", 1, "");
// 			for ($i=0; $i<count($allSubscriptionsForms);$i++)
// 			{
// // 				if( isset($allSubscriptionsForms[$i]["subscription_type"]) )
// 				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("blocSubscriptionsForms".".subscriptionsforms".".name", getMessage($allSubscriptionsForms[$i]["subscription_type"]));
// 				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("blocSubscriptionsForms".".subscriptionsforms".".amount", $allSubscriptionsForms[$i]["subscription_amount"]);
// 				if( isset($allSubscriptionsForms[$i]["subscription_type"]) && $_POST["subscriptiontype"] == $allSubscriptionsForms[$i]["subscription_type"] )
// 					$GLOBALS["SYSTEM_TEMPLATE"]->MxCheckerField("blocSubscriptionsForms".".subscriptionsforms".".value", "radio", "subscriptiontype", $allSubscriptionsForms[$i]["subscription_type"], "checked=checked", "");
// 				else
// 					$GLOBALS["SYSTEM_TEMPLATE"]->MxCheckerField("blocSubscriptionsForms".".subscriptionsforms".".value", "radio", "subscriptiontype", $allSubscriptionsForms[$i]["subscription_type"], "", "");
// 				$GLOBALS['SYSTEM_TEMPLATE']->MxBloc("blocSubscriptionsForms".".subscriptionsforms", "loop");
// 			}
// 			foreach( $arrPaymentMethods as $key => $value )
// 			{
// 				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("blocSubscriptionsForms".".paymentMethods".".name", getMessage("lblPayMtd_".$key));
// 				if( isset($_POST["paymentMethod"]) && $_POST["paymentMethod"] == $key )
// 					$GLOBALS["SYSTEM_TEMPLATE"]->MxCheckerField("blocSubscriptionsForms".".paymentMethods".".value", "radio", "paymentMethod", $key, "checked=checked", "");
// 				else
// 					$GLOBALS["SYSTEM_TEMPLATE"]->MxCheckerField("blocSubscriptionsForms".".paymentMethods".".value", "radio", "paymentMethod", $key, "", "");
// 				$GLOBALS["SYSTEM_TEMPLATE"]->MxBloc("blocSubscriptionsForms".".paymentMethods", "loop");
// 			}
// 			$GLOBALS["SYSTEM_TEMPLATE"]->MxCheckerField("blocSubscriptionsForms".".subsmladh", "checkbox", "subsmladh", 1, "", "title='".htmlspecialchars(getMessage("tipAcceptSubsMLAdh"), ENT_QUOTES)."'");
			$file=new File($GLOBALS["CONF_DATA_PATH"]."data/message/".$currentCode."/charte_inscription_".$_GET['param'].".inc", "r");
			$GLOBALS["SYSTEM_TEMPLATE"]->MxText("charteSiteContent", $file->readAll());
		}
		ExitBloc();
		return "";
	}

public function formLectureQaptcha()
	{
	
		$GLOBALS["SYSTEM_TEMPLATE"] = new ModeliXeGranilim($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_coordination/mygamecharacters/ajaxdata.mxt");
		$GLOBALS["SYSTEM_TEMPLATE"]->SetMxFileParameter($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR'].$GLOBALS['SYSTEM_TEMPLATE_CONF']);
		$GLOBALS["SYSTEM_TEMPLATE"]->SetModeliXe(true);
		
		$aResponse['error'] = false;
	
		if(isset($_POST['action']) && isset($_POST['qaptcha_key']))
		{
			$_SESSION['qaptcha_key'] = false;	
			
			if(htmlentities($_POST['action'], ENT_QUOTES, 'UTF-8') == 'qaptcha')
			{
				$_SESSION['qaptcha_key'] = $_POST['qaptcha_key'];
				echo json_encode($aResponse);
			}
			else
			{
				$aResponse['error'] = true;
				echo json_encode($aResponse);
			}
		}
		else
		{
			$aResponse['error'] = true;
			echo json_encode($aResponse);
		}
	}

	public function execFormLecture()
	{
		/*Récupération des messages utilisateurs*/
		addMessageFile("user.ini");
               /* gestion du lib en fonction de la langue courante */
                $currentCode=$GLOBALS["SYSTEM_USER_SESSION"]->langue->getCode();
                $defaultCode=$GLOBALS["SYSTEM_DEFAULT_LANGUAGE_CODE"];
                /* fin récupération des codes par defaut */

		if($_GET["type"] == "user_first_name"){
			if( strlen($_GET["user_first_name"])==0 ){
				$returnValue = 0;
				$returnMessage = htmlspecialchars(getMessage("ajaxFirstNameUndefined"));
				$this->printMXJson($returnValue, $returnMessage);
			}
			elseif( strlen($_GET["user_first_name"])<3 ){
				$returnValue = 0;
				$returnMessage = htmlspecialchars(getMessage("ajaxFirstNameTooShort"));
				$this->printMXJson($returnValue, $returnMessage);
			}
			elseif( strlen($_GET["user_first_name"])>64 ){
				$returnValue = 0;
				$returnMessage = htmlspecialchars(getMessage("ajaxFirstNameTooLong"));
				$this->printMXJson($returnValue, $returnMessage);
			}
			else { 
				$bolean = checkDataChars($_GET["user_first_name"], "/[\/:*!,?§%µ¤£~«<>|°{}1234567890]/");
				if( $bolean == false ){
					$returnValue = 0;
					$returnMessage = htmlspecialchars(getMessage("ajaxFirstNameBadChars"));
					$this->printMXJson($returnValue, $returnMessage);
				} else {
					$returnValue = 1;
					$returnMessage = "Identifiant valide !";
					$this->printMXJson($returnValue, $returnMessage);
				}
			}
		}
		if($_GET["type"] == "user_last_name"){
			if( strlen($_GET["user_last_name"])==0 ){
				$returnValue = 0;
				$returnMessage = htmlspecialchars(getMessage("ajaxLastNameUndefined"));
				$this->printMXJson($returnValue, $returnMessage);
			}
			elseif( strlen($_GET["user_last_name"])<3 ){
				$returnValue = 0;
				$returnMessage = htmlspecialchars(getMessage("ajaxLastNameTooShort"));
				$this->printMXJson($returnValue, $returnMessage);
			}
			elseif( strlen($_GET["user_last_name"])>64 ){
				$returnValue = 0;
				$returnMessage = htmlspecialchars(getMessage("ajaxLastNameTooLong"));
				$this->printMXJson($returnValue, $returnMessage);
			}
			else { 
				$bolean = checkDataChars($_GET["user_last_name"], "/[\/:*!,?§%µ¤£~«<>|°{}1234567890]/");
				if( $bolean == false ){
					$returnValue = 0;
					$returnMessage = htmlspecialchars(getMessage("ajaxLastNameBadChars"));
					$this->printMXJson($returnValue, $returnMessage);
				} else {
					$returnValue = 1;
					$returnMessage = "Identifiant valide !";
					$this->printMXJson($returnValue, $returnMessage);
				}
			}
		} 
		if($_GET["type"] == "login"){
		
                        /*Inclusion de la librairie UserManagerDb pour effectuer l'insertion et la vérif dans la table sys_user_temp*/
			include_once($GLOBALS['CONF_LIB_PATH']."lib/system/system_data/user/ressource/usermanagerdb.php");
			//Création de l'objet
			$MyManager=new UserManagerDb();
			//On fixe la table par la méthode getTable
			$MyManager->setTable("sys_object_user_temp");

			/*Inclusion de la librairie NodeGroupUserManagerDb pour effectuer l'insertion dans la table sys_node_group_user_temp*/
			include_once($GLOBALS['CONF_LIB_PATH']."lib/system/system_data/nodegroupuser/ressource/nodegroupusermanagerdb.php");
			//Création de l'objet
			$MyNodeGroupUser=new NodeGroupUserManagerDb();
			//On fixe la table par la méthode getTable
			$MyNodeGroupUser->setTable("sys_object_node_group_user_temp");

			if( strlen($_GET["login"])==0 ){
				$returnValue = 0;
				$returnMessage = htmlspecialchars(getMessage("ajaxLoginUndefined"));
				$this->printMXJson($returnValue, $returnMessage);
			}

			elseif( strlen($_GET["login"])<4 ){
				$returnValue = 0;
				$returnMessage = htmlspecialchars(getMessage("ajaxLoginTooShort"));
				$this->printMXJson($returnValue, $returnMessage);
			}

			elseif( strlen($_GET["login"])>48 ){
				$returnValue = 0;
				$returnMessage = htmlspecialchars(getMessage("ajaxLoginTooLong"));
				$this->printMXJson($returnValue, $returnMessage);
			}

			else { 
				$bolean = checkDataChars($_GET["login"], "/[\/:*!,?§%µ¤£~«<>|°{}]/");
				if( $bolean == false || $MyManager->checkLoginExist($_GET["login"]) || $GLOBALS['SYSTEM_MANAGER']['USER']->checkLoginExist($_GET["login"]) ){
					$returnValue = 0;
					$returnMessage = htmlspecialchars(getMessage("ajaxLoginBadChars"));
					$this->printMXJson($returnValue, $returnMessage);
				} else {
					$returnValue = 1;
					$returnMessage = "Identifiant valide !";
					$this->printMXJson($returnValue, $returnMessage);
				}
			}
		}
		if($_GET["type"] == "user_passwords"){

			if( strlen($_GET["user_password"])==0 ){
				$returnValue = 0;
				$returnMessage = htmlspecialchars(getMessage("ajaxUserPasswordUndefined"));
				$this->printMXJson($returnValue, $returnMessage);
			}

			elseif( strlen($_GET["user_password2"])==0 ){
				$returnValue = 0;
				$returnMessage = htmlspecialchars(getMessage("ajaxUserPassword2Undefined"));
				$this->printMXJson($returnValue, $returnMessage);
			}

			elseif( strlen($_GET["user_password"])<7 ){
				$returnValue = 0;
				$returnMessage = htmlspecialchars(getMessage("ajaxUserPasswordTooShort"));
				$this->printMXJson($returnValue, $returnMessage);
			}

			elseif( $_GET["user_password"] != $_GET["user_password2"] ){
				$returnValue = 0;
				$returnMessage = htmlspecialchars(getMessage("ajaxUserPasswordCheckFailed"));
				$this->printMXJson($returnValue, $returnMessage);
			}

			else {
				$returnValue = 1;
				$returnMessage = "Mot de passe valide !";
				$this->printMXJson($returnValue, $returnMessage);
			}
		}
		if($_GET["type"] == "user_mail"){

			if( strlen($_GET["user_mail"])==0 ){
				$returnValue = 0;
				$returnMessage = htmlspecialchars(getMessage("ajaxCourrielUndefined"));
				$this->printMXJson($returnValue, $returnMessage);
			} 
			else { 
				$result = checkMail($_GET["user_mail"]);
				if( $result != "Valide"){
					$returnValue = 0;
					$returnMessage = $result;
					$this->printMXJson($returnValue, $returnMessage);
				} else {
					$returnValue = 1;
					$returnMessage = "Adresse courriel valide !";
					$this->printMXJson($returnValue, $returnMessage);
				}
			}
		}
		if($_GET["type"] == "user_birthdate"){

			if( strlen($_GET["user_birthdate"])==0 ){
				$returnValue = 0;
				$returnMessage = htmlspecialchars(getMessage("ajaxBirthDateUndefined"));
				$this->printMXJson($returnValue, $returnMessage);
			} 
			else {
				$bolean = preg_match('/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/', $_GET["user_birthdate"]);
				if( $bolean == false ){
					$returnValue = 0;
					$returnMessage = "Date invalide !";
					$this->printMXJson($returnValue, $returnMessage);
				} else {
					$returnValue = 1;
					$returnMessage = "Date valide !";
					$this->printMXJson($returnValue, $returnMessage);
				}
			}
		}
	}

	public function execQaptcha()
	{
		/*Récupération des messages utilisateurs*/
		addMessageFile("user.ini");
               /* gestion du lib en fonction de la langue courante */
                $currentCode=$GLOBALS["SYSTEM_USER_SESSION"]->langue->getCode();
                $defaultCode=$GLOBALS["SYSTEM_DEFAULT_LANGUAGE_CODE"];
                /* fin récupération des codes par defaut */

                // check if $_SESSION['qaptcha_key'] created with AJAX exists
		if(isset($_SESSION['qaptcha_key']) && !empty($_SESSION['qaptcha_key']))
		{
		  $myVar = $_SESSION['qaptcha_key'];
		
		  // check if the random input created exists and is empty
		  if(isset($_POST[''.$myVar.'']) && empty($_POST[''.$myVar.'']))
		  {
			/* Headers XML */
			header("Content-type: text/plain");
			header("Cache-Control: no-cache, must-revalidate");           // HTTP/1.1
			header("Pragma: no-cache");

			/* Appel du modèle mxt spécifique à l'affichage des catégories/rubriques */
			$GLOBALS["SYSTEM_TEMPLATE"] = new ModeliXeGranilim($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_coordination/home/qaptcha.mxt");
			$GLOBALS["SYSTEM_TEMPLATE"]->SetMxFileParameter($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR'].$GLOBALS['SYSTEM_TEMPLATE_CONF']);
			$GLOBALS["SYSTEM_TEMPLATE"]->SetModeliXe(true);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxText("return", var_dump($_POST));
		  }
		  else
		  {
		    /* Headers XML */
			header("Content-type: text/plain");
			header("Cache-Control: no-cache, must-revalidate");           // HTTP/1.1
			header("Pragma: no-cache");

			/* Appel du modèle mxt spécifique à l'affichage des catégories/rubriques */
			$GLOBALS["SYSTEM_TEMPLATE"] = new ModeliXeGranilim($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_coordination/home/qaptcha.mxt");
			$GLOBALS["SYSTEM_TEMPLATE"]->SetMxFileParameter($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR'].$GLOBALS['SYSTEM_TEMPLATE_CONF']);
			$GLOBALS["SYSTEM_TEMPLATE"]->SetModeliXe(true);
			$GLOBALS["SYSTEM_TEMPLATE"]->MxText("return", $_POST);
		  }
		}
		unset($_SESSION['qaptcha_key']);
	}

/**
* Fonction de sortie Modelixe en Json
*/
	function printMXJson($returnValue, $returnMessage)
	{
		/* Headers XML */
		header("Content-type: text/plain");
		header("Cache-Control: no-cache, must-revalidate");           // HTTP/1.1
		header("Pragma: no-cache");

		/* Appel du modèle mxt spécifique à l'affichage des catégories/rubriques */
		$GLOBALS["SYSTEM_TEMPLATE"] = new ModeliXeGranilim($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_coordination/home/checkform.mxt");
		$GLOBALS["SYSTEM_TEMPLATE"]->SetMxFileParameter($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR'].$GLOBALS['SYSTEM_TEMPLATE_CONF']);
		$GLOBALS["SYSTEM_TEMPLATE"]->SetModeliXe(true);
		$GLOBALS["SYSTEM_TEMPLATE"]->MxText("returnValue", $returnValue);
		$GLOBALS["SYSTEM_TEMPLATE"]->MxText("returnMessage", $returnMessage);
	}

/**
* Function affichant le texte de présentation détaillé pour le noeud d'entrée une fois authentifié
* @access public
* @return chaine chaine vide
*/

	function actionAccueil()
	{
		global $SERVER_NAME, $SCRIPT_NAME, $CONF_PERSISTANT_SECURE,$CONF_DATA_PATH;
		/* On inclus la template (voir package.template.php) */

		WithBlocPath("Home", "actionAccueil");

		/*Récupération des messages utilisateurs*/
		addMessageFile("user.ini");

		/* gestion du lib en fonction de la langue courante */
		$currentCode=$GLOBALS["SYSTEM_USER_SESSION"]->langue->getCode();
		$defaultCode=$GLOBALS["SYSTEM_DEFAULT_LANGUAGE_CODE"];
		/* fin récupération des codes par defaut */

		//Récupération de l'identifiant de la communauté : methode en fin de page
		$nodeId = recupCommunity();

		if(is_numeric($nodeId)) //si le noeud existe
		{
			//On récupère le texte du noeud choisi par l'internaute
			$sql="SELECT * FROM ".DATA_ACCES_TABLE_PREFIX.DATA_ACCES_OBJECT_PREFIX."textentrynode WHERE node_id=".$nodeId;
			# Exécution de Requete
			$result=$GLOBALS['SYSTEM_DATABASE_CONN']->sql_query($sql);

			# Teste si il y a des enregistrements
			if ($GLOBALS['SYSTEM_DATABASE_CONN']->sql_numrows()>0)
			{
				$list = $GLOBALS['SYSTEM_DATABASE_CONN']->sql_fetchrow();
				$text = $list['text'];
				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("textAccueil",$text);
			}else{
				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("textAccueil",getMessage("NoText"));
			}

	    		# Destruction des éléments
    		    	$GLOBALS['SYSTEM_DATABASE_CONN']->sql_freeresult();
		}
		ExitBloc();
		return "";
	}



/**
* Function permettant de rafficher le contenu pour modification dans la bd
* @access public
* @return chaine chaine html
*/
    function actionAdmin()
    {
		/*Récupération des messages utilisateurs*/
		addMessageFile("object.ini");
		addMessageFile("adminhome.ini");
		
		/* gestion du lib en fonction de la langue courante */
		$currentCode=$GLOBALS["SYSTEM_USER_SESSION"]->langue->getCode();
		$defaultCode=$GLOBALS["SYSTEM_DEFAULT_LANGUAGE_CODE"];
		/* fin récupération des codes par defaut */

		mxPageTitle("methodActionAdminHomeTitlePage");
		
		/* Instanciation du wysiwyg */
		$wysiResume = new Wysi("contentResumeInfos", "postTextInfos", "fr_FR", "", "summernote", "", 180);
		$wysiResume->includeDependancy();
		
		$wysiText = new Wysi("contentTextInfos", "postTextInfos", "fr_FR", "", "summernote");
		$wysiText->includeRawJs();
	
		//$this->tabeCreate();
		$text =getMessage("NoText");

		/* On inclus la template (voir package.template.php) */
		withBlocPath("Home", "actionAdmin");

		/* creation des onglets */
		$this->tabeCreate();
		
		// Cas où le noeud correspond à la racine de la plateforme Qware
		if(recupCommunity() === "3") $nodeId = "2"; else $nodeId = recupCommunity();
		
		# Requete sur identifiant de l objet de coordination correspondant
		$sql="SELECT * FROM ".DATA_ACCES_TABLE_PREFIX.DATA_ACCES_OBJECT_PREFIX."textentrynode WHERE node_id=".$nodeId." AND langue_id=".$GLOBALS["SYSTEM_USER_SESSION"]->langue->getId();
		# Execution de Requete
		$result=$GLOBALS['SYSTEM_DATABASE_CONN']->sql_query($sql);

		# Teste si il y a des enregistrements
		if ($GLOBALS['SYSTEM_DATABASE_CONN']->sql_numrows()>0)
		{
			# On récupère les données en variable
			$View = $GLOBALS['SYSTEM_DATABASE_CONN']->sql_fetchrow();
			if($View['textentrynode_resume'] != "")
				$resume = $View['textentrynode_resume'];
			if($View['textentrynode_text'] != "")
				$text = $View['textentrynode_text'];
			# Destruction des resultats
			$GLOBALS['SYSTEM_DATABASE_CONN']->sql_freeresult();
		} else {
			$text = getMessage("");
		}
		// Résumé de la communauté
		$wysiResume->SetContent($resume);
		$GLOBALS["SYSTEM_TEMPLATE"]->MxText("wysiResume", $wysiResume->Display());
		
		// Texte complet de la communauté
		$wysiText->SetContent($text);
		$GLOBALS["SYSTEM_TEMPLATE"]->MxText("wysiText", $wysiText->Display());
			
		$GLOBALS["SYSTEM_TEMPLATE"]->MxText("currentLang", $currentCode);
		$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("urlAction", Navigation::formatUrl($this->getId(), "Home", "execAdmin"));

		return "";
	}

/**
* Function permettant de modifier le contenu dans la bd et redirection(traitement)
* @access public
* @return chaine chaine vide
*/
    function execAdmin()
    {
		global $SERVER_NAME, $SCRIPT_NAME, $CONF_PERSISTANT_SECURE, $CONF_DATA_PATH;

		// Cas où le noeud correspond à la racine de la plateforme Qware
		if(recupCommunity() === "3") $nodeId = "2"; else $nodeId = recupCommunity();
        
		# Requete sur identifiant de l objet de coordination correspondant
		$sql="SELECT * FROM ".DATA_ACCES_TABLE_PREFIX.DATA_ACCES_OBJECT_PREFIX."textentrynode WHERE node_id=".$nodeId." AND langue_id=".$GLOBALS["SYSTEM_USER_SESSION"]->langue->getId();
		# Exécution de Requete
		$result=$GLOBALS['SYSTEM_DATABASE_CONN']->sql_query($sql);

		# Teste si il y a des enregistrements
		if ($GLOBALS['SYSTEM_DATABASE_CONN']->sql_numrows()>0)
		{
			# Requete sur identifiant de l objet de coordination correspondant
//     	    $sql="UPDATE ".DATA_ACCES_TABLE_PREFIX.DATA_ACCES_OBJECT_PREFIX."textentrynode SET textentrynode_text='".$_POST['contentTextInfos']."', textentrynode_resume='".$_POST['contentResumeInfos']."' WHERE node_id=".recupCommunityByDomain($_SERVER["HTTP_HOST"])." AND langue_id=".$GLOBALS["SYSTEM_USER_SESSION"]->langue->getId();
			$sql="UPDATE ".DATA_ACCES_TABLE_PREFIX.DATA_ACCES_OBJECT_PREFIX."textentrynode SET textentrynode_text='".$_POST['contentTextInfos']."', textentrynode_resume='".$_POST['contentResumeInfos']."' WHERE node_id=".$nodeId." AND langue_id=".$GLOBALS["SYSTEM_USER_SESSION"]->langue->getId();
			# Exécution de Requete
    	    $result=$GLOBALS['SYSTEM_DATABASE_CONN']->sql_query($sql);
		}
		else
		{
			# Requete sur identifiant de l objet de coordination correspondant
//			$sql="INSERT INTO ".DATA_ACCES_TABLE_PREFIX.DATA_ACCES_OBJECT_PREFIX."textentrynode (textentrynode_text, textentrynode_resume, node_id, langue_id) VALUES ('".$_POST['contentTextInfos']."','".$_POST['contentResumeInfos']."',".recupCommunityPublic().",".$GLOBALS["SYSTEM_USER_SESSION"]->langue->getId().")";
			$sql="INSERT INTO ".DATA_ACCES_TABLE_PREFIX.DATA_ACCES_OBJECT_PREFIX."textentrynode (textentrynode_text, textentrynode_resume, node_id, langue_id) VALUES ('".$_POST['contentTextInfos']."','".$_POST['contentResumeInfos']."',".$nodeId.",".$GLOBALS["SYSTEM_USER_SESSION"]->langue->getId().")";
			
			# Exécution de Requete
			$result=$GLOBALS['SYSTEM_DATABASE_CONN']->sql_query($sql);
		}

		# Destruction des éléments
		$GLOBALS['SYSTEM_DATABASE_CONN']->sql_freeresult();

		# Redirection vers le formulaire
		systemRedirect(Navigation::formatUrl($this->getId(),"Home", "actionAdmin", "datamodified"));
		return "";
	}

/**
* Function permettant de controler les doublons, d'inscrire dans la bd et redirection avec message
* @access public
* @return chaine chaine vide
*/
    function execLecture()
    {
        global $SERVER_NAME, $SCRIPT_NAME, $CONF_PERSISTANT_SECURE,$CONF_DATA_PATH;

		/* gestion du lib en fonction de la langue courante */
		$currentCode=$GLOBALS["SYSTEM_USER_SESSION"]->langue->getCode();
		$defaultCode=$GLOBALS["SYSTEM_DEFAULT_LANGUAGE_CODE"];
		/* fin récupération des codes par defaut */

		/*Récupération des messages utilisateurs*/
		addMessageFile("user.ini");
		//On vide la chaine de vérification des champs obligatoires
		$chaine = "";

		if($_POST)
		{
			foreach($_POST as $cle=>$val)
			{
			//	echo "cle = ".$cle." val =".$val."<br>";
				if($val=="" && ($cle !="user_comment" && $cle !="user_fax" && $cle !="user_organisation" && $cle !="user_country"))
				{
					$chaine .= getMessage($cle).", ";
				}
			}
			if($chaine!="")
			{
			$chaine .= getMessage('obligatory');
			}
		}

/*
* Olivier case du chemin.... :-(
* 22/06/05
*/
		//Si certains champs sont manquants pour l'inscription
		if ($chaine != "")
		{
			$GLOBALS["SYSTEM_CONTROL"]->messageSystem = $chaine;
			$GLOBALS["SYSTEM_TEMPLATE"]->MxBloc("DATA", "modify", $GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_coordination/home/formlecture.mxt");
			$GLOBALS["SYSTEM_TEMPLATE"]->WithMxPath("DATA", "relative");
			$this->formLecture($_POST);
			return "";
		}
		else
		{
			if($_POST["user_password"] != $_POST["user_password2"])
			{
				$GLOBALS["SYSTEM_CONTROL"]->messageSystem = "password_error";
				$GLOBALS["SYSTEM_TEMPLATE"]->MxBloc("DATA", "modify", 		$GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_coordination/home/formlecture.mxt");
				$GLOBALS["SYSTEM_TEMPLATE"]->WithMxPath("DATA", "relative");
				$this->formLecture($_POST);
				return "";
			}

		}
/*
* Olivier DEVAINE 13/01/05 -> plus besoin de la charte
*/
//		if(isset($_POST['user_chart']))
//		{
			/*Inclusion de la librairie UserManagerDb pour effectuer l'insertion et la vérif dans la table sys_user_temp*/
			include_once($GLOBALS['CONF_LIB_PATH']."lib/system/system_data/User/ressource/usermanagerdb.php");
			//Création de l'objet
			$MyManager=new UserManagerDb();
			//On fixe la table par la méthode getTable
			$MyManager->setTable("sys_user_temp");

			/*Inclusion de la librairie NodeGroupUserManagerDb pour effectuer l'insertion dans la table sys_node_group_user_temp*/
			include_once($GLOBALS['CONF_LIB_PATH']."lib/system/system_data/NodeGroupUser/ressource/nodegroupusermanagerdb.php");
			//Création de l'objet
			$MyNodeGroupUser=new NodeGroupUserManagerDb();
			//On fixe la table par la méthode getTable
			$MyNodeGroupUser->setTable("sys_node_group_user_temp");

			# Teste si il y a des enregistrements sur MyManager (table temporaire) ou sur la table des comptes
			if (($MyManager->checkValid($_POST["user_login"], $_POST["user_password"]) != 0) || ($GLOBALS['SYSTEM_MANAGER']['USER']->checkValid($_POST["user_login"], $_POST["user_password"]) != 0))
			{
				$GLOBALS["SYSTEM_CONTROL"]->messageSystem = "user_exist";
				$GLOBALS["SYSTEM_TEMPLATE"]->MxBloc("DATA", "modify", $GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_coordination/home/formlecture.mxt");
				$GLOBALS["SYSTEM_TEMPLATE"]->WithMxPath("DATA", "relative");
				$this->formLecture($_POST);
	//			systemRedirect(Navigation::formatUrl($this->getId(),"Home","formLecture","user_exist"));
			  }
			else
			  {
				//On créé un nouvel objet User pour effectuer l'insertion de chaque champs
				$MyUser=new User();

				$MyUser->setTitle($_POST['user_title']);
				$MyUser->setFirstName($_POST['user_first_name']);
				$MyUser->setLastName($_POST['user_last_name']);
				$MyUser->setLogin($_POST['user_login']);
				$MyUser->setPassword($_POST['user_password']);
				$MyUser->setMail($_POST['user_mail']);
				$MyUser->setPostalAddress($_POST['user_postal_address']);
				$MyUser->setPostalCode($_POST['user_postal_code']);
				$MyUser->setCity($_POST['user_city']);
				$MyUser->setState($_POST['user_state']);
				$MyUser->setCountry($_POST['user_country']);
				$MyUser->setOrganisation($_POST['user_organisation']);
				$MyUser->setTel($_POST['user_tel']);
				$MyUser->setFax($_POST['user_fax']);
				$MyUser->setComment($_POST['user_comment']);
				//On enregistre les paramètres
				$ObjUsersave = $MyManager->saveInstance($MyUser);

				//Insertion du noeud temporaire de l'utilisateur
				//Champs concernés : user_id, group_id, node_id, is_node_only, is_forbidden
				$MyNodeUser =new NodeGroupUser();
				$MyNodeUser->setUserId($ObjUsersave->getId());
				if(isset($_GET['param']))
				{
					$MyNodeUser->setNodeId($_GET['param']);
				}
				$MyNodeUser->setGroupId(0);
				$MyNodeUser->setIsForbidden(0);
				$MyNodeUser->setIsNodeOnly(0);

				//on enregistre les paramètres
				$test = $MyNodeGroupUser->saveInstance($MyNodeUser);

				/*Indexation dans le moteur de recherche*/
				if (includePackage("search.php")){
					$status=1;
					Search::addSearch("&param=".$ObjUsersave->getId(), "usertemp", array("actionManageRegister"=>"actionManageRegister"), $MyUser->getFirstName()." ".$MyUser->getLastName(), $MyUser->getMail()." ".$MyUser->getTel(), "", $status, 0, 0, 0, $_GET['param']);
					/*On récupère l'oid de l'objet dans les droits selon le nid de la communauté*/
					/*$oidObj = Search::getOidFromNameAndNode("usertemp", $_GET['param']);
					if($oidObj != 0)
					{
					Search::addSearch("&param=".$ObjUsersave->getId(), "usertemp", array("actionManageRegister"=>"actionManageRegister"), $MyUser->getFirstName()." ".$MyUser->getLastName(), $MyUser->getMail()." ".$MyUser->getTel(), "", $status, $oidObj);
					}*/
				}

				# Redirection vers le formulaire
				systemRedirect(absoluteUrl("user_subscribe",$_GET['param']));
			}
//		}
//		else //si la Charte n'est pas validée
//		{
//				$GLOBALS["SYSTEM_CONTROL"]->messageSystem = "chartnessaryaccept";
//				$GLOBALS["SYSTEM_TEMPLATE"]->MxBloc("DATA", "modify", $GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_coordination/home/formLecture.mxt");
//				$GLOBALS["SYSTEM_TEMPLATE"]->WithMxPath("DATA", "relative");
//				$this->formLecture($_POST);
//		}
        return "";
    }

	/**
	* getAllRow4Export : recupere tous les enregistrements utilisé par l'objet de coordination 
	* le tableau est constiué de la nom_du_champ=valeur_du_champ
	* Si aucune données n'est à exporter, la méthode return null
	* @access public
	* @return tableau associatif
	*/
	function getAllRow4Export(){
		$nodeId = recupCommunity();
		$datas = array();
		
		if(is_numeric($nodeId)){
			$sql="SELECT * FROM ".DATA_ACCES_TABLE_PREFIX.DATA_ACCES_OBJECT_PREFIX."textentrynode WHERE node_id=".$nodeId;
        		$result=$GLOBALS['SYSTEM_DATABASE_CONN']->sql_query($sql);
			if ($GLOBALS['SYSTEM_DATABASE_CONN']->sql_numrows()>0){
				$dataReturn = array();
				while($list = $GLOBALS['SYSTEM_DATABASE_CONN']->sql_fetchrow())
					$dataReturn[]=$list;
				$GLOBALS['SYSTEM_DATABASE_CONN']->sql_freeresult();

				$datas[0]["tableName"]=DATA_ACCES_TABLE_PREFIX.DATA_ACCES_OBJECT_PREFIX."textentrynode";
				$datas[0]["datas"]=$dataReturn;
				return $datas;
			}
		}
		return null;
	}

	/**
	* setAllRow4Import : Insert les donnes en provenance du tableau associatif
	* le tableau est constiué de la nom_du_champ=valeur_du_champ
	* Si les enregistrements se sont bien sauvegardés, return true
	* @access public
	* @param boolean
	*/
	function setAllRow4Import($tableau){
		$nodeId = recupCommunity();

		if(is_numeric($nodeId)){
			$sql="DELETE FROM ".DATA_ACCES_TABLE_PREFIX.DATA_ACCES_OBJECT_PREFIX."textentrynode WHERE node_id=".$nodeId;
        		$result=$GLOBALS['SYSTEM_DATABASE_CONN']->sql_query($sql);
		}

		for($j=0;$j < count($tableau);$j++){
			$tableName = $tableau[$j]["tableName"];
			$tableElem = $tableau[$j]["datas"];

			for($i=0;$i <count($tableElem);$i++){	
				unset($set);
				unset($values);
	
				foreach($tableElem[$i] as $key=>$value){
					if(!is_numeric($key)){
						(!isset($set))?$set=$key:$set.=",".$key;
						(!isset($values))?$values="'".$value."'":$values.=",'".$value."'";
					}
				}
				$sql = "INSERT INTO ".$tableName." (".$set.") VALUES(".$values.")";
				$result=$GLOBALS['SYSTEM_DATABASE_CONN']->sql_query($sql);
			}
		}
		return true;
	}

/**
* recupere les fils d'un noeud depuis le noeud principal
* @access public
*/
	private function getObjectSon($nodeId)
	{
		$tab=$GLOBALS["SYSTEM_CONTROL"]->getListObjectForNavigation($nodeId);
		return $tab;
	}
}

/**
* Function permettant de verifié la validité d'un mail saisi
* @access public
* @return chaine chaine code message
*/
	function verifie_email($email){
		$email = strtolower($email);
		
		if (strlen($email) < 6){ return "$email : Email trop court";}
		if (strlen($email) > 255) {return "$email : Email trop long";}
		if (!ereg("@", $email)){ return "$email : Le email n'a pas d'arobase (@)";}
		if (preg_match_all("/([^a-zA-Z0-9_\@\.\-])/i", $email, $trouve))
		{
			return "$email : caractère(s) interdit(s) dans un email (".implode(", ", $trouve[0]).").";
		}
		if (!preg_match("/^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$/i", $email))
		{
			return "$email : ce n'est pas un la forme d'un email.";
		}
		list($compte, $domaine)=split("@", $email, 2);
		if (!checkdnsrr($domaine, "MX")){
			return "$email : Ce domaine ($domaine) n'accepte pas les emails";
		}
		return "$email : Valide !";
	}
?>
