<?php
$onoff = '0';
$userdata->set('dbtech_vbmail_bounceflag', $onoff);

// Ensure we can fetch bitfields
require_once(DIR . '/includes/adminfunctions_options.php');
$bitfields = fetch_bitfield_definitions('nocache|dbtech_vbmailpermissions');

$usergroupids = array_merge(array($user['usergroupid']), explode(',', $userinfo['membergroupids']));
$bit = 0;
foreach ((array)VBMAIL::$cache['mailinglist'] as $mailinglistid => $mailinglist)
{
	$subscribe = false;
	foreach ($mailinglist['permissions'] as $usergroupid => $permissions)
	{
		if (!in_array($usergroupid, $usergroupids))
		{
			// We're not a member of this UG
			continue;
		}
		
		if (!($permissions & (int)$bitfields['defaultsubscribed']))
		{
			// Not default subscribed
			continue;
		}
		
		// Set the bitfield
		$subscribe = true;
	}
	
	if ($subscribe AND $userinfo['userid'])
	{
		// Subscribe this user
		VBMAIL::subscribeUser($userinfo, $mailinglist, 'newuser');
	}
}
?>