<?php

/*************************************************************************/
/* SPAGHETTILEARNING - E-Learning System                                 */
/* ============================================                          */
/*                                                                       */
/* Copyright (c) 2002 by Claudio Erba (webmaster@spaghettilearning.com)  */
/* & Fabio Pirovano (gishell@tiscali.it) http://www.spaghettilearning.com*/
/*                                                                       */
/* This program is free software. You can redistribute it and/or modify  */
/* it under the terms of the GNU General Public License as published by  */
/* the Free Software Foundation; either version 2 of the License.        */
/*************************************************************************/

if(isset($_SESSION['sesCmsAdmUser']) && isset($_SESSION['sesCmsAdmLevel'])) {

function user() {
	//access control
	global $prefixCms, $prefix, $visuUserAtTime;
	funAdminAccess('OP');
	addTitleArea('user');
	include('admin/modules/group/groupUtils.php');
	include('core/class/class.typeone.php');

	if (isset($_GET['startPos'])) $ini = $_GET['startPos'];
	else $ini = 0;
	//prev and next
	if(isset($_POST['idGroup'])) $idGSel = $_POST['idGroup'];
	if(isset($_POST['searchField'])) $searchSel = $_POST['searchField'];
	if(isset($_GET['idGroup'])) $idGSel = $_GET['idGroup'];
	if(isset($_GET['searchField'])) $searchSel = base64_decode($_GET['searchField']);

	//if a group is selected
	if($idGSel) {
		//search query
		$textQuery = "
		SELECT t1.idUser, t1.userid
		FROM ".$prefix."_user AS t1,
			".$prefixCms."_groupuser AS t2
		WHERE t1.idUser = t2.idUser AND t2.idGroup = '$idGSel'";
	}
	else {
		$textQuery = "
		SELECT t1.idUser, t1.userid
		FROM ".$prefix."_user AS t1
		WHERE 1";
	}

	if($searchSel != "") $textQuery .= " AND t1.userid LIKE '%$searchSel%'";

	$textQuery .= " AND t1.valid = '1'";
	//limit result
	$textQuery .= " ORDER BY t1.userid LIMIT $ini,".($ini + $visuUserAtTime + 1);

	//do query
	$result = mysql_query($textQuery);

	//finding avvailable group
	$groups = listGroup();

	//visualize result
	echo '<div class="stdBlock">';

	echo '<form method="post" action="admin.php?modulename=user&amp;op=user">'
		.'<div class="internalBlock">'

		.'<label for="group">'._ONLYTHISGROUP.'</label>'
			.'<select id="group" name="idGroup">'
				.'<option value="">'._ALL.'</option>';

				while(list($idCommon, $nameGroup) = each($groups)) {
					echo '<option value="'.$idCommon.'"';
					if($idCommon == $idGSel) echo ' selected="selected"';
					echo '>'.$nameGroup.'</option>';
				}
			echo '</select><br />'

		.'<label for="fieldSearch">'._SEARCHFIELD.'</label>'
			.'<input type="text" id="fieldSearch" name="searchField" value="'.$searchSel.'" maxlength="100" /><br />'

		.'<label>'
			.'<input class="button" type="submit" value="'._SEARCH.'" /></label>'

		.'</div>'
		.'</form>';

	$tableUser = new typeOne($visuUserAtTime);

	$tableUser->OpenTable(_LISTOPTION);

	$tableUser->WriteHeader(
		array(_USERID,
		'<img src="'.getPathImage().'standard/man.gif" alt="'._GROUPMAN.'" title="'._GROUPMANG.'">',
			'<img src="'.getPathImage().'standard/mod.gif" alt="'._MODIFY.'" title="'._MODIFYG.'" />',
			'<img src="'.getPathImage().'standard/rem.gif" alt="'._REMOVE.'" title="'._REMOVEG.'" />'),
		array('', 'img', 'img', 'img'));

	$i = 0;
	if(mysql_num_rows($result) == "0") echo '<b>'._NORESULT.'</b>';
	while((list($idUser, $userid) = mysql_fetch_row($result))&&(++$i <= $visuUserAtTime)) {

		//write line
		$tableUser->WriteRow(
			array($userid,
				'<a href="admin.php?modulename=user&amp;op=groupassociateuser&amp;idUser='.$idUser.'">
					<img src="'.getPathImage().'standard/man.gif" alt="'._GROUPMAN.'" /></a>',
				'<a href="admin.php?modulename=user&amp;op=newinfouser&amp;idUser='.$idUser.'">
					<img src="'.getPathImage().'standard/mod.gif" alt="'._MODIFY.'" /></a>',
				'<a href="admin.php?modulename=user&amp;op=remuser&amp;idUser='.$idUser.'">
					<img src="'.getPathImage().'standard/rem.gif" alt="'._REMOVE.'" /></a>'));
	}
	$tableUser->WriteAddRow('<a href="admin.php?modulename=user&amp;op=newuser" title="'._ADDELEM.'">
								<img src="'.getPathImage().'standard/add.gif" alt="'._ADD.'" /> '._ADDELEMENT.'</a>');

	$tableUser->CloseTable();

	$images = array(
		'prev' => '<img src="'.getPathImage().'standard/prev.gif" alt="'._PREV.'" title="'._PREVELEM.'" />',
		'next' => '<img src="'.getPathImage().'standard/next.gif" alt="'._NEXT.'" title="'._NEXTELEM.'" />'
	);

	$tableUser->WriteNavBar($images,
							'admin.php?modulename=user&amp;op=user&amp;idGroup='.$idGSel
								.'&amp;searchField='.base64_encode($searchSel).'&amp;startPos=',
							$ini,
							0,
							($idUser != ''));
	echo '</div>';
}

function newuser() {
	//access control
	global $prefixCms;
	funAdminAccess('NEW');
	include('admin/modules/group/groupUtils.php');

	addTitleArea('user');

	echo '<form method="post" action="admin.php?modulename=user&amp;op=insertuser">'
		.'<div class="stdBlock">';


	echo '<fieldset><legend>'._DEFAULTDATA.'</legend>'


		.'<label for="userid"><span class="fontRed">*</span>'._USERID.'</label>'
		.'<input type="text" id="userid" name="userid" maxlength="50" /><br />'

		.'<label for="pass">'._PASSWORD.'</label>'
		.'<input type="password" id="pass" name="password" maxlength="50" /><br />'

		.'<label for="passRe">'._REPASSWORD.'</label>'
		.'<input type="password" id="passRe" name="rePassword" maxlength="50" /><br />'

		.'<label for="rand">'._RANDOMPASS.'</label>'
		.'<input type="checkbox" id="rand" name="randompass" value="1" /><br />'

		.'<label for="mail"><span class="fontRed">*</span>'._EMAIL.'</label>'
		.'<input type="text" id="mail" name="email" maxlength="255" /><br />'

		.'</fieldset>';

	echo '<div class="otherdata">'
		.'<br /><label for="extra">'._EXTRAMAIL.'</label><br />'
		.'<textarea id="extra" name="extratext" rows="4" cols="35"></textarea><br /><br />';

	if(isLMSInstall()) {
		$levelsAvvail = getListOfLMSLevel();
		echo '<label class="floating" for="lev"><span class="fontRed">*</span>'._LEVEL.'</label>'
			.'<select id="lev" name="levelForNewUser">';
		while(list($levelValue, $levelName) = each($levelsAvvail)) {
			echo '<option value="'.$levelValue.'">'.$levelName.'</option>';
		}
		echo '</select>';
	}
	echo '</div>';

	groupMask(0);

	$groups = listGroup(false);
	//Advice and selection for the group
	echo '<div class="otherdata">'
		._DEFAULGROUPADVICE
		.'</div>';


	echo '<fieldset>'
		.'<legend>'._GROUPS.'</legend>';

	echo '';
	if(!count($groups)) echo '<br />'._NOGROUPS.'<br /><br />';
	while(list($idCommon, $nameGroup) = each($groups)) {
		echo '<input type="checkbox" name="groups[]" value="'.$idCommon.'" />&nbsp;'.$nameGroup.'<br />';
	}
	echo '';

	//submit button
	echo '</fieldset>'
		.'<input type="submit" value="'._INSERT.'" />';

	echo '</div>'
		.'</form>';

}

function insertuser() {
	//access control
	global $prefixCms, $urlCms;
	funAdminAccess('NEW');
	include('admin/modules/group/groupUtils.php');

	addTitleArea('user');
	//control userid
	if(trim($_POST['userid']) == '') {
		errorCommunication(_BLANKUSER);
		return;
	}

	//control email
	if ($_POST['email'] == '') {
		errorCommunication(_MAILNOTVALID);
		return;
	}
	if (!eregi("^([a-z0-9_\-]|\\.[a-z0-9_])+@(([a-z0-9_\-]|\\.-)+\\.)+[a-z]{2,8}$", $_POST['email'])) {
		errorCommunication(_MAILNOTVALID);
		return;
	}

	if($_POST['randompass'] == '1') {
		//password creation
		$pass = chr(rand(97, 122)).rand(0, 9).chr(rand(97, 122)).chr(rand(97, 122)).chr(rand(97, 122)).rand(0, 9).rand(0, 9).chr(rand(97, 122));
	}
	elseif($_POST['password'] != $_POST['rePassword']) {
		//password error, no corrispondence
		errorCommunication(_PASSWNOCORR);
		return;
	}
	else $pass = $_POST['password'];

	//control mandatory field
	if(!controlMandatoryFieldGroup()) {
		errorCommunication(_MANDATORYEMPTY);
		return;
	}

	//insert user in database
	$insResult = insertNewUser($_POST['userid'], md5($pass), $_POST['email'], $_POST['levelForNewUser']);

	if($insResult < 0) {
		switch($insResult) {
			case "-1" : {
				errorCommunication(_DUPLICATEUSER);
			};break;
			case "-2" : {
				errorCommunication(_ERRINS);
			};break;
			case "-3" : {
				errorCommunication(_ERRNOIDUSER);
			};break;
		}
		return;
	}
	else { // insert the user into the default group
		$qtxt="INSERT INTO ".$prefixCms."_groupuser (idGroup, idUser, whoins, dateofins) VALUES ('0', '$insResult', '2', NOW());";
		$q=mysql_query($qtxt);
	}

	$mailAdmin = getUserMail($_SESSION['sesCmsAdmUser']);
	$from = "From: $mailAdmin\r\n";
	$intestazione  = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n";
	$mailText = _MAILTEXT.'<br /><br />'
		._SITEURL.'&nbsp;<a href="'.$urlCms.'">'.$urlCms.'</a><br /><br />'
		._USERIDMAIL.'&nbsp;<b>'.trim($_POST['userid']).'</b><br /><br />'
		._PASSWORDMAIL.'&nbsp;<b>'.$pass.'</b><br />'
		.'<hr /><br />'
		.stripslashes($_POST['extratext']);

	//send e-mail
	$mailerr = false;
	if(!@mail($_POST['email'], _MAILOBJECT, $mailText, $from.$intestazione)) {
		echo errorCommunication(_MAILERR);
		echo '<div class="stdBlock"><b>'._MAILTEXTFOLLOW.'</b><br /><br />'.$mailText.'</div>';
		$mailerr = true;
	}

	//save info for default group
	$reGroup = insertGroupInfo(0, $insResult);
	if($reGroup < 0) {
		echo errorCommunication(_ERRORINSCRGROUP);
		return;
	}
	elseif($reGroup > 0) {
		echo errorCommunication(_ERRORFIELDGROUP.$reGroup);
	}

	$groups = '';
	if(isset($_POST['groups'])) {
		while(list(, $idG) = each($_POST['groups']))
			$groups .= $idG.'-';
		$groups = substr($groups, 0, -1);
	}

	//redirect to next step or, if mail error, give a link to proceed
	if(!$mailerr){
		if(!isset($_POST['groups'])) Header('Location:admin.php?modulename=user&op=user');
		else Header('Location:admin.php?modulename=user&op=groupsinscription&idUser='.$insResult.'&idGroups='.$groups);
	}
	else {
		echo '<br /><div class="stdBlock">'
			.'<a href="';
		if(!isset($_POST['groups'])) echo 'admin.php?modulename=user&op=user';
		else echo 'admin.php?modulename=user&amp;op=groupsinscription&amp;idUser='.$insResult.'&amp;idGroups='.$groups;
		echo '">'
			.'<span class="fontBig">'._CLICKTOPROCEED.'</span></a>'
			.'</div>';
	}
}

function groupsinscription() {
	//access control
	global $prefixCms, $urlCms;
	funAdminAccess('NEW');

	addTitleArea('user');
	include('admin/modules/group/groupUtils.php');

	$groupsSel = explode('-', $_GET['idGroups']);


	echo '<div class="stdBlock">'
		.'<div class="title">'._INFOFORGROUP.'</div>'
		.'<form method="post" action="admin.php?modulename=user&amp;op=savegroupinscription">';
	while(list(, $idG) = each($groupsSel)) {
		groupMask($idG);
		echo '<div class="noFloat">'
			.'<input type="hidden" name="groups[]" value="'.$idG.'" /></div>';
	}
	//submit button
	echo '<div class="line">'
			.'<input type="hidden" name="idUser" value="'.$_GET['idUser'].'" />'
			.'<div class="cellContent"><input type="submit" value="'._INSERT.'" /></div>'
		.'</div>'
		.'<div class="noFloat"></div>';
	echo '</form>'
		.'</div>';
}

function savegroupinscription() {
		//access control
	global $prefixCms, $urlCms;
	funAdminAccess('NEW');

	addTitleArea('user');
	include('admin/modules/group/groupUtils.php');
	//control mandatory field
	if(!controlMandatoryFieldGroup()) {
		errorCommunication(_MANDATORYEMPTY);
		return;
	}

	if(isset($_POST['groups'])){
		while(list(, $idGroup) = each($_POST['groups'])) {
			$reGroup = insertGroupInfo($idGroup, $_POST['idUser']);
			if($reGroup < 0) {
				echo errorCommunication(_ERRORINSCRGROUP);
			}
			elseif($reGroup > 0) {
				echo errorCommunication(_ERRORFIELDGROUP.$reGroup);
			}
		}
	}
	Header('Location:admin.php?modulename=user&op=user');
}

function newinfouser() {
	//access control
	global $prefixCms;
	funAdminAccess('MOD');

	$user = getUserInfo($_GET['idUser']);

	addTitleArea('user');


	echo '<form method="post" action="admin.php?modulename=user&amp;op=updateuser">'
		.'<div class="stdBlock">'
		.'<div class="title">'._INSNEWINFO.'</div>'
		.'<input type="hidden" name="idUser" value="'.$_GET['idUser'].'" />'
		.'<fieldset>'
		//userid
		.'<div class="line">'


		.'<label for="userid">'._USERID.'</label>'
		.'<input type="text" id="userid" name="userid" maxlength="50" value="'.$user['userid'].'" /><br />'

		//e-mail
		.'<label for="mail"><span class="fontRed">*</span>'._EMAIL.'</label>'
		.'<input type="text" id="mail" name="email" maxlength="255" value="'.$user['email'].'" /><br />';

		if(isLMSInstall()) {
			$levelsAvvail = getListOfLMSLevel();
			echo '<label for="lev">'._LEVEL.'</label>'
				.'<select id="lev" name="level">';
			while(list($levelValue, $levelName) = each($levelsAvvail)) {
				echo '<option value="'.$levelValue.'"';
				if($levelValue == $user['level']) echo ' selected="selected"';
				echo '>'.$levelName.'</option>';
			}
			echo '</select><br />';
		}

		//password
		echo '<label for="pass">'._PASSWORD.'</label>'
			.'<input type="password" id="pass" name="password" maxlength="50" /><br />'
		//password
		.'<label for="repass">'._REPASSWORD.'</label>'
		.'<input type="password" id="repass" name="rePassword" maxlength="50" /><br />';


	echo '</fieldset>'
		.'<input type="submit" value="'._SAVE.'" />'
		.'</div>'
		.'</form>';

}

function updateuser() {
	//access control
	global $prefixCms, $urlCms;
	funAdminAccess('MOD');

	addTitleArea('user');

	if ($_POST['email'] == '') {
		errorCommunication(_MAILNOTVALID);
		return;
	}
	if (!eregi("^([a-z0-9_\-]|\\.[a-z0-9_])+@(([a-z0-9_\-]|\\.-)+\\.)+[a-z]{2,8}$", $_POST['email'])) {
		errorCommunication(_MAILNOTVALID);
		return;
	}
	if($_POST['password'] == '') {
		$pass = "";
	}
	elseif($_POST['password'] != $_POST['rePassword']) {
		//password error, no corrispondence
		errorCommunication(_PASSWNOCORR);
		return;
	}
	else $pass = $_POST['password'];

	$re = setNewUserinfo($_POST['idUser'], trim($_POST['userid']), $_POST['email'], $_POST['level'], $pass);

	if($re == 0) {
		//insert error
		errorCommunication(_ERRINS);
		return;
	}
	elseif($re == -1) {
		//duplicateuser
		errorCommunication(_DUPLICATEUSER);
		return;
	}

	//sending mail
	$mailAdmin = getUserMail($_SESSION['sesCmsAdmUser']);
	$from = "From: $mailAdmin\r\n";
	$intestazione  = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n";
	$mailText = _MAILTEXTUP.'<br /><br />'
		._SITEURL.'&nbsp;<a href="'.$urlCms.'">'.$urlCms.'</a><br /><br />'
		._USERIDMAIL.'&nbsp;<b>'.trim($_POST['userid']).'</b><br /><br />';
	if($pass != '') $mailText .= _PASSWORDMAIL.'&nbsp;<b>'.$pass.'</b><br />';

	//send e-mail
	$mailerr = false;
	if(!@mail($_POST['email'], _MAILOBJECTUP, $mailText, $from.$intestazione)) {
		echo errorCommunication(_MAILERR);
		echo '<div class="stdBlock"><b>'._MAILTEXTFOLLOW.'</b><br /><br />'.$mailText.'</div>';
		$mailerr = true;
	}
	else Header("Location:admin.php?modulename=user&op=user");
}

function remuser() {
	//access control
	global $prefixCms, $urlCms;
	funAdminAccess('REM');

	addTitleArea('user');

	$user = getUserInfo($_GET['idUser']);

	echo '<div class="stdBlock">'
		.'<div class="evidence">'
		.'<img src="'.getPathImage().'standard/user.gif" alt="'._USER.'" /> '
		.'<a title="'._EMAILTIT.'" href="mailto:'.$user['email'].'">'
		.$user['userid'].'</a></div>';

	echo '<b>'._AREYOUSURE.'</b><br /><br />'
		.'[ <a href="admin.php?modulename=user&amp;op=deluser&amp;idUser='.$_GET['idUser'].'">'._YES.'</a> | '
		.'<a href="admin.php?modulename=user&op=user">'._NO.'</a> ]<br />';

	echo '</div>';
	//Header("Location:admin.php?modulename=user&op=user");
}

function deluser() {
	//access control
	global $prefixCms, $urlCms;
	include('admin/modules/group/groupUtils.php');

	funAdminAccess('REM');

	addTitleArea('user');

	if(!deleteGroupDependence($_GET['idUser'])) {
		errorCommunication(_ERRREM);
		return;
	}

	if(!disableUser($_GET['idUser'])) {
		errorCommunication(_ERRREM);
		return;
	}

	Header("Location:admin.php?modulename=user&op=user");
}

function groupassociateuser() {
	//access control
	global $prefixCms, $urlCms;
	funAdminAccess('MOD');

	include('admin/modules/group/groupUtils.php');
	include('core/class/class.typeone.php');

	addTitleArea('user');

	$user = getUserInfo($_GET['idUser']);
	$groups = listGroup(true);
	$groupsUser = listUserGroup($_GET['idUser']);

	echo '<div class="stdBlock">';

	$tableGroup = new typeOne(0);

	$tableGroup->OpenTable($user['userid'].' : '._GROUPSUSER);

	$tableGroup->WriteHeader(
		array(_GROUPNAME,
			'<img src="'.getPathImage().'user/status.gif" alt="'._STATUS
				.'" title="'._STATUSG.'" />',
			'<img src="'.getPathImage().'user/modinfo.gif" alt="'._MOINFO
				.'" title="'._MODINFOG.'" />',
			'<img src="'.getPathImage().'user/subscribe.gif" alt="'._SUBSCRIBE
				.'" title="'._SUBSCRIBEG.'" />',
			'<img src="'.getPathImage().'user/unsubscribe.gif" alt="'._UNSUBSCRIBE
				.'" title="'._UNSUBSCRIBEG.'" />',),
		array('', 'img', 'img', 'img', 'img'));

	while(list($idG, $nameGroup) = each($groups)) {

		if(isset($groupsUser[$idG])) $isInscr = true;
		else $isInscr = false;

		if($isInscr) {
			$modinfo = '<a href="admin.php?modulename=user&amp;op=modinfousergroup&amp;idG='
					.$idG.'&amp;idUser='.$_GET['idUser'].'" title="'._MODINFOG.'">
					<img src="'.getPathImage().'user/modinfo.gif" alt="'._MOINFO
					.'" /></a>';
			$status = '<img src="'.getPathImage().'user/status.gif" alt="'._STATUS.'" />';
			$subscribe = '&nbsp;';
			$unsubscribe = '<a href="admin.php?modulename=user&amp;op=unsubscribe&amp;idG='
					.$idG.'&amp;idUser='.$_GET['idUser'].'" title="'._UNSUBSCRIBEG.'">
					<img src="'.getPathImage().'user/unsubscribe.gif" alt="'._UNSUBSCRIBE.'" /></a>';

		}
		else {
			$modinfo = '&nbsp;';
			$status = '&nbsp;';
			if ($idG > 0) {
				$subscribe = '<a href="admin.php?modulename=user&amp;op=subscribe&amp;idGroups='
						.$idG.'&amp;idUser='.$_GET['idUser'].'" title="'._SUBSCRIBEG.'">
						<img src="'.getPathImage().'user/subscribe.gif" alt="'._SUBSCRIBE.'" /></a>';
			}
			else {
				$subscribe="";
			}
			$unsubscribe = '&nbsp;';
		}
		if($idG == 0) $unsubscribe = '&nbsp;';

		//writerow
		$tableGroup->WriteRow(
			array($nameGroup,
				$status,
				$modinfo,
				$subscribe,
				$unsubscribe));
	}
	$tableGroup->CloseTable();

	echo '</div>';
}

function unsubscribe() {
	//access control
	global $prefixCms, $urlCms;
	funAdminAccess('REM');

	include('admin/modules/group/groupUtils.php');

	if($_GET['idG'] == '0') Header('Location:admin.php?modulename=user&op=groupassociateuser&idUser='.$_GET['idUser']);

	addTitleArea('user');
	echo '<div class="stdBlock">';

	if($_GET['confirm']) {
		if(deleteGroupDependence($_GET['idUser'], $_GET['idG']))
			Header('Location:admin.php?modulename=user&op=groupassociateuser&idUser='.$_GET['idUser']);
		else {
			errorCommunication(_ERRREMGROUP);
		}
	}
	else {
		$user = getUserInfo($_GET['idUser']);
		$groupName = getGroupName($_GET['idG']);

		echo '<div class="remRequest">';

		echo _CONFREQUEST.'<br /><br />'
			._USERID.' : <span class="redFont">'.$user['userid'].'</span><br />'
			._GROUPNAME.' : <span class="redFont">'.$groupName.'</span><br /><br />'

			.'[ <a href="admin.php?modulename=user&amp;op=unsubscribe&amp;idG='
			.$_GET['idG'].'&amp;idUser='.$_GET['idUser'].'&amp;confirm=1" '
			.'title="'._YESGTIT.'">'._YESG.'</a> | '

			.'<a href="admin.php?modulename=user&amp;op=groupassociateuser&amp;idUser='.$_GET['idUser'].'" '
			.'title="'._NOGITIT.'">'._NOG.'</a> ]';

		echo '</div>';

	}

	echo '</div>';
}

function modinfousergroup() {
	//access control
	global $prefixCms, $urlCms;
	funAdminAccess('MOD');

	include('admin/modules/group/groupUtils.php');

	addTitleArea('user');
	echo '<div class="stdBlock">'
		.'<form method="post" action="admin.php?modulename=user&amp;op=updateinfousergroup">'

		.'<input type="hidden" name="idG" value="'.$_GET['idG'].'" />'
		.'<input type="hidden" name="idUser" value="'.$_GET['idUser'].'" />';

	groupMask($_GET['idG'], true, $_GET['idUser']);

	echo '<br /><input type="submit" value="'._SAVE.'" />';

	echo '</form>'
		.'</div>';
}

function updateinfousergroup() {
	global $prefixCms, $urlCms;
	funAdminAccess('MOD');

	include('admin/modules/group/groupUtils.php');

	controlMandatoryFieldGroup();

	if(!updateGroupInfo($_POST['idG'], $_POST['idUser']))
			Header('Location:admin.php?modulename=user&op=groupassociateuser&idUser='.$_POST['idUser']);
	else {
		errorCommunication(_ERRUPINFO);
	}
}

switch($op) {
	case "user" : {
		user();
	};break;

	case "newuser" : {
		newuser();
	};break;
	case "insertuser" : {
		insertuser();
	};break;
	case "groupsinscription" : {
		groupsinscription();
	};break;
	case "savegroupinscription" : {
		savegroupinscription();
	};break;

	case "newinfouser" : {
		newinfouser();
	};break;
	case "updateuser" : {
		updateuser();
	};break;
	case "groupassociateuser" : {
		groupassociateuser();
	};break;

	case "modinfousergroup" : {
		modinfousergroup();
	};break;
	case "updateinfousergroup" : {
		updateinfousergroup();
	};break;
	case "subscribe" : {
		groupsinscription();
	};break;
	case "unsubscribe" : {
		unsubscribe();
	};break;

	case "remuser" : {
		remuser();
	};break;
	case "deluser" : {
		deluser();
	};break;
}

}

?>