$_SESSION['dune_session_ref'] ?? '']); if (!$identity || empty($mybb->user['uid'])) { header('Location: /dune-sso.php', true, 303); exit; } try { dune_apply_system_board_membership($identity); } catch (Throwable $error) { http_response_code(503); exit('Organisation boards are temporarily unavailable.'); } $kind = $_GET['kind'] ?? 'clan'; $id = $_GET['organisation'] ?? ''; if (!is_string($kind) || !is_string($id) || !in_array($kind, ['clan','company','politics','elections'], true)) { http_response_code(400); exit('Choose a valid board.'); } $projection = $identity['systemBoards']; if ($kind === 'elections') { $board = $db->fetch_array($db->simple_select('dune_system_boards', '*', "kind='system' AND organisation_id='elections'")); } else { $grant = null; foreach ($projection['organisations'] as $item) if ($item['kind'] === $kind && ($id === '' || $item['id'] === $id)) { $grant = $item; break; } if (!$grant || ($grant['read'] ?? false) !== true) { http_response_code(404); exit('This board is not available to your account.'); } $boards = dune_system_board_registry(); $board = $boards[$kind.':'.$grant['id']] ?? null; } if (!$board) { http_response_code(503); exit('This board has not been published yet.'); } header('Location: /forumdisplay.php?fid='.(int)$board['fid'].'&dune_embed=1', true, 303);