MyBB Community Forums

Full Version: [B] Custom Group Deletion
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When you delete a custom group where a member might be additional it's not removed from their additionalgroups column.
switch($db->type)
		{
			case "pgsql":
			case "sqlite3":
			case "sqlite2":
				$query = $db->simple_select("users", "uid", "','||additionalgroups||',' LIKE '%,{$usergroup['gid']},%'");
				break;
			default:
				$query = $db->simple_select("users", "uid", "CONCAT(',',additionalgroups,',') LIKE '%,{$usergroup['gid']},%'");
		}
		while($user = $db->fetch_array($query))
		{
			leave_usergroup($user['uid'], $usergroup['gid']);
		}


I don't see anything wrong with that.

Ryan
leave_usergroup()

Hmm..never noticed that function. I could use that in some of my plugins too.

function leave_usergroup($uid, $leavegroup)
{
	global $db, $mybb, $cache;

	if($uid == $mybb->user['uid'])
	{
		$user = $mybb->user;
	}
	else
	{
		$query = $db->simple_select("users", "*", "uid='".intval($uid)."'");
		$user = $db->fetch_array($query);
	}

	$groupslist = "";
	$usergroups = "";
	$usergroups = $user['additionalgroups'].",";

	$groups = explode(",", $user['additionalgroups']);

	if(is_array($groups))
	{
		foreach($groups as $gid)
		{
			if(trim($gid) != "" && $leavegroup != $gid && !$donegroup[$gid])
			{
				$groupslist .= $comma.$gid;
				$comma = ",";
				$donegroup[$gid] = 1;
			}
		}
	}
	
	$dispupdate = "";
	if($leavegroup == $user['displaygroup'])
	{
		$dispupdate = ", displaygroup=usergroup";
	}

	$db->write_query("
		UPDATE ".TABLE_PREFIX."users
		SET additionalgroups='$groupslist' $dispupdate
		WHERE uid='".intval($uid)."'
	");
	
	$cache->update_moderators();
}

Maybe the problem exists there.
I looked in there as well. I don't see any problems.
Give SQA a chance to test this then.
I cannot reproduce this issue. Marked as bogus.
Well...I guess I will look into this more. Maybe it's another issue with using the upgrade package versus full version.