Hi, people. Well, this comes from a discussion I had at the old mamboportal forum about a week ago. I had been wondering if there was any possibility of having multiple Mambo sites running on one server and sharing ONE user database.
That means that if you register in one of the sites, you could use the same username/password in the other installed Mambo sites.
So.. I got a bunch o' you-can't-do-that's and try-something-less-cool's

, but at the last moment I thought up a way to get Mambo to this for me, so for all it's worth I though I'd share my hack with the mambo community.
------------------------------------------------------------------------
Mambo 4.5 hack to support multi-site / one usertable (backup your site AND database):
1) C'mon, back'em up.
2) In database.php, add:
///////////////////////////////////////////////////////////////////////////////////////
function database( $host='localhost', $user, $pass, $db, $table_prefix ) {
// perform a number of fatality checks, then die gracefully
if (!function_exists( 'mysql_connect' )) {
//or die( 'FATAL ERROR: MySQL support not available. Please check your configuration.' );
$mosSystemError = 1;
include "configuration.php";
include "offline.php";
exit();
}
if (!($this->_resource = @mysql_connect( $host, $user, $pass ))) {
//or die( 'FATAL ERROR: Connection to database server failed.' );
$mosSystemError = 1;
include "configuration.php";
include "offline.php";
exit();
}
if (!mysql_select_db($db)) {
//or die( "FATAL ERROR: Database not found. Operation failed with error: ".mysql_error());
$mosSystemError = 1;
include "configuration.php";
include "offline.php";
exit();
}
$this->_table_prefix = $table_prefix;
/* Tom: make a second prefix so we can later change depending on if we reference the users table or not */
global $mosConfig_users_dbprefix;
$this->_user_table_prefix = $mosConfig_users_dbprefix;
/* Tom: end edit */
}
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
function setQuery( $sql, $prefix='#__' ) {
/* Tom: substitute the prefixes that point to the users table with the central user table prefix */
$sql = str_replace('#__users', $this->_user_table_prefix.'users', $sql);
$sql = str_replace('mos_users', $this->_user_table_prefix.'users', $sql);
/* Tom: end edit */
$this->_sql = str_replace( $prefix, $this->_table_prefix, $sql );
}
///////////////////////////////////////////////////////////////////////////////////////
3) In configuration.php, add:
///////////////////////////////////////////////////////////////////////////////////////
$mosConfig_users_dbprefix = 'all_'; //tom: this is the prefix for the cross site user table
///////////////////////////////////////////////////////////////////////////////////////
4) Finally rename your mos_users table (or whatever prefix you use for your first mos site) to all_users.
5) Thats it! I think
Cheers,
Thomas Woodard