Location: PHPKode > projects > pmchat > pmchat/clientutil.inc
<?

function addTeam($teamName,$email)
{
$query="INSERT INTO TeamInfo(NAME,EMAIL) values('".$teamName."','".$email."')";
return executeQuery($query);
}

function addUser($userName,$teamId,$email,$loginname,$password,$role)
{
	$query="INSERT INTO UserInfo(USERNAME,TEAMID,EMAIL,LOGINNAME,PASSWORD,ROLE) values('".$userName."',".$teamId.",'".$email."','".$loginname."','".$password."','".$role."')";
	$rs=mysql_query($query);
	
	if(!$rs)
	{
		return 0;
	}
	
	return 1;
}


function updateUser($userId,$userName,$teamId,$email,$loginname,$password,$role)
{
			$query="";

			if($password==null)
			{
			$query="UPDATE UserInfo SET USERNAME='".$userName."',TEAMID=".$teamId.",EMAIL='".$email."',LOGINNAME='".$loginname."',ROLE='".$role."' where USERID=".$userId;
			}
			else
			{
			$query="UPDATE UserInfo SET USERNAME='".$userName."',TEAMID=".$teamId.",EMAIL='".$email."',LOGINNAME='".$loginname."',PASSWORD='".$password."',ROLE='".$role."' where USERID=".$userId;
			}			
			
			$rs=mysql_query($query);
			
			if(!$rs)
			{
				return 0;
			}

			return 1;
		
}//func


function deleteUser($userId)
{


	$query="DELETE from UserInfo where USERID=".$userId;


	$rs=mysql_query($query);

	if(!$rs)
	{
		return 0;
	}

	return 1;
	
}//func



function executeQuery($query)
{

$rs=mysql_query($query);
return $rs;

}//function


function addToArray($v,$s)
{
$found=false;
for($i=0;$i<count($v);$i++)
{
$s1=$v[$i];
if($s1==$s)
{
$found=true;
break;
}
}
if(!$found)
{
array_push($v,$s);
}
return $v;
}

function getUserNames($userIdList,$delim)
{		

		$query= "SELECT USERNAME FROM UserInfo WHERE ";
		
		
		$tt=getlist($userIdList,$delim);
		
		for($i=0;$i<count($tt);$i++)
		{
			$temp=$tt[$i];
			if(($i+1)< count($tt))
			{
			$query.="USERID=".$temp." OR ";
			}
			else
			{
			$query.="USERID=".$temp." ";	
			}
		}//for		
				
		$v=array();
		
		$rs=executeQuery($query);
		
		if($rs)
		{
		while($row=mysql_fetch_array($rs))
		{
			array_push($v,$row['USERNAME']);
			
		}//while
		}
		
		return $v;

}


function getUserInfo($userId)
{
		$query="SELECT * from UserInfo WHERE USERID=".$userId;

		return executeQuery($query);
}
?>
Return current item: pmchat