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.
How to use People
I've just installed the latest version off SVN because I'm interested in using the new "People" framework to handle authentication in another application I'm developing for my site that uses a Vanilla forum. I don't know OO PHP too well, so I'm pretty confused about how it works. The basic tasks I'll need to carry out:
* Login user, starting session and setting cookies
* Retrieve user info (userid, and name)
* logout user
I'd greatly appreciate it if someone could provide brief samples of how to do those things or explain what some of the People classes do.
Thanks!
0
This discussion has been closed.
Comments
$Context->Authenticator->Authenticate($Username, $Password, $Persistant);
do all the work of creating the session and cookies?How do I check if the user is logged in and access user information such as username?
if ($Context->Session->UserID) { //User Logged In! Echo their User Name. echo $Context->Session->User->Name; }
I've also read here somewhere that I can just include appg/init_people.php rather than the two files (settings.php and init_ajax.php) above. Is this correct?
include_once("./appg/settings.php"); include_once("./appg/init_people.php");
No idea why you'd need the ajax one for session management.
Edit: Looks like settings has to be included first, so I try including settings and then init_people and I get the following error:
Fatal error: Cannot redeclare class mysql in /home/path/to/site/forum/library/Framework/Framework.Class.MySQL.php on line 139
Looks like "StringFormatter" is also duplicated in both....what a nightmare this little project has turned out to be.
Then open up your conf/settings.php file and add this:
$Configuration['DATABASE_SERVER'] = 'VanillaMySQL';
For the StringFormatter you're probably going to have to rename it in one of the two apps.
Mark, I did try to rename the conflicting classes and it seemed to work witht the MySQL class, but not so well with the StringFormatter. Maybe I'll give it a closer look. The link you provided sounds interesting, though I don't understand the "Then you will go into your conf/settings.php file and change the Database structure to reflect your new CatUser table and the fields inside it." I'm looking at the settings file and I'm not seeing how it relates to the database structure.
Edit: Nevermind, I found the correct file, appg/database.php
echo $Context->Session->User->FirstName;
doesn't work
Are you sure the currently logged in user has a firstname?
echo $Context->Session->User->Name; i get the Username but the FirstName doesn't work. LastName doesn't work at all.
When I mistype it, like Firstname or firstname i get an error, but with FirstName i only get an empty string
if (!@$UserManager) $UserManager = $Context->ObjectFactory->NewContextObject($Context, "UserManager"); $AccountUserID = ForceIncomingInt("u", $Context->Session->UserID); if (!@$AccountUser) $AccountUser = $UserManager->GetUserById($AccountUserID);
and then print $AccountUser->FirstName or FullName or whatever.