Quote from: rossco at May 01, 2008, 09:05 PM
How much work would it take to integrate a forum or a shopping cart in to modx now with the new structure? Sharing usernames and passwords for forums and hidden pages etc.
I think Ryan didn’t notice what board this post was in, but anywho...
Essentially integrating an existing "forum" or "shopping cart" system is something that STILL depends entirely on the capabilities of said system to integrate with external applications. And even that can be a difficult thing to determine; a lot of systems say they provide API’s for these types of integrations, but they often fall short of functional expectations in actual deployments.
Unfortunately, there simply is not a cookie-cutter approach to integrating the various user systems of disparate PHP web applications. Each application has to be evaluated to determine the best path to take, and in many cases, there aren’t any quick solutions. And I won’t even get into the other issues inherent in developing bridges between applications with "incompatible" licenses.
All that said, the ease of using the new modX class as a "framework" (i.e. include in external PHP application code), being able to configure contexts with custom session handlers, user classes, etc., and the multitude of other benefits of the new object-oriented API should hopefully help make these integrations easier for developers to achieve.
And on a related note, I have an integration partially completed with our Atlassian Crowd identity server via it’s SOAP API. It’s very basic at the moment, and not ready for public consumption yet, but is working very well to allow external authentication to MODx via Crowd, including automatic importation of user data. This first example of a MODx Core Extension consists of an authentication plugin, and two classes, a modCrowdUser class that extends the new modUser class, and a modCrowdClient class that provides a PHP SoapClient instance to communicate with the Crowd SOAP API.
Here is the current plugin, which reveals a new event in 0.9.7, OnUserNotFound...
<?php
switch ($modx->event->name) {
case "OnUserNotFound":
if (isset($username) && !empty($username)) {
$crowdAttributes = array (
'url' => isset($crowdUrl) ? $crowdUrl : $modx->config['user.crowd.url'],
'application' => isset($crowdApp) ? $crowdApp : $modx->config['user.crowd.application'],
'credential' => isset($crowdPwd) ? $crowdPwd : $modx->config['user.crowd.credential']
);
$modx->addPackage('modx.user.crowd', MODX_CORE_PATH . 'model/');
if ($crowd = $modx->getService('crowd', 'modCrowdClient', '', $crowdAttributes)) {
$userexists = $crowd->findUsername($username);
$user = & $scriptProperties['user'];
$user = $modx->newObject('modCrowdUser');
$user->set('username', $username);
$user->addOne($modx->newObject('modUserProfile'));
}
}
break;
//Register this event for authentication in all other contexts
case "OnWebAuthentication":
//Register this event for manager authentication only
case "OnManagerAuthentication":
$authenticated = false;
if (isset($user) && !empty($user) && isset($password) && !empty($password)) {
$crowdAttributes = array (
'url' => isset($crowdUrl) ? $crowdUrl : $modx->config['user.crowd.url'],
'application' => isset($crowdApp) ? $crowdApp : $modx->config['user.crowd.application'],
'credential' => isset($crowdPwd) ? $crowdPwd : $modx->config['user.crowd.credential']
);
$modx->addPackage('modx.user.crowd', MODX_CORE_PATH . 'model/');
if ($crowd = $modx->getService('crowd', 'modCrowdClient', '', $crowdAttributes)) {
if ($authenticated = $crowd->authenticate($user->get('username'), $password)) {
if ($user->isNew() && is_a($user, 'modCrowdUser') && $modx->config['user.crowd.autoadd']) {
if ($userDetails = $crowd->getUser($user->get('username'))) {
$user->modUserProfile->set('fullname', implode(" ", array($userDetails['givenName'], $userDetails['sn'])));
$user->modUserProfile->set('email', $userDetails['mail']);
$user->modUserProfile->set('failed_logins', $userDetails['invalidPasswordAttempts']);
$user->modUserProfile->set('last_login', $userDetails['lastAuthenticated']);
$authenticated = $user->save();
}
}
}
}
}
$modx->event->_output = $authenticated;
break;
}
?>
Lot’s of exciting new possibilities; many still to be revealed.