Ok here we go...this first post is my solution for those using
Community Builder.
I will try later also to post a solution for those using the default mambo user component.
Open the file
admin.comprofiler.phpAdd the following code block to the end of the file:
function deleteSMF($userid) {
global $database;
$database->setQuery("UPDATE smf_messages SET ID_MEMBER = 0 WHERE ID_MEMBER = '$userid'");
$database->query();
$database->setQuery("DELETE FROM smf_members WHERE ID_MEMBER = '$userid'");
$database->query();
$database->setQuery("DELETE FROM smf_log_topics WHERE ID_MEMBER = '$userid'");
$database->query();
$database->setQuery("DELETE FROM smf_log_boards WHERE ID_MEMBER = '$userid'");
$database->query();
$database->setQuery("DELETE FROM smf_log_mark_read WHERE ID_MEMBER = '$userid'");
$database->query();
$database->setQuery("DELETE FROM smf_log_notify WHERE ID_MEMBER = '$userid'");
$database->query();
$database->setQuery("DELETE FROM smf_log_online WHERE ID_MEMBER = '$userid'");
$database->query();
$database->setQuery("DELETE FROM smf_collapsed_categories WHERE ID_MEMBER = '$userid'");
$database->query();
$database->setQuery("DELETE FROM smf_themes WHERE ID_MEMBER = '$userid'");
$database->query();
$database->setQuery("UPDATE smf_instant_messages SET ID_MEMBER_FROM = 0 WHERE ID_MEMBER_FROM '$userid'");
$database->query();
$database->setQuery("DELETE FROM smf_moderators WHERE ID_MEMBER = '$userid'");
$database->query();
//Now update the modSettings
$database->setQuery("SELECT COUNT(ID_MEMBER) AS count, MAX(ID_MEMBER) AS max FROM smf_members");
$results = $database->loadObjectList();
$memberCount = $results[0]->count;
$latestmember = $results[0]->max;
$database->setQuery("SELECT IFNULL(realName, memberName) AS realName FROM smf_members WHERE ID_MEMBER = " . (int) $latestmember . " LIMIT 1");
$latestRealName = $database->loadResult();
$database->setQuery("REPLACE INTO smf_settings (variable,value) VALUES ('latestMember', '$latestmember'),('latestRealName', '$latestRealName'),('memberCount', '$memberCount')");
$database->query();
return;
}
The
userid that is passed to the above function is the
SMF ID_MEMBER (not the mambo userid), this function interacts with the
removeusers function of
community builder.
So find the
removeusers function and edit:
Around line 996 you will find the following:
$obj->delete( $id );
$obj2->delete( $id );
$msg .= $obj->getError();
$msg .= $obj2->getError();
Add
directly above it the following code (this is needed since SMF userid's and mambo id's are different, we need to find the username first and then check for the id).
$database->setQuery("SELECT name FROM #__users WHERE id='$id'");
$name = $database->loadResult();
so you should now have:
$database->setQuery("SELECT name FROM #__users WHERE id='$id'");
$name = $database->loadResult();
$obj->delete( $id );
$obj2->delete( $id );
$msg .= $obj->getError();
$msg .= $obj2->getError();
Now
right under the above block add the following lines:
//SMF Hack
//Check if SMF is actually installed
$database->setQuery("SELECT COUNT(*) FROM #__components WHERE link = 'option=com_smf'");
$active = $database->loadResult();
if($active > 0)
{
$database->setQuery("SELECT ID_MEMBER from smf_members WHERE memberName = '$name'");
$smfid = $database->loadResult();
deleteSMF($smfid);
}
// End SMF Hack
As you can see this is the place where the deleteSMF is called.
Now everytime you erase a user from the mambo administration tool of the
community builder the user is also erased (with all of his stuff) from SMF as well.
This is a quick fix for the delete issue. I am working on a totaly modified community component which will integrade both SMF and gallery2 components.