<?php
	class OSUser
	{
        private $UserID				=	0;
		private	$UserUUID			=	"";
		private $UserName			=	"";
		private $UserMail			=	"";

		private $Grid				=	null;

		function __construct($userUUID, $userName, $userMail, $grid, $userid = 0) 
		{
			global $RUNTIME;

			$this->Grid				=	$grid;

			$this->UserUUID		=	$userUUID;
			$this->UserName		=	$userName;
			$this->UserMail		=	$userMail;

			if($userid == 0)
			{
				$addRegionStatement = $RUNTIME['PDO']->prepare("INSERT IGNORE INTO users (GridID, UserUUID, UserName, UserMail) VALUES (:GridID, :UserUUID, :UserName, :UserMail)");
				$addRegionStatement->execute(array("GridID" => $this->Grid->getGridID(), "UserUUID" => $userUUID, "UserName" => $userName, "UserMail" => $userMail)); 
				$this->UserID		= $RUNTIME['PDO']->lastInsertId();
			}

			if($this->UserID == 0)
			{
				$getRegionStatement = $RUNTIME['PDO']->prepare("SELECT * FROM users WHERE UserUUID = :UserUUID AND GridID = :GridID");
				$getRegionStatement->execute(array("UserUUID" => $userUUID, "GridID" => $this->Grid->getGridID())); 

				if($row = $getRegionStatement->fetch())
					$this->RegionID = $row['UserID'];
			}
		}
    }
?>