src/Neuron/GameServer/Windows/OldChat.php
private function getUserRightWhere ()
	{
		if (!isset ($this->sWhere))
		{
			$groups = array ();
			
			$this->sWhere = "(";
		
			if (!$this->user)
			{
				// Only allowed to see the public messages (0/0)
				$groups[self::CHAT_GROUP_ALL] = array (array ($this->channel), false);
			}
			
			else
			{
				// Always show your own message 
				// or don't.
				//$this->sWhere .= 'chat.plid = '.$this->user->getId ().' OR ';
			
				// Allowed to see private messages and clan
				$groups[self::CHAT_GROUP_ALL] = array (array ($this->channel), false);
				$groups[self::CHAT_GROUP_USER] = array (array ($this->user->getId ()), true);
				
				$clans = $this->user->getClans ();
				if (count ($clans) > 0)
				{
					$groups[self::CHAT_GROUP_CLAN] = array (array (), true);
				
					foreach ($clans as $clan)
					{
						$groups[self::CHAT_GROUP_CLAN][0][] = $clan->getId ();
					}
				}
			}
			
			// Build the actual *where*
			foreach ($groups as $k => $v)
			{
				if (is_array ($v) && count ($v) > 0)
				{
					$this->sWhere .= "(chat.target_group = {$k} AND (";
					
					if ($v[1])
					{
						$this->sWhere .= "chat.plid = {$this->user->getId()} OR ";
					}
					
					foreach ($v[0] as $vv)
					{
						$this->sWhere .= "chat.target_id = {$vv} OR ";
					}
					$this->sWhere = substr ($this->sWhere, 0, -4).")) OR ";
				}
				else
				{
					$this->sWhere .= "chat.target_group = {$k} OR ";
				}
			}
			$this->sWhere = substr ($this->sWhere, 0, -4).")";
		}
		
		return $this->sWhere;
	}
private function getUserRightWhere ()
	{
		if (!isset ($this->sWhere))
		{
			$groups = array ();
			
			$this->sWhere = "(";
		
			if (!$this->user)
			{
				// Only allowed to see the public messages (0/0)
				$groups[self::CHAT_GROUP_ALL] = array (array ($this->channel), false);
			}
			
			else
			{
				// Always show your own message 
				// or don't.
				//$this->sWhere .= 'chat.plid = '.$this->user->getId ().' OR ';
			
				// Allowed to see private messages and clan
				$groups[self::CHAT_GROUP_ALL] = array (array ($this->channel), false);
				$groups[self::CHAT_GROUP_USER] = array (array ($this->user->getId ()), true);
				
				$clans = $this->user->getClans ();
				if (count ($clans) > 0)
				{
					$groups[self::CHAT_GROUP_CLAN] = array (array (), true);
				
					foreach ($clans as $clan)
					{
						$groups[self::CHAT_GROUP_CLAN][0][] = $clan->getId ();
					}
				}
			}
			
			// Build the actual *where*
			foreach ($groups as $k => $v)
			{
				if (is_array ($v) && count ($v) > 0)
				{
					$this->sWhere .= "(chat.target_group = {$k} AND (";
					
					if ($v[1])
					{
						$this->sWhere .= "chat.plid = {$this->user->getId()} OR ";
					}
					
					foreach ($v[0] as $vv)
					{
						$this->sWhere .= "chat.target_id = {$vv} OR ";
					}
					$this->sWhere = substr ($this->sWhere, 0, -4).")) OR ";
				}
				else
				{
					$this->sWhere .= "chat.target_group = {$k} OR ";
				}
			}
			$this->sWhere = substr ($this->sWhere, 0, -4).")";
		}
		
		return $this->sWhere;
	}
/*
Return the SQL statement
to get all messages for this player