Well, this is quick and this is dirty. This is possibly the loosest integration in the world - all that is shared really is the username and password.
Having ditched a lot of workarounds, here’s a very quick complete solution. At the end I will list some issues I hope others can solve.
1) Install Vanilla, tell it your MODx db details.
2) Edit /conf/database.php - add this in after your password:
// We're using MODx table for the user.
$DatabaseTables['User'] = 'modx_web_users';
// Next, an extra table, because MODx 0.9.x mostly uses another tables for web user attributes.
$DatabaseTables['UserExtra'] = 'modx_web_user_attributes';
// If you are using a different prefix, you must change this here.
// All Vanilla table references are redefined with LUM_ here so that we can use MODx tables for any table.
$DatabaseTables['Category'] = 'LUM_Category';
$DatabaseTables['CategoryBlock'] = 'LUM_CategoryBlock';
$DatabaseTables['CategoryRoleBlock'] = 'LUM_CategoryRoleBlock';
$DatabaseTables['Comment'] = 'LUM_Comment';
$DatabaseTables['Discussion'] = 'LUM_Discussion';
$DatabaseTables['DiscussionUserWhisperFrom'] = 'LUM_DiscussionUserWhisperFrom';
$DatabaseTables['DiscussionUserWhisperTo'] = 'LUM_DiscussionUserWhisperTo';
$DatabaseTables['IpHistory'] = 'LUM_IpHistory';
$DatabaseTables['Role'] = 'LUM_Role';
$DatabaseTables['Style'] = 'LUM_Style';
$DatabaseTables['UserBookmark'] = 'LUM_UserBookmark';
$DatabaseTables['UserDiscussionWatch'] = 'LUM_UserDiscussionWatch';
$DatabaseTables['UserRoleHistory'] = 'LUM_UserRoleHistory';
$DatabaseColumns['UserExtra']['UserID'] = 'internalKey';
$DatabaseColumns['UserExtra']['Email'] = 'email';
// We may, in time add the others.
// Reused fields:
$DatabaseColumns['User']['UserID'] = 'id';
// New fields:
$DatabaseColumns['User']['Password'] = 'password';
$DatabaseColumns['User']['Email'] = 'vanilla_email';
$DatabaseColumns['User']['Name'] = 'username';
$DatabaseColumns['User']['RoleID'] = 'vanilla_RoleID';
$DatabaseColumns['User']['StyleID'] = 'vanilla_StyleID';
$DatabaseColumns['User']['CustomStyle'] = 'vanilla_CustomStyle';
$DatabaseColumns['User']['FirstName'] = 'vanilla_FirstName';
$DatabaseColumns['User']['LastName'] = 'vanilla_LastName';
$DatabaseColumns['User']['VerificationKey'] = 'vanilla_VerificationKey';
$DatabaseColumns['User']['EmailVerificationKey'] = 'vanilla_EmailVerificationKey';
$DatabaseColumns['User']['UtilizeEmail'] = 'vanilla_UtilizeEmail';
$DatabaseColumns['User']['ShowName'] = 'vanilla_ShowName';
$DatabaseColumns['User']['Icon'] = 'vanilla_Icon';
$DatabaseColumns['User']['Picture'] = 'vanilla_Picture';
$DatabaseColumns['User']['Attributes'] = 'vanilla_Attributes';
$DatabaseColumns['User']['CountVisit'] = 'vanilla_CountVisit';
$DatabaseColumns['User']['CountDiscussions'] = 'vanilla_CountDiscussions';
$DatabaseColumns['User']['CountComments'] = 'vanilla_CountComments';
$DatabaseColumns['User']['DateFirstVisit'] = 'vanilla_DateFirstVisit';
$DatabaseColumns['User']['DateLastActive'] = 'vanilla_DateLastActive';
$DatabaseColumns['User']['RemoteIp'] = 'vanilla_RemoteIp';
$DatabaseColumns['User']['LastDiscussionPost'] = 'vanilla_LastDiscussionPost';
$DatabaseColumns['User']['DiscussionSpamCheck'] = 'vanilla_DiscussionSpamCheck';
$DatabaseColumns['User']['LastCommentPost'] = 'vanilla_LastCommentPost';
$DatabaseColumns['User']['CommentSpamCheck'] = 'vanilla_CommentSpamCheck';
$DatabaseColumns['User']['UserBlocksCategories'] = 'vanilla_UserBlocksCategories';
$DatabaseColumns['User']['DefaultFormatType'] = 'vanilla_DefaultFormatType';
$DatabaseColumns['User']['Discovery'] = 'vanilla_Discovery';
$DatabaseColumns['User']['Preferences'] = 'vanilla_Preferences';
$DatabaseColumns['User']['SendNewApplicantNotifications'] = 'vanilla_SendNewApplicantNotifications';
3) Edit /conf/settings.php - add in
// MODx integration settings
$Configuration['DATABASE_TABLE_PREFIX'] = ''; // LUM_ is now added elsewhere.
// $Configuration['AUTHENTICATION_MODULE'] = 'People/People.Class.MODxAuthenticator.php';
// This should work with the WebLogin snippet, change it if you use a different session ID:
$Configuration['SESSION_USER_IDENTIFIER'] = 'webInternalKey';
// WebLogin actually uses the username in the cookie, so you'll have to just double-cookie.
$Configuration['COOKIE_USER_KEY'] = 'lussumocookieone';
$Configuration['COOKIE_VERIFICATION_KEY'] = 'lussumocookietwo';
// Change COOKIE_PATH if you change the cookie.
4) Use phpMyAdmin to add to your web_users table by executing this SQL:
ALTER TABLE modx_web_users
ADD `vanilla_RoleID` int(2) NOT NULL DEFAULT '3',
ADD `vanilla_StyleID` int(3) NOT NULL DEFAULT '1',
ADD `vanilla_CustomStyle` varchar(255) DEFAULT NULL,
ADD `vanilla_FirstName` varchar(50) NOT NULL DEFAULT '',
ADD `vanilla_LastName` varchar(50) NOT NULL DEFAULT '',
ADD `vanilla_VerificationKey` varchar(50) NOT NULL DEFAULT '',
ADD `vanilla_EmailVerificationKey` varchar(50) DEFAULT NULL,
ADD `vanilla_Email` varchar(200) NOT NULL DEFAULT '',
ADD `vanilla_UtilizeEmail` enum('1','0') NOT NULL DEFAULT '0',
ADD `vanilla_ShowName` enum('1','0') NOT NULL DEFAULT '1',
ADD `vanilla_Icon` varchar(255) DEFAULT NULL,
ADD `vanilla_Picture` varchar(255) DEFAULT NULL,
ADD `vanilla_Attributes` text NULL,
ADD `vanilla_CountVisit` int(8) NOT NULL DEFAULT '0',
ADD `vanilla_CountDiscussions` int(8) NOT NULL DEFAULT '0',
ADD `vanilla_CountComments` int(8) NOT NULL DEFAULT '0',
ADD `vanilla_DateFirstVisit` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
ADD `vanilla_DateLastActive` datetime NOT NULL DEFAULT '2006-06-06 00:00:00',
ADD `vanilla_RemoteIp` varchar(100) NOT NULL DEFAULT '',
ADD `vanilla_LastDiscussionPost` datetime DEFAULT NULL,
ADD `vanilla_DiscussionSpamCheck` int(11) NOT NULL DEFAULT '0',
ADD `vanilla_LastCommentPost` datetime DEFAULT NULL,
ADD `vanilla_CommentSpamCheck` int(11) NOT NULL DEFAULT '0',
ADD `vanilla_UserBlocksCategories` enum('1','0') NOT NULL DEFAULT '0',
ADD `vanilla_DefaultFormatType` varchar(20) DEFAULT NULL,
ADD `vanilla_Discovery` text,
ADD `vanilla_Preferences` text,
ADD `vanilla_SendNewApplicantNotifications` enum('1','0') NOT NULL DEFAULT '0';
5) For an appropriate Web User, change vanilla_RoleID to 4 - granting access to the Vanilla admin stuff.
6) That’s it.
--
Big Thing Left To Do:
Add to web_user_attributes upon registration.
The impact of A means that presently (under MODx 0.9.2.1), users added in MODx can be used in Vanilla, but users added in Vanilla won’t show up in the list - presumably because there is no corresponding userid in _attributes.
I’ve made the _attributes table available to Vanilla, I called it UserExtra. It is presently not used, but I have successfully used it in investigations thus far. You can use something like
$s->SetMainTable(’UserExtra’, ’ue’);
to use it. There are 2 fields available through the definitions - UserID (actually the internalKey field) and Email.
What needs to happen on registration is: Do registration. Get UserID. Save a new row in UserExtra with UserID and Email set. I just don’t know how exactly to go about doing this bit. I can see that it needs to be in a file called extensions/MODxIntegration/default.php and that it needs to be like the code at the bottom of
http://lussumo.com/docs/doku.php?id=vanilla:integration:wordpress but I don’t fully understand his API, and frankly it’s late here.
I’m not going to get chance to do anything more on this - I hope it’s helped.
Now, of course, all that’s happened here is we’ve bolted on a bunch of Vanilla fields to a user system that is in dire need of attention, and told Vanilla where to look for stuff (including session ID). It is quite, quite far from the integration one might dream about. It is however a start.
A suite of Vanilla-friendly snippets would be useful - a version of WebLogin that used the same cookie/session methodology would be a big help. It should also be fairly trivial to whip up a TV with binding to Vanilla threads so that the relevant page to link to could be set easily.