/
Modern way of showing user in grids

Modern way of showing user in grids

Imported From: http://groups.google.com/group/in-portal-dev/browse_thread/thread/ed407b4ac446715a#

Most of data, that can be added from Front-End has "CreatedById" column, that stores ID of user, who created that record.

In all places we use LEFT JOIN to "PortalUser" table to speed up user data retrieval. However we don't centrally use universal scheme for user data display. Here is the one, that I've developed on one of projects I was working on:

'CASE %1$s.CreatedById
	WHEN ' . USER_ROOT . ' THEN "root"
	WHEN ' . USER_GUEST . ' THEN "Guest"
	ELSE IF(CONCAT(pu.FirstName, pu.LastName) <> "", CONCAT(pu.FirstName, " ", pu.LastName), pu.Username)
END'

Above SQL shows user's firstname & lastname only when they are filled and shows username otherwise.