db = $db; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $this->users_table = $users_table; } /** * Load user helper * * @param array $user_ids */ public function load_users(array $user_ids) { $user_ids[] = ANONYMOUS; // Load the users $user_ids = array_unique($user_ids); // Do not load users we already have in $this->users $user_ids = array_diff($user_ids, array_keys($this->users)); if (sizeof($user_ids)) { $sql = 'SELECT * FROM ' . $this->users_table . ' WHERE ' . $this->db->sql_in_set('user_id', $user_ids); $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $this->users[$row['user_id']] = $row; } $this->db->sql_freeresult($result); } } /** * Get a user row from our users cache * * @param int $user_id * @return 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 */ public function get_user($user_id) { return (isset($this->users[$user_id])) ? $this->users[$user_id] : (isset($this->users[ANONYMOUS]) ? $this->users[ANONYMOUS] : false); } /** * Get avatar * * @param int $user_id * @return string */ public function get_avatar($user_id) { if (!($user = $this->get_user($user_id))) { return ''; } if (!function_exists('get_user_avatar')) { include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); } return get_user_avatar($user['user_avatar'], $user['user_avatar_type'], $user['user_avatar_width'], $user['user_avatar_height']); } }