<?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 AdminUser
* @link www.rooty.me
* @copyright Copyright &copy; 2009-2018, Rooty
* @author Rooty <www.rooty.me|rooty@rooty.me>
* @since 2004/09/03
* @version 0.3
* @package object_coordination
* @subpackage AdminUser
*/

if ( !defined('SYSTEM_IN') )
{
 die("Hacking attempt");
}
/**
* Classe AdminUser
*
* Classe pour gérer les comptes et leur association aux groupes
* @package object_coordination
* @subpackage AdminUser
* 
*/
Class AdminUser extends CoordinationObj
{
/**
* @access private
* @return booleen true
*/
	function tabeCreate()
	{
		$tabPictoTabe = array("cogs","plus");
		$tabTabe = array("listUser","BtnAdd");
		$tabAction = array( array("actionAdmin", "changeUserAdmin", "deleteGroupUserAdmin"), array("addUserAdmin") );
		$tabUrlTabe = array(formatUrl($this->getId(), "AdminUser", "actionAdmin"),formatUrl($this->getId(), "AdminUser", "addUserAdmin"));
		printTabeAdmin("TabeB", $tabTabe, $tabUrlTabe, $tabPictoTabe, $tabAction);
		return true;
	}

/**
* Function permettant de lister et modifier l'affectation des comptes pour le groupe choisi
* @access public
* @return chaine chaine html
*/
	function actionAdmin()
    {
        if( isset($_GET['sEcho']) )
		{
			$this->getAjaxUsers($_GET);
		} else {/*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 */
			
			mxPageTitle("actionAdminTitlePage");
			
			$arrayCallCss = array();
			$arrayCallCss[] = "data/css/bootstrap-datepicker/1.9.0/bootstrap-datepicker3.min.css";
			$arrayCallCss[] = "data/css/dataTables.bootstrap4/1.10.22/dataTables.bootstrap4.min.css";
			mxCallCss($arrayCallCss);
			
			$arrayCallJs = array();
			$arrayCallJs[] = "data/javascript/bootstrap-datepicker/1.9.0/bootstrap-datepicker.min.js";
			$arrayCallJs[] = "data/javascript/bootstrap-datepicker/1.9.0/locales/bootstrap-datepicker.".$currentCode.".min.js";
			$arrayCallJs[] = "data/javascript/jquery.dataTables/1.10.22/jquery.dataTables.min.js";
			$arrayCallJs[] = "data/javascript/dataTables.bootstrap4/1.10.22/dataTables.bootstrap4.min.js";
			mxCallJs($arrayCallJs);
			
			$arrayRawJs[] = "\$(document).ready(function(){\$('#tabAdminUser').dataTable({\"bPaginate\": true,\"bFilter\": true,\"bInfo\": true,\"sPaginationType\": \"full_numbers\",\"bAutoWidth\": false,\"bLengthChange\": true,\"aaSorting\": [[ 1, \"asc\" ]],\"iDisplayLength\": 15,\"aLengthMenu\": [[15, 25, 50, 100, -1], [15, 25, 50, 100, \"All\"]],\"oLanguage\": {\"sUrl\": \"data/message/".$currentCode."/datatables_adminuser.txt\"}});$('.datepicker').datepicker();});";
			mxRawJs($arrayRawJs);
		
			/* On inclus la template (voir package.template.php) */
			withBlocPath("AdminUser", "actionAdmin");

			$this->tabeCreate();

			/* Récupèration du noeud à administrer sinon noeud d'entrée de l'admin */
			$groupId=($this->getData("groupId")!="")?$this->getData("groupId"):1; 		/* Tous les Groupes par défaut */
			$group_id=(isset($_POST["group_id"]) && is_numeric($_POST["group_id"]))?$_POST["group_id"]:((isset($_GET["group_id"]) && is_numeric($_GET["group_id"]))?$_GET["group_id"]:$groupId);

			/* Export des comptes */
			$GLOBALS['SYSTEM_TEMPLATE']->MxText("TxtExport", getMessage("TxtExport"));
			$GLOBALS['SYSTEM_TEMPLATE']->MxAttribut("urlSort", "document.FManageUser.action='".formatUrl($this->getId(),"AdminUser","actionAdmin")."';  document.FManageUser.target='';");
			$GLOBALS['SYSTEM_TEMPLATE']->MxAttribut("urlExport", "document.FManageUser.action='".formatUrl($this->getId(), "AdminUser", "exportAdmin")."';  document.FManageUser.target='blank';");
			$GLOBALS['SYSTEM_TEMPLATE']->MxSelect("exportFormat", "exportFormat", '', array('xml'=>'Xml','csv'=>'Csv','html'=>'Html','rss2.0'=>'RSS 2.0'), getMessage("TxtExport"), "", '', "class=\"form\"");

			/* Creation du Tree d'admin */
			$myTreeGroup=$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP"]->createInstance($groupId);
			/* Verification de l'existance du Tree */
			if ( !is_object($myTreeGroup) ){
				if ( $myTreeGroup->isLoaded()==false ){
					systemRedirect($urlReturn."&msg=WrongArgument");
					return "WrongArgument";
				}
			}
			// --> récupèration du treeNode correspondant au noeud
			$tabTreeGroup[0]=$myTreeGroup;		//--> treeNodeUnique....
			$tabId=array_merge(array($groupId), $tabTreeGroup[0]->getSonArray());
			$tabId=array_unique($tabId);

			/* BEGIN NEW USER FORM */
			$MyUser = $GLOBALS["SYSTEM_MANAGER"]["USER"]->createNewInstance();
			$MyUser->setFirstName("");
			$MyUser->setLastName("");
			$MyUser->setLogin("");
			$MyUser->setPassword("");
			$MyUser->setMail("");

			$titre = array(getMessage("mr"),getMessage("mrs"), getMessage("miss"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxSelect("user_title", "user_title", $MyUser->getTitle(), $titre, getMessage("user_title"), "", "", "class=\"form\" title=\"".htmlspecialchars(getMessage("tipSelectTitle"), ENT_QUOTES)."\"");
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_first_name", "text", "user_first_name", $MyUser->getFirstName(), "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", $MyUser->getLastName(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipLastName"), ENT_QUOTES)."\"", getMessage("user_last_name"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_login", "text", "user_login", $MyUser->getLogin(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipLogin"), ENT_QUOTES)."\"", getMessage("user_login"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_password", "password", "user_password", $MyUser->getPassword(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipPassword"), ENT_QUOTES)."\"", getMessage("user_password"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_password2", "password", "user_password2", $MyUser->getPassword(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipPassword2"), ENT_QUOTES)."\"", getMessage("user_password"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_mail", "text", "user_mail", $MyUser->getMail(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipCourriel"), ENT_QUOTES)."\"", getMessage("user_mail"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_birthdate", "text", "user_birthdate", $MyUser->getBirthDate(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipBirthDate"), ENT_QUOTES)."\"", getMessage("user_birthdate"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_code", "text", "user_postal_code", $MyUser->getPostalCode(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipPostalCode"), ENT_QUOTES)."\"", getMessage("user_postal_code"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_address", "textarea", "user_postal_address", $MyUser->getPostalAddress(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipPostalAddress"), ENT_QUOTES)."\"", getMessage("user_postal_address"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_organisation", "text", "user_organisation", $MyUser->getOrganisation(), "class=\"form\"");
			$tabcom = $MyUser->getComment();
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_coment", "text", "user_coment", (isset($tabcom[0])?$tabcom[0]:""), "class=\"form\"");
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_city", "text", "user_city", $MyUser->getCity(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipCity"), ENT_QUOTES)."\"", getMessage("user_city"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_state", "text", "user_state", $MyUser->getState(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipState"), ENT_QUOTES)."\"", getMessage("user_state"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_country", "text", "user_country", $MyUser->getCountry(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipCountry"), ENT_QUOTES)."\"", getMessage("user_country"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_tel", "text", "user_tel", $MyUser->getTel(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipTel"), ENT_QUOTES)."\"", getMessage("user_tel"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_fax", "text", "user_fax", $MyUser->getFax(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipFax"), ENT_QUOTES)."\"", getMessage("user_fax"));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("user_id", $MyUser->getId());
			# Récupération des étiquettes du formulaire
			$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("urlActionAdd", formatUrl($this->getId(),"AdminUser","execAddUserAdmin",""));
			$GLOBALS["SYSTEM_TEMPLATE"]->MxText("urlReturnAdd", formatUrl($this->GetId(),"AdminUser","actionAdmin"));
			
	// 		printTabTreeGroup($tabTreeGroup, $groupId, "GROUPUSER");
			printTabTreeGroup($tabTreeGroup, "", "GROUPUSER", "groupuser_id", '', getMessage("TxtGroup"));
			/* END NEW USER FORM */
			
			# Envoi du formulaire en fonction de l'action : encode le javascript
			$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("urlAction", formatUrl($this->GetId(),"AdminUser","actionAdmin"));

			if ($GLOBALS["SYSTEM_TEMPLATE"]->IsMxAttribut("urlAddUser"))
				$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("urlAddUser", formatUrl($this->GetId(),"AdminUser","addUserAdmin"));

			/* Affichage de la liste des groupes */
	// 		printTabTreeGroup($tabTreeGroup, $group_id, "GROUP");
			printTabTreeGroup($tabTreeGroup, $group_id, "GROUP", "group_id", '', getMessage("TxtGroup"));

			if(isset($group_id) && is_numeric($group_id))
			{
				/* Creation du Tree d'admin */
				$myTreeGroup			=$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP"]->createInstance($group_id);
				/* Verification de l'existance du Tree */
				if ( !is_object($myTreeGroup) ){
					if ( $myTreeGroup->isLoaded()==false ){
						systemRedirect($urlReturn."&msg=WrongArgument");
						return "WrongArgument";
					}
				}
				// --> recuperation du treeNode correspondant au noeurd
				$tabTreeGroup[0]=$myTreeGroup; //--> treeNodeUnique....

				//On récupère l'instance des noeuds et groupes temporaires
				$tabUser=$GLOBALS["SYSTEM_CONTROL"]->arrayOfAdministrableUserFromTabTreeGroup($tabTreeGroup);
	// 			var_dump($tabUser);

				if(count($tabUser)>0)
				{
					/* Pour le Tri/Nom */
					$tabName=array();

					for ($i=0; $i<count($tabUser);$i++)
					{
						$lib=$tabUser[$i]->getFirstName();
						$tabName[$i]=$lib;
					}
					asort($tabName);
					reset($tabName);

					while (list($i, $lib) = each($tabName))
					{
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.frmUser1",getMessage("frmUser1"));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.frmUser2",getMessage("frmUser2"));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.frmUser3",getMessage("frmUser3"));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.userGroupList",getMessage("userGroupList"));

						//On récupère les données de l'utilisateur concerné
						$currentUser=$tabUser[$i];
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.BtnUpdate",getMessage("BtnUpdate"));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.BtnDelete",getMessage("BtnDelete"));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("ligne.url_user",formatUrl($this->getId(),"AdminUser","ChangeUserAdmin","",$currentUser->getId()));
// 						$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("ligne.del_user",formatUrl($this->getId(),"AdminUser","ChangeUserAdmin","",$currentUser->getId()));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.vuser_first_name", htmlentitiesconv($currentUser->getFirstName()));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.vuser_last_name", htmlentitiesconv($currentUser->getLastName()));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.vuser_login", htmlentitiesconv($currentUser->getLogin()));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.vuser_mail", htmlentitiesconv($currentUser->getMail()));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("ligne.vmailto", "mailto:".htmlentitiesconv($currentUser->getMail()));
	// 					var_dump($currentUser->getAccountActive());
						$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("ligne.url_account_active",formatUrl($this->getId(),"AdminUser","ChangeAccountActive","",$currentUser->getId()));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.vuser_account_active", ($currentUser->getAccountActive())?"toggle-on text-success":"toggle-off text-danger" );
						$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("ligne.vuser_id", "user".$currentUser->getId());
						
						/* Pour récuperer les libellés */
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.user_first_name", getMessage("user_first_name"));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.user_last_name", getMessage("user_last_name"));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.user_login", getMessage("user_login"));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.user_mail", getMessage("user_mail"));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.user_account_active", getMessage("user_account_active"));
						$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.TxtGroup", getMessage("TxtGroup"));

						/* Récupèration des groupes Utilisateurs*/
						$tabGroupUser=$GLOBALS["SYSTEM_MANAGER"]["GROUP_USER"]->getInstanceFromUserId($currentUser->getId());
						for ($j=0; $j<count($tabGroupUser); $j++)
						{
							if ( (in_array($tabGroupUser[$j]->getGroupId(), $tabId)) )
							{
								$Group=$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP"]->createInstance( $tabGroupUser[$j]->getGroupId());
								$tabWayTreeGroup = $Group->getFatherLibelleArray($currentCode);
								$lib=$tabWayTreeGroup[0];

								if ($lib==""){
									$tabWayTreeGroup = $Group->getFatherLibelleArray($defaultCode);
								}
								$treeGroup = "";
								for($n=(count($tabWayTreeGroup)-1);$n>=0;$n--){
									if($n>0)
										$treeGroup .= " / ".$tabWayTreeGroup[$n];
									else
										$treeGroup .= " / ".$tabWayTreeGroup[$n]."";
								}
								$lib = $treeGroup;
								$GLOBALS['SYSTEM_TEMPLATE']->MxText("ligne.GROUP_USER.GroupName", $lib);
								$GLOBALS['SYSTEM_TEMPLATE']->MxBloc("ligne.GROUP_USER", "loop");
							}
						}
						$GLOBALS["SYSTEM_TEMPLATE"]->MxBloc("ligne", "loop");
					}
					$GLOBALS["SYSTEM_TEMPLATE"]->MxText("nbUser", count($tabName));
				}
				else
				{
					$GLOBALS["SYSTEM_CONTROL"]->messageSystem = "NoCompteAssociated";
				}
			}
			return "";
		}
	}

/**
* Function permettant d'exporter les données d'un admin
* @access public
* @return chaine chaine vide
*/
function exportAdmin()
{
		
		/* Récupération du format sélectionné*/
		$exportFormat=( (isset($_POST["exportFormat"])) && ($_POST["exportFormat"]!="") )?$_POST["exportFormat"]:"html";

		/* Récupération du noeud à administrer sinon noeud d'entrà  de l'admin */
		$groupId=($this->getData("groupId")!="")?$this->getData("groupId"):1; 		/* Tous les Groupes par dà aut */
		$group_id=(isset($_POST["group_id"]) && is_numeric($_POST["group_id"]))?$_POST["group_id"]:$groupId;

		/* Creation du Tree d'admin */
		$myTreeGroup			=$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP"]->createInstance($group_id);
		/* Verification de l'existance du Tree */
		if ( !is_object($myTreeGroup) ){
			if ( $myTreeGroup->isLoaded()==false ){
				systemRedirect($urlReturn."&msg=WrongArgument");
				return "WrongArgument";
			}
		}
		// --> recuperation du treeNode correspondant au noeurd
		$tabTreeGroup[0]=$myTreeGroup;		//--> treeNodeUnique....

		//On récupère l'instance des noeuds et groupes temporaires
		$tabUser=$GLOBALS["SYSTEM_CONTROL"]->arrayOfAdministrableUserFromTabTreeGroup($tabTreeGroup);

		if(count($tabUser)>0)
		{
			/* Pour le Tri/Nom */
			$tabName=array();

			for ($i=0; $i<count($tabUser);$i++)
			{
				$lib=$tabUser[$i]->getFirstName();
				$tabName[$i]=$lib;
			}
			asort($tabName);
			reset($tabName);

			if(!is_file($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_coordination/".strtolower($GLOBALS["SYSTEM_CONTROL"]->className)."/".$exportFormat.".mxt"))
			{
				# Redirection vers le formulaire (avec le message)
				$GLOBALS["SYSTEM_CONTROL"]->messageSystem="msgError";
				return "";
			}

			$defaultCode=$GLOBALS["SYSTEM_DEFAULT_LANGUAGE_CODE"];

			switch($exportFormat){
				case "csv":
					header("Content-Type: application/csv-tab-delimited-table");
					header("Content-disposition: filename=".$this->getName($defaultCode).".csv");
					break;
				case "xml":
					header("Content-type: text/xml");
					break;
				case "rss2.0":
					header("Content-type: text/xml; charset=UTF-8");
				default:
			} // switch

			//On surcharge la template principale en fonction du format
			$GLOBALS["SYSTEM_TEMPLATE"] = new ModeliXeQware($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_coordination/".strtolower($GLOBALS["SYSTEM_CONTROL"]->className)."/".$exportFormat.".mxt");
			$GLOBALS["SYSTEM_TEMPLATE"]->SetModeliXe();

			if($GLOBALS["SYSTEM_TEMPLATE"]->isMxFlag("ObjectName","text"))
			$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ObjectName", $this->getName($defaultCode));

			while (list($i, $lib) = each($tabName))
			{
				//On récupère les données de l'utilisateur concerné				
				$currentUser=$tabUser[$i];

				$titre = array(getMessage("mr"),getMessage("mrs"), getMessage("miss"));
				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.vuser_title", $titre[$currentUser->getTitle()]);
				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.vuser_first_name", $currentUser->getFirstName());
				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.vuser_last_name", $currentUser->getLastName());
				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.vuser_login", utf8_encode($currentUser->getLogin()));
				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.vuser_mail", utf8_encode($currentUser->getMail()));
				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.vuser_organisation", utf8_encode($currentUser->getOrganisation()));

				$tabcom = $currentUser->getComment();
				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.vuser_comment", (isset($tabcom[0])?htmlentitiesconv($tabcom[0]):""));
				$GLOBALS["SYSTEM_TEMPLATE"]->MxText("ligne.vuser_city", utf8_encode(htmlentitiesconv($currentUser->getCity())));
				//On fait une bouclette à la template
				$GLOBALS["SYSTEM_TEMPLATE"]->MxBloc("ligne", "loop");
			}
		}
		return "";
	}

/**
* addUserAdmin affichage de la liste utilisateur
* @access public
* @return chaine code message
*/
	function addUserAdmin()
	{
		global $SERVER_NAME, $SCRIPT_NAME, $CONF_PERSISTANT_SECURE,$CONF_DATA_PATH;
		/* On inclus la template (voir package.template.php) */
		withBlocPath("AdminUser", "addUserAdmin");

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

		/* Creation des tabulations */
		$this->tabeCreate();

		/* Récupération du noeud à administrer sinon noeud d'entrée de l'admin */
		$groupId=($this->getData("groupId")!="")?$this->getData("groupId"):1; 		/* Tous les Groupes par dà aut */
		$group_id=(isset($_POST["group_id"]) && is_numeric($_POST["group_id"]))?$_POST["group_id"]:$groupId;

		/* Creation du Tree d'admin */
		$myTreeGroup			=$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP"]->createInstance($groupId);
		/* Verification de l'existance du Tree */
		if ( !is_object($myTreeGroup) ){
			if ( $myTreeGroup->isLoaded()==false ){
			systemRedirect(formatUrl($this->getId(),"AdminUser","actionAdmin","msgError"));
				return "WrongArgument";
			}
		}
		// --> recuperation du treeNode correspondant au noeurd
		$tabTreeGroup[0]=$myTreeGroup;		//--> treeNodeUnique....

		/* 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 */

		$MyUser = $GLOBALS["SYSTEM_MANAGER"]["USER"]->createNewInstance();
		$MyUser->setFirstName("");
		$MyUser->setLastName("");
		$MyUser->setLogin("");
		$MyUser->setPassword("");
		$MyUser->setMail("");

		/*MxSelect(string $path, string $name, string | array $selectedValue, array $Value, [string $defaultValue], [int $multipleSize], [string $javascriptAttribut]);*/
// 		$titre = array(getMessage("mr"),getMessage("mrs"), getMessage("miss"));
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxSelect("user_title", "user_title", $MyUser->getTitle(), $titre,"", "", "", "class=\"form\"");
// 
// 		/*MxFormField(string $path, string $type, $string name, string $value, [string $attribut]); */
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_first_name", "text", "user_first_name", $MyUser->getFirstName(), "class=\"form\"");
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_last_name", "text", "user_last_name", $MyUser->getLastName(), "class=\"form\"");
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_login", "text", "user_login", $MyUser->getLogin(), "class=\"form\"");
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_password", "password", "user_password", $MyUser->getPassword(), "class=\"form\"");
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_password2", "password", "user_password2", $MyUser->getPassword(), "class=\"form\"");
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_mail", "text", "user_mail", $MyUser->getMail(), "class=\"form\"");
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_birthdate", "text", "user_birthdate", $MyUser->getBirthDate(), "class=\"form\"");
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_code", "text", "user_postal_code", $MyUser->getPostalCode(), "class=\"form\"");
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_adress", "textarea", "user_postal_adress", $MyUser->getPostalAddress(), "class=\"form\"");
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_organisation", "text", "user_organisation", $MyUser->getOrganisation(), "class=\"form\"");
// 		$tabcom = $MyUser->getComment();
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_coment", "text", "user_coment", (isset($tabcom[0])?$tabcom[0]:""), "class=\"form\"");
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_city", "text", "user_city", $MyUser->getCity(), "class=\"form\"");
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_state", "text", "user_state", $MyUser->getState(), "class=\"form\"");
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_country", "text", "user_country", $MyUser->getCountry(), "class=\"form\"");
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_tel", "text", "user_tel", $MyUser->getTel(), "class=\"form\"");
// 		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_fax", "text", "user_fax", $MyUser->getFax(), "class=\"form\"");

		$titre = array(getMessage("mr"),getMessage("mrs"), getMessage("miss"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxSelect("user_title", "user_title", $MyUser->getTitle(), $titre, "", "", "", "class=\"form\" title=\"".htmlspecialchars(getMessage("tipSelectTitle"), ENT_QUOTES)."\"");
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_first_name", "text", "user_first_name", $MyUser->getFirstName(), "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", $MyUser->getLastName(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipLastName"), ENT_QUOTES)."\"", getMessage("user_last_name"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_login", "text", "user_login", $MyUser->getLogin(), "class=\"form\" disabled", getMessage("user_login"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_password", "password", "user_password", $MyUser->getPassword(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipPassword"), ENT_QUOTES)."\"", getMessage("user_password"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("re_user_password", "password", "re_user_password", $MyUser->getPassword(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipPassword2"), ENT_QUOTES)."\"", getMessage("user_password"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_mail", "text", "user_mail", $MyUser->getMail(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipCourriel"), ENT_QUOTES)."\"", getMessage("user_mail"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_birthdate", "text", "user_birthdate", $MyUser->getBirthDate(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipBirthDate"), ENT_QUOTES)."\"", getMessage("user_birthdate"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_code", "text", "user_postal_code", $MyUser->getPostalCode(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipPostalCode"), ENT_QUOTES)."\"", getMessage("user_postal_code"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_address", "text", "user_postal_address", $MyUser->getPostalAddress(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipPostalAddress"), ENT_QUOTES)."\"", getMessage("user_postal_address"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_organisation", "text", "user_organisation", $MyUser->getOrganisation(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipOrganisation"), ENT_QUOTES)."\"", getMessage("user_ogarnisation"));
		$tabcom = $MyUser->getComment();
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_comment", "text", "user_comment", (isset($tabcom[0])?$tabcom[0]:""), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipComment"), ENT_QUOTES)."\"", getMessage("user_comment"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_city", "text", "user_city", $MyUser->getCity(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipCity"), ENT_QUOTES)."\"", getMessage("user_city"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_state", "text", "user_state", $MyUser->getState(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipState"), ENT_QUOTES)."\"", getMessage("user_state"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_country", "text", "user_country", $MyUser->getCountry(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipCountry"), ENT_QUOTES)."\"", getMessage("user_country"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_tel", "text", "user_tel", $MyUser->getTel(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipTel"), ENT_QUOTES)."\"", getMessage("user_tel"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_fax", "text", "user_fax", $MyUser->getFax(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipFax"), ENT_QUOTES)."\"", getMessage("user_fax"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_website", "text", "user_website", $MyUser->getWebSite(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipWebsite"), ENT_QUOTES)."\"", getMessage("user_website"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_msn", "text", "user_msn", $MyUser->getMsn(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipMsn"), ENT_QUOTES)."\"", getMessage("user_msn"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_jabber", "text", "user_jabber", $MyUser->getJabber(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipJabber"), ENT_QUOTES)."\"", getMessage("user_jabber"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_facebook", "text", "user_facebook", $MyUser->getFacebook(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipFacebook"), ENT_QUOTES)."\"", getMessage("user_facebook"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_mastodon", "text", "user_mastodon", $MyUser->getMastodon(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipMastodon"), ENT_QUOTES)."\"", getMessage("user_mastodon"));

		$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("user_id", $MyUser->getId());

		# Récupération des étiquettes du formulaire
		$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("urlAction", formatUrl($this->getId(),"AdminUser","execAddUserAdmin",""));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxText("urlReturn", formatUrl($this->GetId(),"AdminUser","actionAdmin"));

		printTabTreeGroup($tabTreeGroup, $groupId, "GROUP");
		return "";
	}

/**
* Function permettant de modifier le compte sélectionnépar l'administrateur'
* @access public
* @return chaine code message
*/
	function execAddUserAdmin()
	{		
		global $SERVER_NAME, $SCRIPT_NAME, $CONF_PERSISTANT_SECURE, $CONF_DATA_PATH;

		/* Récupération du noeud à administrer sinon noeud d'entrà  de l'admin */
		$groupId=($this->getData("groupId")!="")?$this->getData("groupId"):1;
		$group_id=(isset($_POST["group_id"]) && is_numeric($_POST["group_id"]))?$_POST["group_id"]:$groupId;
		
		/* 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 */
		
		/* Creation du Tree d'admin */
		$myTreeGroup			=$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP"]->createInstance($groupId);
		/* Verification de l'existance du Tree */
		if ( !is_object($myTreeGroup) && ((!isset($_POST["group_id"]) && (!is_numeric($_POST["group_id"])))  )){
			if ( $myTreeGroup->isLoaded()==false ){
				systemRedirect(formatUrl($this->getId(),"AdminUser","actionAdmin","msgError").$location);
				return "WrongArgument";
			}
		}
		// --> recuperation du treeNode correspondant au noeurd
		$tabTreeGroup[0]=$myTreeGroup;		//--> treeNodeUnique....

		/*Récupération des messages utilisateurs*/
		addMessageFile("user.ini");
		//On vide la chaine de và ification 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" && $cle !="user_id" && $cle !="user_birthdate"))
				{
					$chaine .= getMessage($cle).", ";
				}
			}
			if($chaine!="")
			{
				//$chaine .= getMessage('obligatory');
				$chaine = "pouhaaaaaaa!";
			}
		}

		//Si certains champs sont manquants pour l'inscription
// 		if ($chaine != "")
// 		{
// 			$GLOBALS["SYSTEM_CONTROL"]->messageSystem = $chaine;
// 			/* On inclus la template (voir package.template.php) */
// 
// 			$this->addUserAdmin();
// 
// 			return "";
// 		}

		$MyUser = $GLOBALS["SYSTEM_MANAGER"]["USER"]->createNewInstance();
		# Teste si il y a des enregistrements sur la table des comptes
		$result=$GLOBALS['SYSTEM_MANAGER']['USER']->checkValid($_POST["user_login"], $_POST["user_password"]);

		if (($result != 0) && ($result !=$MyUser->getId()) )
		{
			$GLOBALS["SYSTEM_CONTROL"]->messageSystem = "user_exist";
			/* On inclus la template (voir package.template.php) */

			$this->addUserAdmin();

			return "";
		}
		else
		{
			//On enregistre les modifications de l'objet 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->setBirthDate($_POST['user_birthdate']);
			$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(array($_POST['user_comment']));

			//On enregistre les paramà res
			$ObjUsersave = $GLOBALS["SYSTEM_MANAGER"]["USER"]->saveInstance($MyUser);
		}
		$user_id	=$ObjUsersave->getId();

		/* Creation du Tree d'admin */
		$myTreeGroup	=$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP"]->createInstance($groupId);
		/* Verification de l'existance du Tree */
		if ( !is_object($myTreeGroup) ){
			if ( $myTreeGroup->isLoaded()==false ){
				return "WrongArgument";
			}
		}
		// --> recuperation du treeNode correspondant au noeurd
		$tabTreeGroup[0]=$myTreeGroup;		//--> treeNodeUnique....

		if ( (in_array( $group_id, $myTreeGroup->getSonArray() )) || ($group_id==$myTreeGroup->getId()) )
		{
			$groupUser= new GroupUser();
			$groupUser->setUserId($user_id);
			$groupUser->setGroupId($group_id);
			$groupUser=$GLOBALS["SYSTEM_MANAGER"]["GROUP_USER"]->insertInstance($groupUser);
			$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP_CACHE"]->emptyCache();
			$GLOBALS["SYSTEM_MANAGER"]["TREE_NODE_CACHE"]->emptyCache();
			$GLOBALS["SYSTEM_MANAGER"]["LIST_USER_GROUP_CACHE"]->emptyCache();
			$GLOBALS["SYSTEM_MANAGER"]["LIST_USER_NODE_CACHE"]->emptyCache();
			if( DATA_ACCES_CACHE_PERMISSION )
				$GLOBALS["SYSTEM_MANAGER"]["PERMISSION_CACHE"]->emptyCache();

			systemRedirect(formatUrl($this->getId(),"AdminUser","ChangeUserAdmin","msgSave",$user_id));
			return "";
		}else{
			systemRedirect(formatUrl($this->getId(),"AdminUser","actionAdmin","selectcheckbox"));
			return "";
		}
	}

/**
* changeUserAdmin affichage de la liste utilisateur
* @access public
* @return chaine code message
*/
	function ChangeUserAdmin()
	{
		global $SERVER_NAME, $SCRIPT_NAME, $CONF_PERSISTANT_SECURE,$CONF_DATA_PATH;

		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 */
		
		mxPageTitle("actionAdminTitlePage");
		
		$arrayCallCss = array();
        $arrayCallCss[] = "data/css/bootstrap-datepicker/1.9.0/bootstrap-datepicker3.min.css";
        $arrayCallCss[] = "data/css/bootstrap-toggle/2.2.2/bootstrap-toggle.min.css";
		$arrayCallCss[] = "data/css/dataTables.bootstrap4/1.10.22/dataTables.bootstrap4.min.css";
        mxCallCss($arrayCallCss);
        
		$arrayCallJs = array();
		$arrayCallJs[] = "data/javascript/bootstrap-datepicker/1.9.0/bootstrap-datepicker.min.js";
        $arrayCallJs[] = "data/javascript/bootstrap-datepicker/1.9.0/locales/bootstrap-datepicker.".$currentCode.".min.js";
        $arrayCallJs[] = "data/javascript/bootstrap-toggle/2.2.2/bootstrap-toggle.min.js";
		$arrayCallJs[] = "data/javascript/jquery.dataTables/1.10.22/jquery.dataTables.min.js";
		$arrayCallJs[] = "data/javascript/dataTables.bootstrap4/1.10.22/dataTables.bootstrap4.min.js";
        mxCallJs($arrayCallJs);

        $arrayRawJs[] = "\$(document).ready(function(){\$(\"#tabListGroups\").dataTable({\"bPaginate\": false,\"bFilter\": false,\"bInfo\": false,\"bAutoWidth\": false,\"bLengthChange\": false,\"aaSorting\": [[ 0, \"asc\" ]]});});";
		mxRawJs($arrayRawJs);
        
        /* On inclus la template (voir package.template.php) */
		withBlocPath("AdminUser", "ChangeUserAdmin");

		/* Inclusion du package */
// 		includePackage("pagingmanager.php");
        
		/* Creation des tabulations */
		$this->tabeCreate();

		/* Récupération du noeud à administrer sinon noeud d'entrà  de l'admin */
		$groupId=($this->getData("groupId")!="")?$this->getData("groupId"):1; 		/* Tous les Groupes par dà aut */
		$group_id=(isset($_POST["group_id"]) && is_numeric($_POST["group_id"]))?$_POST["group_id"]:$groupId;

		if((isset($_GET["param"])) && (is_numeric($_GET["param"])))
		{
			$param=$_GET["param"];
		}
		else
		{
			# Redirection vers le formulaire
			systemRedirect(formatUrl($this->getId(),"AdminUser","actionAdmin","msgError"));
			return "msgError";
		}
		
		/* creation de la gestion de tranche */
// 		$PagingManager = new PagingManager(0);
// 		$localisation = $PagingManager->getCurrentLocalisation();
		
		/* Creation du Tree d'admin */
		$myTreeGroup			=$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP"]->createInstance($groupId);
		/* Verification de l'existance du Tree */
		if ( !is_object($myTreeGroup) ){
			if ( $myTreeGroup->isLoaded()==false ){
			systemRedirect(formatUrl($this->getId(),"AdminUser","actionAdmin","msgError"));
				return "WrongArgument";
			}
		}
		// --> recuperation du treeNode correspondant au noeurd
		$tabTreeGroup[0]=$myTreeGroup;		//--> treeNodeUnique....

		$MyUser = $GLOBALS["SYSTEM_MANAGER"]["USER"]->createInstance($param);

		$GLOBALS["SYSTEM_TEMPLATE"]->MxText("accountState", ($MyUser->getAccountActive())?" checked=\"checked\"":"");
		
		$titre = array(getMessage("mr"),getMessage("mrs"), getMessage("miss"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxSelect("user_title", "user_title", $MyUser->getTitle(), $titre, "", "", "", "class=\"form\" title=\"".htmlspecialchars(getMessage("tipSelectTitle"), ENT_QUOTES)."\"");
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_first_name", "text", "user_first_name", $MyUser->getFirstName(), "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", $MyUser->getLastName(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipLastName"), ENT_QUOTES)."\"", getMessage("user_last_name"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_login", "text", "user_login", $MyUser->getLogin(), "class=\"form\" disabled", getMessage("user_login"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_password", "password", "user_password", $MyUser->getPassword(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipPassword"), ENT_QUOTES)."\"", getMessage("user_password"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("re_user_password", "password", "re_user_password", $MyUser->getPassword(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipPassword2"), ENT_QUOTES)."\"", getMessage("user_password"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_mail", "text", "user_mail", $MyUser->getMail(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipCourriel"), ENT_QUOTES)."\"", getMessage("user_mail"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_birthdate", "text", "user_birthdate", $MyUser->getBirthDate(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipBirthDate"), ENT_QUOTES)."\"", getMessage("user_birthdate"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_code", "text", "user_postal_code", $MyUser->getPostalCode(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipPostalCode"), ENT_QUOTES)."\"", getMessage("user_postal_code"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_address", "text", "user_postal_address", $MyUser->getPostalAddress(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipPostalAddress"), ENT_QUOTES)."\"", getMessage("user_postal_address"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_organisation", "text", "user_organisation", $MyUser->getOrganisation(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipOrganisation"), ENT_QUOTES)."\"", getMessage("user_ogarnisation"));
		$tabcom = $MyUser->getComment();
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_comment", "text", "user_comment", (isset($tabcom[0])?$tabcom[0]:""), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipComment"), ENT_QUOTES)."\"", getMessage("user_comment"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_city", "text", "user_city", $MyUser->getCity(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipCity"), ENT_QUOTES)."\"", getMessage("user_city"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_state", "text", "user_state", $MyUser->getState(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipState"), ENT_QUOTES)."\"", getMessage("user_state"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_country", "text", "user_country", $MyUser->getCountry(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipCountry"), ENT_QUOTES)."\"", getMessage("user_country"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_tel", "text", "user_tel", $MyUser->getTel(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipTel"), ENT_QUOTES)."\"", getMessage("user_tel"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_fax", "text", "user_fax", $MyUser->getFax(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipFax"), ENT_QUOTES)."\"", getMessage("user_fax"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_website", "text", "user_website", $MyUser->getWebSite(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipWebsite"), ENT_QUOTES)."\"", getMessage("user_website"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_msn", "text", "user_msn", $MyUser->getMsn(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipMsn"), ENT_QUOTES)."\"", getMessage("user_msn"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_jabber", "text", "user_jabber", $MyUser->getJabber(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipJabber"), ENT_QUOTES)."\"", getMessage("user_jabber"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_facebook", "text", "user_facebook", $MyUser->getFacebook(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipFacebook"), ENT_QUOTES)."\"", getMessage("user_facebook"));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_mastodon", "text", "user_mastodon", $MyUser->getMastodon(), "class=\"form\" title=\"".htmlspecialchars(getMessage("tipMastodon"), ENT_QUOTES)."\"", getMessage("user_mastodon"));
		
		$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("user_id", $MyUser->getId());				
		
		# Récupération des étiquettes du formulaire
		$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("urlAction", formatUrl($this->getId(),"AdminUser","execChangeUserAdmin","",$param));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("urlAddAction", formatUrl($this->getId(),"AdminUser","execAddGroupUserAdmin","",$param));
		$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("urlReturn", formatUrl($this->GetId(),"AdminUser","actionAdmin"));
		printTabTreeGroup($tabTreeGroup, $groupId, "GROUP");

		/* recuperation des id administrables */
		$tabId[0]=$groupId;
		$tabId=array_merge($tabId, $myTreeGroup->getSonArray());

		$tabGroupUser=$GLOBALS["SYSTEM_MANAGER"]["GROUP_USER"]->getInstanceFromUserId($param);
		for ($j=0; $j<count($tabGroupUser); $j++)
		{
			if ( (in_array($tabGroupUser[$j]->getGroupId(), $tabId)) )
			{
				$Group=$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP"]->createInstance( $tabGroupUser[$j]->getGroupId());
				$tabWayTreeGroup = $Group->getFatherLibelleArray($currentCode);
				$lib=$tabWayTreeGroup[0];

				if ($lib=="")
				{
					$tabWayTreeGroup = $Group->getFatherLibelleArray($defaultCode);
				}

				$treeGroup = "";
				for($n=(count($tabWayTreeGroup)-1);$n>=0;$n--)
				{
					if($n>0)
					{
					$treeGroup .= "/ ".$tabWayTreeGroup[$n];
					}
					else
					{
					$treeGroup .= "/ <b>".$tabWayTreeGroup[$n]."</b>";
					}
				}
				$lib = $treeGroup;
				$GLOBALS['SYSTEM_TEMPLATE']->MxText("GROUP_USER.GroupName", $lib);
				$GLOBALS['SYSTEM_TEMPLATE']->MxAttribut("GROUP_USER.GROUP_DELETE.urlDelete", formatUrl($this->getId(), "AdminUser", "deleteGroupUserAdmin")."&amp;groupUserId=".$tabGroupUser[$j]->getId() );
				$GLOBALS['SYSTEM_TEMPLATE']->MxText("GROUP_USER.GROUP_DELETE.BtnDelete", getMessage("BtnDelete") );
				$GLOBALS['SYSTEM_TEMPLATE']->MxText("GROUP_USER.GROUP_DELETE.imgPath", $GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']);
				$GLOBALS['SYSTEM_TEMPLATE']->MxBloc("GROUP_USER", "loop");
			}
		}

		if (count($tabGroupUser)==0)
		{
				$GLOBALS['SYSTEM_TEMPLATE']->MxBloc("GROUP_USER", "delete");
		}
		/* Sortie de la Template */
		ExitBloc();
		return "";
	}

/**
* Function permettant de modifier le compte sélectionnépar l'administrateur(traitement)
* @access public
* @return chaine code message
*/
	function execChangeUserAdmin()
	{
		/* Inclusion du package */
// 		includePackage("pagingmanager.php");
		
		global $SERVER_NAME, $SCRIPT_NAME, $CONF_PERSISTANT_SECURE,$CONF_DATA_PATH;
		
		/* Récupération du noeud à administrer sinon noeud d'entrée de l'admin */
		$groupId=($this->getData("groupId")!="")?$this->getData("groupId"):1;
		$group_id=(isset($_POST["group_id"]) && is_numeric($_POST["group_id"]))?$_POST["group_id"]:$groupId;

		/* 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 */
		
// 		$PagingManager = new PagingManager(0);
// 		$localisation = $PagingManager->getCurrentLocalisation();
		
		/* Creation du Tree d'admin */
		$myTreeGroup			=$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP"]->createInstance($groupId);
		/* Verification de l'existance du Tree */
		if ( !is_object($myTreeGroup) ){
			if ( $myTreeGroup->isLoaded()==false ){
				systemRedirect(formatUrl($this->getId(),"AdminUser","actionAdmin","msgError").$localisation);
				return "WrongArgument";
			}
		}
		// --> recuperation du treeNode correspondant au noeud
		$tabTreeGroup[0]=$myTreeGroup;		//--> treeNodeUnique....

		/*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" && $cle !="user_id" && $cle !="user_birthdate"))
				{
					$chaine .= getMessage($cle).", ";
				}
			}
			if($chaine!="")
			{
			$chaine .= getMessage('obligatory');
			}
		}

		//Si certains champs sont manquants pour l'inscription
		if ($chaine != "")
		{
			$GLOBALS["SYSTEM_CONTROL"]->messageSystem = $chaine;
			/* On inclus la template (voir package.template.php) */
			withBlocPath("AdminUser", "ChangeUserAdmin");
			$this->ChangeUserAdmin();
			ExitBloc();
			return "";
		}

		if((!isset($_GET["param"])) && (!is_numeric($_GET["param"])))
		{
			$GLOBALS["SYSTEM_CONTROL"]->messageSystem = "msgError";
			/* On inclus la template (voir package.template.php) */
			withBlocPath("AdminUser", "actionAdmin");
			$this->actionAdmin();
			ExitBloc();
			return "";
		}
		else
		{
			$MyUser = $GLOBALS["SYSTEM_MANAGER"]["USER"]->createInstance($_GET["param"]);
			# Teste si il y a des enregistrements sur la table des comptes
			$result=$GLOBALS['SYSTEM_MANAGER']['USER']->checkValid($_POST["user_login"], $_POST["user_password"]);

			if (($result != 0) && ($result !=$MyUser->getId()) )
			{
				$GLOBALS["SYSTEM_CONTROL"]->messageSystem = "user_exist";
				/* On inclus la template (voir package.template.php) */
				withBlocPath("AdminUser", "ChangeUserAdmin");
				$this->ChangeUserAdmin();
				ExitBloc();
				return "";
			}
			else
			{
                $d = DateTime::createFromFormat('d/m/Y', $_POST['user_birthdate']);
				//On enregistre les modifications de l'objet 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->setBirthDate($d->getTimestamp());
				$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(array($_POST['user_comment']));

				//On enregistre les paramètres
				$ObjUsersave = $GLOBALS["SYSTEM_MANAGER"]["USER"]->saveInstance($MyUser);

				# Redirection vers le formulaire
				systemRedirect(formatUrl($this->getId(),"AdminUser","actionAdmin","datamodified").$localisation);
			}
		}
		return "";
	}

	/**
	* Méthode de l'outil News permettant d'obtenir le News pour une communauté
	*
	* @access public
	*/
	private function getAjaxUsers()
	{
//         var_dump($_GET);
		//--- Dépendances ---
		//--- Fichier de messages de l'outil
		addMessageFile("adminuser.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 défaut */

		// chemin du fichier de template
		$GLOBALS["SYSTEM_TEMPLATE"] = new ModeliXeQware($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_coordination/adminnews/ajaxdata.mxt");
		$GLOBALS["SYSTEM_TEMPLATE"]->SetMxFileParameter($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR'].$GLOBALS['SYSTEM_TEMPLATE_CONF']);
		$GLOBALS["SYSTEM_TEMPLATE"]->SetModeliXe(true);
		
		$aColumns = array( 'news_id', 'news_comm', 'news_timestamp', 'news_type', 'news_icon', 'news_title_fr', 'news_title_gb' );
		$sIndexColumn = "news_id";
		$sTable = DATA_ACCES_TABLE_PREFIX.DATA_ACCES_OBJECT_PREFIX."comendatorenews";
		
		/* 
		* Paging
		*/
		$sLimit = "";
		if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
		{
			$sLimit = "LIMIT ".$_GET['iDisplayStart'].", ".$_GET['iDisplayLength'];
		}
		/*
		* Ordering
		*/
		if ( isset( $_GET['iSortCol_0'] ) )
		{
			$sOrder = "ORDER BY  ";
			for ( $i=0 ; $i<intval( $_GET['iSortingCols'] ) ; $i++ )
			{
				if ( $_GET[ 'bSortable_'.intval($_GET['iSortCol_'.$i]) ] == "true" )
				{
					$sOrder .= $aColumns[ intval( $_GET['iSortCol_'.$i] ) ]."
						".$_GET['sSortDir_'.$i].", ";
				}
			}
			
			$sOrder = substr_replace( $sOrder, "", -2 );
			if ( $sOrder == "ORDER BY" )
			{
				$sOrder = "";
			}
		} else {
			$sOrder = "";
		}
		/* 
		* Filtering
		* NOTE this does not match the built-in DataTables filtering which does it
		* word by word on any field. It's possible to do here, but concerned about efficiency
		* on very large tables, and MySQL's regex functionality is very limited
		*/
		$sWhere = "";
		if ( isset( $_GET['sSearch'] ) && $_GET['sSearch'] != "" )
		{
			$sWhere = "WHERE (";
			for ( $i=0 ; $i<count($aColumns) ; $i++ )
			{
				$sWhere .= $aColumns[$i]." LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ";
			}
			$sWhere = substr_replace( $sWhere, "", -3 );
			$sWhere .= ')';
		}
		
		/* Individual column filtering */
		for ( $i=0 ; $i<count($aColumns) ; $i++ )
		{
			if ( isset( $_GET['bSearchable_'.$i] ) && $_GET['bSearchable_'.$i] == "true" && $_GET['sSearch_'.$i] != '' )
			{
				if ( $sWhere == "" )
				{
					$sWhere = "WHERE ";
				}
				else
				{
					$sWhere .= " AND ";
				}
				$sWhere .= $aColumns[$i]." LIKE '%".mysql_real_escape_string($_GET['sSearch_'.$i])."%' ";
			}
		}

		if(is_numeric($this->communityID)){
			includeDep("adminnews/adminnewsmanager.php");
			$newsManager = new AdminNewsManager();
			echo json_encode( $newsManager->getAllNewsByComId($sTable, $this->communityID, $this->communityLib, $aColumns, $sIndexColumn, $sWhere, $sOrder, $sLimit, $currentCode, $this->getId()) );
		}
	}
	
/**
* Function permettant de supprimer le compte sélectionné par l'administrateur'
* @access public
* @return chaine chaine vide
*/
	function deleteGroupUserAdmin()
	{
		/* On inclus la template (voir package.template.php) */
		withBlocPath("AdminUser", "deletegroupuseradmin");
		
		/* Inclusion du package */
// 		includePackage("pagingmanager.php");
		
		/*Récupération des messages utilisateurs*/
		addMessageFile("user.ini");

		$this->tabeCreate();
// 		$PagingManager = new PagingManager(0);
// 		$localisation = $PagingManager->getCurrentLocalisation();
		$groupId	=($this->getData("groupId")!="")?$this->getData("groupId"):1;
		$groupUserId	=(isset($_GET["groupUserId"]) && is_numeric($_GET["groupUserId"]))?$_GET["groupUserId"]:0;

		if ($groupUserId==0)
		{
			systemRedirect(formatUrl($this->getId(),"AdminUser","actionAdmin","WrongArgument").$localisation);
			return "";
		}

		$GroupUser=$GLOBALS["SYSTEM_MANAGER"]["GROUP_USER"]->createInstance($groupUserId);
		$MyTreeGroup=$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP"]->createInstance($groupId);

		/* 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 étiquettes du formulaire
		$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("urlAction", formatUrl($this->getId(),"AdminUser","execdeleteGroupUserAdmin","")."&amp;groupUserId=".$groupUserId.$localisation);
		$GLOBALS["SYSTEM_TEMPLATE"]->MxAttribut("urlReturn", formatUrl($this->getId(),"AdminUser","actionAdmin","").$localisation);

		if ( (in_array($GroupUser->getGroupId(), $MyTreeGroup->getSonArray())) || ($GroupUser->getGroupId()==$groupId) )
		{
			$Group=$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP"]->createInstance( $GroupUser->getGroupId());
			$tabWayTreeGroup = $Group->getFatherLibelleArray($currentCode);
			$lib=$tabWayTreeGroup[0];

			if ($lib=="")
			{
				$tabWayTreeGroup = $Group->getFatherLibelleArray($defaultCode);
			}

			$treeGroup = "";
			for($n=(count($tabWayTreeGroup)-2);$n>=0;$n--)
			{
				if($n>0)
				{
				$treeGroup .= "/ ".$tabWayTreeGroup[$n];
				}
				else
				{
				$treeGroup .= "/ <b>".$tabWayTreeGroup[$n]."</b>";
				}
			}
			$lib = $treeGroup;
			$GLOBALS['SYSTEM_TEMPLATE']->MxText("GroupName", $lib);
			$User=$GLOBALS["SYSTEM_MANAGER"]["USER"]->createInstance( $GroupUser->getUserId() );
			$GLOBALS['SYSTEM_TEMPLATE']->MxText("FirstName", $User->getFirstName() );
			$GLOBALS['SYSTEM_TEMPLATE']->MxText("LastName", $User->getLastName() );

			return "";
		}else{
			systemRedirect(formatUrl($this->getId(),"AdminUser","actionAdmin","wrongArgument").$localisation);
			return "";
		}
		ExitBloc();
	}

/**
* Function permettant de supprimer le compte sélectionné par l'administrateur(traitement)
* @access public
* @return chaine chaine vide
*/

	function execDeleteGroupUserAdmin()
	{
		$groupId	=($this->getData("groupId")!="")?$this->getData("groupId"):1;
		$groupUserId	=(isset($_GET["groupUserId"]) && is_numeric($_GET["groupUserId"]))?$_GET["groupUserId"]:0;
		
		/* Inclusion du package */
// 		includePackage("pagingmanager.php");
		
// 		$PagingManager = new PagingManager(0);		
// 		$localisation = $PagingManager->getCurrentLocalisation();
		if ($groupUserId==0)
		{
			systemRedirect(formatUrl($this->getId(),"AdminUser","actionAdmin","wrongArgument").$localisation);
			return "";
		}

		$GroupUser=$GLOBALS["SYSTEM_MANAGER"]["GROUP_USER"]->createInstance($groupUserId);
		$MyTreeGroup=$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP"]->createInstance($groupId);

		if ( (in_array($GroupUser->getGroupId(), $MyTreeGroup->getSonArray())) || ($GroupUser->getGroupId()==$groupId) )
		{
			$verif_delete = false;
			/* Selection de tous les groupes utilisateurs */
			$tabGroupUser=$GLOBALS["SYSTEM_MANAGER"]["GROUP_USER"]->getInstanceFromUserId( $GroupUser->getUserId() );
			$user_id = $GroupUser->getUserId();

			/* Suppression du groupe/Utilisateur */
			$GroupUser=$GLOBALS["SYSTEM_MANAGER"]["GROUP_USER"]->deleteInstance($GroupUser);

			if (count($tabGroupUser)==1)
			{
				/* cas un seul group... on supprime l'utilisateur et ses droits */
				$tabRight=$GLOBALS["SYSTEM_MANAGER"]["RIGHT"]->getInstanceFromUserId( $GroupUser->getUserId(), array() );		/* Droits seulement pour l'utilisateur */
				#--> suppression des droits
				for ($i=0;$i<count($tabRight);$i++)
				{
					$tabRight[$i]=$GLOBALS["SYSTEM_MANAGER"]["RIGHT"]->deleteInstance( $tabRight[$i] );
					/* Droits seulement pour l'utilisateur */
				}

				#--> on supprime l'utilisateur
				$User=$GLOBALS["SYSTEM_MANAGER"]["USER"]->createInstance( $GroupUser->getUserId() );
				$User=$GLOBALS["SYSTEM_MANAGER"]["USER"]->deleteInstance( $User );
				$verif_delete = true;
			}

			$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP_CACHE"]->emptyCache();
			$GLOBALS["SYSTEM_MANAGER"]["TREE_NODE_CACHE"]->emptyCache();
			$GLOBALS["SYSTEM_MANAGER"]["LIST_USER_GROUP_CACHE"]->emptyCache();
			$GLOBALS["SYSTEM_MANAGER"]["LIST_USER_NODE_CACHE"]->emptyCache();
			$GLOBALS["SYSTEM_MANAGER"]["PERMISSION_CACHE"]->emptyCache();
			
			if (!$verif_delete)
			{
			systemRedirect(formatUrl($this->getId(),"AdminUser","ChangeUserAdmin","msgDelete",$user_id).$localisation);
			}
			else
			{
			systemRedirect(formatUrl($this->getId(),"AdminUser","actionAdmin","msgDelete").$localisation);
			}
			return "";
		}else{
			systemRedirect(formatUrl($this->getId(),"AdminUser","actionAdmin","wrongArgument").$localisation);
			return "";
		}
		ExitBloc();
	}

/**
* Function permettant d'ajouter un compte par l'administrateur(traitement)
* @access public
* @return chaine code message
*/
	function execAddGroupUserAdmin()
	{
		/* Inclusion du package */
// 		includePackage("pagingmanager.php");
		
		/* Récupération du noeud à administrer sinon noeud d'entrée  de l'admin */
		$groupId	=($this->getData("groupId")!="")?$this->getData("groupId"):1;
		$group_id	=(isset($_POST["group_id"]) && is_numeric($_POST["group_id"]))?$_POST["group_id"]:$groupId;
		$user_id	=(isset($_POST["user_id"]) && is_numeric($_POST["user_id"]))?$_POST["user_id"]:0;

		/* Creation du Tree d'admin */
		$myTreeGroup	=$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP"]->createInstance($groupId);
		/* Verification de l'existance du Tree */
		if ( !is_object($myTreeGroup) ){
			if ( $myTreeGroup->isLoaded()==false ){
				return "WrongArgument";
			}
		}
		// --> recuperation du treeNode correspondant au noeurd
		$tabTreeGroup[0]=$myTreeGroup;		//--> treeNodeUnique....
// 		$PagingManager = new PagingManager(0);		
// 		$localisation = $PagingManager->getCurrentLocalisation();
				
		if ( (in_array( $group_id, $myTreeGroup->getSonArray() )) || ($group_id==$myTreeGroup->getId()) )
		{
			$groupUser= new GroupUser();
			$groupUser->setUserId($user_id);
			$groupUser->setGroupId($group_id);
			$groupUser=$GLOBALS["SYSTEM_MANAGER"]["GROUP_USER"]->insertInstance($groupUser);
			$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP_CACHE"]->emptyCache();
			$GLOBALS["SYSTEM_MANAGER"]["TREE_NODE_CACHE"]->emptyCache();
			$GLOBALS["SYSTEM_MANAGER"]["LIST_USER_GROUP_CACHE"]->emptyCache();
			$GLOBALS["SYSTEM_MANAGER"]["LIST_USER_NODE_CACHE"]->emptyCache();
			$GLOBALS["SYSTEM_MANAGER"]["PERMISSION_CACHE"]->emptyCache();
			systemRedirect(formatUrl($this->getId(),"AdminUser","ChangeUserAdmin","msgSave",$user_id).$localisation);
			return "";
		}else{
			systemRedirect(formatUrl($this->getId(),"AdminUser","actionAdmin","selectcheckbox").$localisation);
			return "";
		}
	}

#######################################################################################################################################
### Parametrage de l'instance!!!
#######################################################################################################################################
#### On surcharge
###### ici les methodes de CoordinationObj pour avoir un form permettant de saisir la racine de fonctionnement de l'objet
/**
* Surcharge des methodes de la classe CoordinationObjet
* @param chaine url pour le form
* @param chaine url pour le form de retour
* @param entier groupe de configuration...
* @param entier noeud de configuration endroit ou l'objet a à à crà 
* @param tableau
* @access public
* @return chaine code Message
*/
	function configurePrint($url, $urlReturn, $groupIdPass, $nodeIdPass, $tabForbiddenPass)
	{
		addMessageFile("object.ini");

		$end=parent::configurePrint($url, $urlReturn, $groupIdPass, $nodeIdPass, $tabForbiddenPass);

		// On affiche en plus la liste des noeuds et des groupes paramétrables
		/* Récupération du noeud à administrer sinon noeud d'entrée de l'admin */
		$tabForbidden=(is_array($this->getData("tabForbidden")))?$this->getData("tabForbidden"):array();
		$groupId=($this->getData("groupId")!="")?$this->getData("groupId"):1; 		/* Tous les Groupes par dà aut */

		// --> recuperation du treeNode correspondant au noeud
		/* Creation du Tree d'admin */
		$myTreeGroup			=$GLOBALS["SYSTEM_MANAGER"]["TREE_GROUP"]->createInstance($groupIdPass);
		/* Verification de l'existance du Tree */
		if ( !is_object($myTreeGroup) ){
			if ( $myTreeGroup->isLoaded()==false ){
				systemRedirect($urlReturn."&msg=WrongArgument");
				return "WrongArgument";
			}
		}
		// --> recuperation du treeNode correspondant au noeud

		$tabTreeGroup[0]=$myTreeGroup;		//--> treeNodeUnique....
		printTabTreeGroup($tabTreeGroup, $groupId, "GROUP_ADMIN", "group_admin_id");
		/* -- Fin Affichage des groupes d'ajout */
		return $end;
	}

/**
* __createObject : retourne la chaine d'affichage de création de l'objet (/défaut)
* @param chaine url pour le form
* @param chaine url pour le form de retour
* @param entier groupe de configuration...
* @param entier noeud de configuration endroit ou l'objet a été créé 
* @param tableau
* @access public
* @return chaine code Message
*/
	function __createObject($url, $urlReturn, $groupIdPass, $nodeIdPass, $tabForbiddenPass)
	{
		withBlocPath("AdminUser", "configuration");
		$end=$this->configurePrint($url, $urlReturn, $groupIdPass, $nodeIdPass, $tabForbiddenPass);
		ExitBloc();
		return $end;
	}

/**
* __ExecCreateObject : retourne la chaine d'affichage de création de l'objet (/traitement)
* @param entier groupe de configuration...
* @param entier noeud de configuration endroit ou l'objet a été créé
* @param tableau
* @access public
* @return chaine code Message
*/
	function __execCreateObject($groupIdPass, $nodeIdPass, $tabForbiddenPass)
	{
		if (isset($_POST["group_admin_id"]))
			$this->setData("groupId", $_POST["group_admin_id"]);
		else
			$this->setData("groupId", nid());

		$end=parent::__execCreateObject($groupIdPass, $nodeIdPass, $tabForbiddenPass);
		return $end;
	}

/**
* __ExecUpdateObject : retourne la chaine d'affichage de modification de l'objet (/traitement)
* @param entier groupe de configuration...
* @param entier noeud de configuration endroit ou l'objet a été créé
* @param tableau
* @access public
* @return chaine code Message
*/
	function __execUpdateObject($groupIdPass, $nodeIdPass, $tabForbiddenPass)
	{
		if (isset($_POST["group_admin_id"]))
			$this->setData("groupId", $_POST["group_admin_id"]);
		else
			$this->setData("groupId", 1);

		$end=parent::__execUpdateObject($groupIdPass, $nodeIdPass, $tabForbiddenPass);
		return $end;
	}

/**
* __updateObject : surchage updateObject de l'objet de coordination
* @param chaine url pour le form
* @param chaine url pour le form de retour
* @param entier groupe de configuration...
* @param entier noeud de configuration endroit ou l'objet a été créé
* @param tableau
* @access public
* @return chaine code Message
*/
	function __updateObject($url, $urlReturn, $groupIdPass, $nodeIdPass, $tabForbiddenPass)
	{
		withBlocPath("AdminUser", "configuration");
		$end=$this->configurePrint($url, $urlReturn, $groupIdPass, $nodeIdPass, $tabForbiddenPass);
		ExitBloc();
		return $end;
	}
}
?>
