2
Where do we inactivate a user, can you point me? Is it in the profile module?
I try to get a way of doing that but I´m not sure it will allways work.
In this tip a user will get logged out everytime you change his groups.
Edit system/admin/users/users.php around line 225
} else {
if ($groups != array()) {
global $xoopsUser;
$oldgroups = $edituser->getGroups();
//If the edited user is the current user and the current user WAS in the webmaster's group and is NOT in the new groups array
if ($edituser->getVar('uid') == $xoopsUser->getVar('uid') && (in_array(XOOPS_GROUP_ADMIN, $oldgroups)) && !(in_array(XOOPS_GROUP_ADMIN, $groups))) {
//Add the webmaster's group to the groups array to prevent accidentally removing oneself from the webmaster's group
array_push($groups, XOOPS_GROUP_ADMIN);
}
$member_handler =& xoops_gethandler('member');
foreach ($oldgroups as $groupid) {
$member_handler->removeUsersFromGroup($groupid, array($edituser->getVar('uid')));
}
foreach ($groups as $groupid) {
$member_handler->addUserToGroup($groupid, $edituser->getVar('uid'));
}
//hack by trabis
$session_id = '';
$sql= "SELECT s.sess_id FROM ".$xoopsDB->prefix('online')." o LEFT JOIN ".$xoopsDB->prefix('session')." s ON o.online_ip=s.sess_ip WHERE o.online_uid='".$edituser->getVar('uid')."'";
$result = $xoopsDB->query($sql);
list($session_id) = $xoopsDB->fetchRow($result);
if($session_id != '') {
$sql = "DELETE FROM ".$xoopsDB->prefix('session')." WHERE sess_id='".$session_id."'";
$result = $xoopsDB->queryF($sql));
}
//end of hack
}
redirect_header("admin.php?fct=users",1,_AM_DBUPDATED);
}
This code will check if the user is online so he can get the user IP. Having the user IP the script will get the user session and then delete it.
I think you must have the "Whos Online" Block in your page in order to have the table populated.
I did not find any other way of doing this because the session table is not directly linked to the user profile.
Another thing that may occur is that the session may be deleted on any change in the profile and not just for groups. I´m not shore on that either. Please test it. BTW, don´t try to modify your own account because it wont work, you will not be logged out. You can only log out other users.