phpBB API Documentation
Class

phpbb\user_loader

class user_loader

User loader class

This handles loading users from the database and storing in them in a temporary cache so we do not have to query the same user multiple times in different services.

Methods

__construct(driver_interface $db, string $phpbb_root_path, string $php_ext, string $users_table)

User loader constructor

load_users(array $user_ids)

Load user helper

int load_user_by_username(string $username)

Load a user by username

array|bool get_user(int $user_id, bool $query = false)

Get a user row from our users cache

string get_username(int $user_id, string $mode, string $guest_username = false, string $custom_profile_url = false, bool $query = false)

Get username

string get_avatar(int $user_id, bool $query = false, bool $lazy = false)

Get avatar

array get_rank(int $user_id, bool $query = false)

Get rank

Details

at line 53
public __construct(driver_interface $db, string $phpbb_root_path, string $php_ext, string $users_table)

User loader constructor

Parameters

driver_interface $db A database connection
string $phpbb_root_path Path to the phpbb includes directory.
string $php_ext php file extension
string $users_table The name of the database table (phpbb_users)

at line 68
public load_users(array $user_ids)

Load user helper

Parameters

array $user_ids

at line 102
public int load_user_by_username(string $username)

Load a user by username

Stores the full data in the user cache so they do not need to be loaded again Returns the user id so you may use get_user() from the returned value

Parameters

string $username Raw username to load (will be cleaned)

Return Value

int User ID for the username

at line 131
public array|bool get_user(int $user_id, bool $query = false)

Get a user row from our users cache

Parameters

int $user_id User ID of the user you want to retreive
bool $query Should we query the database if this user has not yet been loaded? Typically this should be left as false and you should make sure you load users ahead of time with load_users()

Return Value

array|bool Row from the database of the user or Anonymous if the user wasn't loaded/does not exist or bool False if the anonymous user was not loaded

at line 165
public string get_username(int $user_id, string $mode, string $guest_username = false, string $custom_profile_url = false, bool $query = false)

Get username

Parameters

int $user_id User ID of the user you want to retreive the username for
string $mode The mode to load (same as getusernamestring). One of the following: profile (for getting an url to the profile) username (for obtaining the username) colour (for obtaining the user colour) full (for obtaining a html string representing a coloured link to the users profile) no_profile (the same as full but forcing no profile link)
string $guest_username Optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then.
string $custom_profile_url Optional parameter to specify a profile url. The user id get appended to this url as &u={user_id}
bool $query Should we query the database if this user has not yet been loaded? Typically this should be left as false and you should make sure you load users ahead of time with load_users()

Return Value

string

at line 185
public string get_avatar(int $user_id, bool $query = false, bool $lazy = false)

Get avatar

Parameters

int $user_id User ID of the user you want to retrieve the avatar for
bool $query Should we query the database if this user has not yet been loaded? Typically this should be left as false and you should make sure you load users ahead of time with load_users()
bool $lazy @lazy If true, will be lazy loaded (requires JS)

Return Value

string

at line 211
public array get_rank(int $user_id, bool $query = false)

Get rank

Parameters

int $user_id User ID of the user you want to retreive the rank for
bool $query Should we query the database if this user has not yet been loaded? Typically this should be left as false and you should make sure you load users ahead of time with load_users()

Return Value

array Array with keys 'ranktitle', 'rankimg', and 'rankimgsrc'