$id > 0))); sort($allowed, SORT_NUMERIC); return $allowed; } function dune_board_additional_groups(string $current, array $managed, array $allowed): string { // Remove only groups owned by this integration. Political, staff and all // other unrelated additional groups remain untouched. $old = array_filter(array_map('intval', explode(',', $current)), fn($id) => $id > 0); $groups = array_values(array_unique(array_merge(array_diff($old, $managed), $allowed))); sort($groups, SORT_NUMERIC); return implode(',', $groups); } function dune_board_private_permissions(array $columns, bool $member): array { $allowed = ['canview', 'canviewthreads', 'candlattachments', 'canpostthreads', 'canpostreplys', 'canpostattachments', 'caneditposts', 'caneditattachments', 'canpostpolls', 'canvotepolls', 'cansearch']; $result = []; foreach ($columns as $column) { if (in_array($column, ['pid', 'fid', 'gid'], true)) continue; $result[$column] = $member && in_array($column, $allowed, true) ? 1 : 0; } return $result; } function dune_board_descendant(int $target, int $root, array $parents): bool { if ($root < 1 || $target < 1) return false; $seen = []; while ($target > 0) { if ($target === $root) return true; if (isset($seen[$target]) || !array_key_exists($target, $parents)) return false; $seen[$target] = true; $target = (int)$parents[$target]; } return false; }