Login username shown instead of firstname

15 years 6 months ago #78988 by grosbedo
Hello,
there is a bug which makes Community Builder show the username instead of the CommunityBuilder's DB firstname or Joomla's DB name.

The bug is located in /modules/mod_cblogin/mod_cblogin.php at line 96:

[code:1] $name = $params->get( 'name', 0 );[/code:1]

$name always returns 0 here. I'm not sure why, but I understand the result it has later, between lines 167 and 179:

[code:1]if ( $_CB_framework->myId() ) {
if ($name) {
if ($name == 2) {
$query = "SELECT firstname FROM #__comprofiler WHERE id = ". (int) $_CB_framework->myId();
} else {
$query = "SELECT name FROM #__users WHERE id = ". (int) $_CB_framework->myId();
}
$_CB_database->setQuery( $query );
// some joomla versions (1.5.1, 1.0.11+ do htmlspecialchars in database!):
$name = htmlspecialchars( cbUnHtmlspecialchars( $_CB_database->loadResult() ) );
} else {
$name = htmlspecialchars( cbUnHtmlspecialchars( $_CB_framework->myUsername() ) );
}[/code:1]

I didn't really had the time to look deepier, but I found a quick and dirty fix. Replace the lines shown above from 167 to 179:

[code:1] $query = "SELECT firstname FROM #__comprofiler WHERE id = ". (int) $_CB_framework->myId();
$_CB_database->setQuery( $query );
// some joomla versions (1.5.1, 1.0.11+ do htmlspecialchars in database!):
$name = htmlspecialchars( cbUnHtmlspecialchars( $_CB_database->loadResult() ) );
if (!$name) {
$query = "SELECT name FROM #__users WHERE id = ". (int) $_CB_framework->myId();
}
if (!$name) {
$name = htmlspecialchars( cbUnHtmlspecialchars( $_CB_framework->myUsername() ) );
}
[/code:1]

I think you can find a better way to fix this issue than me, now that you know where to look for this bug :)

Cordially

Please Log in to join the conversation.

15 years 5 months ago #79486 by beat
Thanks for sharing your fix B)

I couldn't reproduce this issue in latest CB 1.2 RC 3, so it must have been fixed some time ago.

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.225 seconds

Facebook Twitter LinkedIn