For all of you that want to have this feature I explain the steps.
1- Include in /include/functions.php the getAvatarFromIds, cloned from getUnameFromIds.
function getAvatarFromIds($uid, $usereal = false)
{
if (!is_array($uid)) {
$uid = array($uid);
}
$userid = array_map('intval', array_filter($uid));
$myts =& MyTextSanitizer::getInstance();
$avatars = array();
if (count($userid) > 0) {
$xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection();
$sql = 'SELECT uid, user_avatar FROM ' . $xoopsDB->prefix('users') . ' WHERE level > 0 AND uid IN(' . implode(',', array_unique($userid)) . ')';
if (!$result = $xoopsDB->query($sql)) {
return $avatars;
}
while ($row = $xoopsDB->fetchArray($result)) {
$uid = $row['uid'];
$avatars[$uid] = $myts->htmlSpecialChars($row['user_avatar']);
}
}
return $avatars;
}
2-Open /modules/newbb/blocks/newbb_block.php. There are 3 functions, one called b_newbb_show for recent answered topic, b_newbb_topic_show for last topics and b_newbb_post_show for last posts. All works the same in this modification, but you have to modify each function in order to have the hack running in all the three blocks.
Find in each
$author_name = newbb_getUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true);
After add
$author_avatar = getAvatarFromIds(array_keys($author));
And now for b_newbb_show and b_newbb_post_show find
$topic['topic_poster'] = $topic_poster;
and after add
if (!empty($author_avatar[$arr['uid']])) {
$topic_avatar = $author_avatar[$arr['uid']];
} else {
$topic_avatar = '';
}
$topic['topic_avatar'] = $topic_avatar;
for b_newbb_topic_show find
$topic['topic_poster'] = $topic_poster;
and after add
if (!empty($author_avatar[$arr['topic_poster']])) {
$topic_avatar = $author_avatar[$arr['topic_poster']];
} else {
$topic_avatar = '';
}
$topic['topic_avatar'] = $topic_avatar;
3-Finally add to your templates located in /modules/newbb/templates/blocks/ this code to show the new smarty variable.
<img src="<{$xoops_url}>/uploads/<{$topic.topic_avatar}>" alt="avatar" />
To have all the avatars same size and shape I use smart resizer.
Hope you find this useful.
Demo here, the red block in the bottom of the page.
PS: Thks guia for the help