public static function getInstance($id = null)
	{
		static $instances;
		static $usernames;

		if (!isset($instances))
		{
			$instances = array();
		}

		if (!isset($usernames))
		{
			$usernames = array();
		}

		// Is this a username?
		if (!is_numeric($id))
		{
			// Normalize and check if we have data for this username
			$id = strtolower(trim($id));
			if (!isset($usernames[$id]))
			{
				$user = new self($id);

				// Save
				$usernames[$id] = $user->get('uidNumber');
				$instances[$usernames[$id]] = $user;
			}
			// Change the $id from username to numeric ID
			$id = $usernames[$id];
		}

		// Check for existing record
		if (empty($instances[$id]) || $instances[$id]->get('uidNumber') != $id)
		{
			$user = new self($id);
			$instances[$id] = $user;
		}

		// Ensure record has data
		if (!$instances[$id]->get('uidNumber'))
		{
			return false;
		}

		return $instances[$id];
	}
public static function getInstance($id = null)
	{
		static $instances;
		static $usernames;

		if (!isset($instances))
		{
			$instances = array();
		}

		if (!isset($usernames))
		{
			$usernames = array();
		}

		// Is this a username?
		if (!is_numeric($id))
		{
			// Normalize and check if we have data for this username
			$id = strtolower(trim($id));
			if (!isset($usernames[$id]))
			{
				$user = new self($id);

				// Save
				$usernames[$id] = $user->get('uidNumber');
				$instances[$usernames[$id]] = $user;
			}
			// Change the $id from username to numeric ID
			$id = $usernames[$id];
		}

		// Check for existing record
		if (empty($instances[$id]) || $instances[$id]->get('uidNumber') != $id)
		{
			$user = new self($id);
			$instances[$id] = $user;
		}

		// Ensure record has data
		if (!$instances[$id]->get('uidNumber'))
		{
			return false;
		}

		return $instances[$id];
	}
public static function getInstance ( $ id = null ) { static $ instances ; static $ usernames ; if ( ! isset ( $ instances ) ) { $ instances = array ( ) ; } if ( ! isset ( $ usernames ) ) { $ usernames = array ( ) ; } // Is this a username? if ( ! is_numeric ( $ id ) ) { // Normalize and check if we have data for this username $ id = strtolower ( trim ( $ id ) ) ; if ( ! isset ( $ usernames [ $ id ] ) ) { $ user = new self ( $ id ) ; // Save $ usernames [ $ id ] = $ user -> get ( 'uidNumber' ) ; $ instances [ $ usernames [ $ id ] ] = $ user ; } // Change the $id from username to numeric ID $ id = $ usernames [ $ id ] ; } // Check for existing record if ( empty ( $ instances [ $ id ] ) || $ instances [ $ id ] -> get ( 'uidNumber' ) != $ id ) { $ user = new self ( $ id ) ; $ instances [ $ id ] = $ user ; } // Ensure record has data if ( ! $ instances [ $ id ] -> get ( 'uidNumber' ) ) { return false ; } return $ instances [ $ id ] ; }
Returns a reference to the global User object, only creating it if it doesn't already exist.

@param   mixed  $id  The user to load - Can be an integer or string
@return  mixed  Returns object if valid record found, false if not
Returns a reference to the global User object only creating it if it doesn t already exist .