/** Return an User instance given its id (or null if it's not found) * @param int $uID The id of the user * @param bool $login = false Set to true to make the user the current one * @param bool $cacheItemsOnLogin = false Set to true to cache some items when $login is true * * @return User|null */ public static function getByUserID($uID, $login = false, $cacheItemsOnLogin = true) { $app = Application::getFacadeApplication(); $db = $app['database']->connection(); $v = array($uID); $q = "SELECT uID, uName, uIsActive, uLastOnline, uTimezone, uDefaultLanguage, uLastPasswordChange FROM Users WHERE uID = ? LIMIT 1"; $r = $db->query($q, $v); $row = $r ? $r->FetchRow() : null; $nu = null; if ($row) { $nu = new self(); $nu->setPropertiesFromArray($row); $nu->uGroups = $nu->_getUserGroups(true); $nu->superUser = $nu->getUserID() == USER_SUPER_ID; if ($login) { $nu->persist($cacheItemsOnLogin); $nu->recordLogin(); } } return $nu; }