Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
FirstName and LastName in session
Mark,
I'm using the People framework outside of Vanilla for several projects, and I have certain pages where I greet / refer to the user by their full name or first name (if set). UserManager->GetSessionDataById() doesn't populate the FirstName/LastName fields of the user object that's stored in the session, so I have to patch it whenever I upgrade Vanilla (no big deal, it's just a 1-line change).
Would you consider populating these two fields in a future version of People / Vanilla? It's on line 518 of People.Class.UserManager.php.
Btw, if you're curious about how I'm using Vanilla / People, http://dcsquares.c99.org/ uses People for authentication, and uses the Vanilla user IDs for the high score tables. My newer project, http://dev.c99.org/DreamZZT/ uses a leaderboard as well as a game download system written as a Vanilla extension.
Thanks,
Sam Steele
0
This discussion has been closed.
Comments
GetSessionDataByID
is intended for getting the session of the currently logged in user.UserManager->GetUserByID()
is probably more appropriate for this use, and it also includes the first name and last name in the user object.Only downside I can see is its a very similar query that would wind up being run twice for those pages that greet the user by name. No biggie IMHO.
in People.Class.UserManager.php changed line 518 from this:
$s->AddSelect(array('Name', 'UserID', 'RoleID', 'StyleID', 'CustomStyle', 'UserBlocksCategories', 'DefaultFormatType', 'Preferences', 'SendNewApplicantNotifications'), 'u');
to this:
$s->AddSelect(array('Name', 'FirstName', 'LastName', 'UserID', 'RoleID', 'StyleID', 'CustomStyle', 'UserBlocksCategories', 'DefaultFormatType', 'Preferences', 'SendNewApplicantNotifications'), 'u');
Then I changed Vanilla.Class.CommentManager.php, line 46:
$s->AddSelect('Name', 'a', 'AuthUsername');
to
$s->AddSelect('FirstName', 'a', 'AuthUsername');
and changed Vanilla.Class.DiscussionManager.php, line 47:
$s->AddSelect('Name', 'u', 'AuthUsername');
to
$s->AddSelect('FirstName', 'u', 'AuthUsername');
and line 51:
$s->AddSelect('Name', 'lu', 'LastUsername');
to
$s->AddSelect('FirstName', 'lu', 'LastUsername');
Obviously changing code like this is not the most efficient way to do this, but I am a lazy man who is only interested in results. Probably there are WAY more areas where these updates have to be made, I've only posted the ones that made the pages look the way i wanted them.
edit: Also I should note that for users who do not have the First Name field filled in, the query returns nothing and thus there is no text displayed either on Comments or on the Discussions page. However it does not appear to break anything, you'll just have nameless icons.