$res = mysqli_fetch_assoc(db_query('Select channel_id FROM '.$mumbledb.'.channels where name = \''.$clan_chan_name.'\' and server_id = '.$serverid));
14 years ago
$clan_chan = $res['channel_id'];
$rename_sql = 'UPDATE '.$mumbledb.'.users p inner join '.$ag_db.'.user u on p.user_id = u.id set p.name = u.nickname WHERE p.name != u.nickname and server_id = '.$serverid;
$search_lost_players = 'Select p.user_id FROM '.$mumbledb.'.users as p left join '.$ag_db.'.user as u on p.user_id = u.id where p.user_id > 0 and u.nickname is null and p.server_id = '.$serverid;
$delete_sql = 'DELETE FROM '.$mumbledb.'.users where user_id IN ('.join(',',$player).') and server_id = '.$serverid;
}
//echo $delete_sql.'<br>';
// Verbinde die Clanchannels mit den Clans
//$clan_channels_sql = 'SELECT distinct(clanname) as name from '.$mumbledb.'.channels c right join '.$ag_db.'.clan cl on c.name = cl.clanname where name is null';
$clan_channels_sql = 'SELECT distinct(clanname) as name, count(u.clan) anzahl, name is not null as existance from '.$mumbledb.'.channels c right join '.$ag_db.'.clan cl on c.name = cl.clanname left join '.$ag_db.'.user u on cl.id = u.clan group by clanname';
db_query('DELETE FROM '.$mumbledb.'.channels WHERE parent_id = '.$clan_chan. ' and name = \''.$row['name'].'\' and server_id = '.$serverid);
14 years ago
}
}
// Delete nonexistant Clan-Channels!
$search_lost_channels = 'select channel_id FROM '.$mumbledb.'.channels left join '.$ag_db.'.clan on name = clanname where clanname is null and parent_id = '.$clan_chan.' and server_id = '.$serverid;
$remove_clan_channel_sql = 'DELETE FROM '.$mumbledb.'.channels where channel_id IN ('.join(',',$channels).') and server_id = '.$serverid;
}
//echo $remove_clan_channel_sql.'<br>';
$sql_user_select = 'Select p.user_id, ch.name as ch_name, ch2.name as ch2_name, ch.parent_id as ch_parent_id, ch2.parent_id as ch2_parent_id, g.group_id as g_group_id, g2.group_id as g2_group_id from
( '.$ag_db.'.user u inner join '.$mumbledb.'.users p on
u.id = p.user_id
)
left join '.$ag_db.'.clan cl on
u.clan = cl.id
left join '.$mumbledb.'.group_members gm on
gm.user_id = p.user_id and p.server_id = gm.server_id
left join '.$mumbledb.'.groups g on
g.group_id = gm.group_id and g.server_id = p.server_id
left join '.$mumbledb.'.channels ch on
ch.channel_id = g.channel_id and p.server_id = ch.server_id
left join '.$mumbledb.'.channels ch2 on
ch2.name = cl.clanname and p.server_id = ch2.server_id
left join '.$mumbledb.'.groups g2 on
g2.channel_id = ch2.channel_id and g2.server_id = p.server_id
where not (ch.name is null && ch2.name is null) and (ch.name is null || ch.parent_id = 2) and (ch2.name is null || ch2.parent_id = 2) and (ch.name is null || ch2.name is null or ch.name != ch2.name) and p.server_id = '.$serverid;