From 63ac375bd8ef338f7d089b3f9306d3905597a4fb Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Mon, 16 Nov 2026 20:07:52 +0100 Subject: [PATCH] design: match board management styling and restore native index collapse --- docs/design/SYSTEM-BOARDS.md | 4 ++ .../mybb/inc/plugins/dune_sections.php | 57 +++++++++++++++++++ .../mybb/provision-system-boards.php | 1 + .../integrations/mybb/system-board-embed.php | 4 +- .../mybb/system-board-manage-view.php | 23 ++++++++ .../integrations/mybb/system-board-manage.php | 11 ++-- website/integrations/mybb/system-board.css | 36 ++++++++++++ .../mybb/test-system-board-category.php | 25 ++++++++ .../mybb/test-system-board-embed.php | 14 ++++- 9 files changed, 165 insertions(+), 10 deletions(-) create mode 100644 website/integrations/mybb/inc/plugins/dune_sections.php create mode 100644 website/integrations/mybb/system-board-manage-view.php create mode 100644 website/integrations/mybb/test-system-board-category.php diff --git a/docs/design/SYSTEM-BOARDS.md b/docs/design/SYSTEM-BOARDS.md index ebcebb72..a949e43c 100644 --- a/docs/design/SYSTEM-BOARDS.md +++ b/docs/design/SYSTEM-BOARDS.md @@ -56,3 +56,7 @@ On clan deletion, current central membership grants disappear. Preserve forum hi ## Compact internal view The first board batch is live from main 39bb5486 (PR #351, CI #354); the four existing active clans have private forums. Native MyBB permission merging passed 52 checks. The user has posted a test thread successfully. The following styling batch gives embedded CP pages a separate green/gold dev presentation and shared palace background, small author rows, no public-profile decoration or signatures, and a full-forum link. Category defaults use MyBB’s native collapse cookie once, then respect the user preference. No custom deletion/pruning worker is needed. + +## Management page and normal-index control + +The management page uses a pure shared PHP view (system-board-manage-view.php) with the compact board stylesheet, illustrated heading, field cards, native field names and CSRF token, and a read-only structure guide. POST validation and inherited membership/moderation remain unchanged. The existing dune_sections.php index renderer replaces MyBB category markup; it now restores the native expander image and cat__e container for the System Boards root, respecting native collapse cookies. Other categories keep their previous presentation. The CLI publisher disables front-end plugins during initialization, avoiding duplicate helper loading after installation. diff --git a/website/integrations/mybb/inc/plugins/dune_sections.php b/website/integrations/mybb/inc/plugins/dune_sections.php new file mode 100644 index 00000000..d36eae24 --- /dev/null +++ b/website/integrations/mybb/inc/plugins/dune_sections.php @@ -0,0 +1,57 @@ +add_hook('index_end','dune_sections_index'); +$plugins->add_hook('pre_output_page','dune_sections_style'); +function dune_sections_style($html){return str_replace('','',$html);} +function dune_sections_info(){return ['name'=>'DuneRealms forum sections','description'=>'Category panels with native permission-aware forum rows and child links.','website'=>'https://www.dunerealms.com','author'=>'DuneRealms','version'=>'1.0.0','compatibility'=>'18*'];} +function dune_sections_escape($text){return htmlspecialchars((string)$text,ENT_QUOTES,'UTF-8');} +function dune_sections_visible($forum,$all){ + foreach(explode(',',$forum['parentlist']??(string)$forum['fid'])as$id){ + if(!isset($all[(int)$id])||empty($all[(int)$id]['active']))return false; + $permissions=forum_permissions((int)$id); + if(empty($permissions['canview'])||!forum_password_validated($all[(int)$id],true))return false; + } + return true; +} +function dune_sections_children($id,$all){ + $children=array_filter($all,fn($f)=>(int)$f['pid']===$id&&dune_sections_visible($f,$all)); + usort($children,fn($a,$b)=>((int)$a['disporder']<=>(int)$b['disporder'])?:((int)$a['fid']<=>(int)$b['fid'])); + return $children; +} +function dune_sections_links($children){ + return implode('',array_map(fn($f)=>''.dune_sections_escape($f['name']).'',$children)); +} +function dune_sections_index(){ + global $cache,$mybb,$forums,$fcache,$db,$theme,$collapsed,$collapsedimg,$collapsedthead; + if(empty($mybb->settings['dune_sections_enabled']))return; + $all=$cache->read('forums');$roots=dune_sections_children(0,$all);$html=''; + $systemRoot=0; + if($db->table_exists('dune_system_boards')){$record=$db->fetch_array($db->simple_select('dune_system_boards','fid',"kind='system' AND organisation_id='root'"));$systemRoot=(int)($record['fid']??0);} + foreach($roots as$root){ + $panels=dune_sections_children((int)$root['fid'],$all);if(!$panels)$panels=[$root]; + $system=(int)$root['fid']===$systemRoot;$key='cat_'.(int)$root['fid'];$toggle=''; + if($system){$label=empty($collapsed[$key.'_e'])?'Collapse System Boards':'Expand System Boards';$toggle='
'.$label.'
';} + $html.='
'.$toggle.'

COMMUNITY FORUMS

'.dune_sections_escape($root['name']).'

'; + if($system)$html.='
'; + $html.='
Subcategories'.dune_sections_links($panels).'
'; + foreach($panels as$panel){ + $children=dune_sections_children((int)$panel['fid'],$all); + $html.='

'.dune_sections_escape($panel['name']).'

'.dune_sections_escape(strip_tags($panel['description'])).'

SUBCATEGORY
'; + $previous=$mybb->settings['hideprivateforums'];$mybb->settings['hideprivateforums']=1; + try{ + if($children){$html.='
Forums'.dune_sections_links($children).'
';$rows=build_forumbits((int)$panel['fid'],2);} + elseif($panel['type']==='f'){ + $copy=$panel;$copy['name']='Discussions';$copy['description']='';$virtual=-991; + $before=$fcache[$virtual]??null;$fcache[$virtual]=[0=>[(int)$panel['fid']=>$copy]]; + try{$rows=build_forumbits($virtual,2);}finally{if($before===null)unset($fcache[$virtual]);else $fcache[$virtual]=$before;} + }else $rows=null; + }finally{$mybb->settings['hideprivateforums']=$previous;} + if($rows&&!empty($rows['forum_list']))$html.=''.$rows['forum_list'].'
ForumThreadsPostsLast post
'; + else $html.='

No visible forums in this section.

'; + $html.='
'; + } + $html.='
'.($system?'
':'').'
'; + } + if($html)$forums=$html; +} + diff --git a/website/integrations/mybb/provision-system-boards.php b/website/integrations/mybb/provision-system-boards.php index c8714ec2..01f767b8 100644 --- a/website/integrations/mybb/provision-system-boards.php +++ b/website/integrations/mybb/provision-system-boards.php @@ -8,6 +8,7 @@ foreach ($input['organisations'] as $org) { if (!in_array($org['kind'] ?? '', ['clan','company'], true) || !preg_match('/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i', $org['id'] ?? '') || !is_string($org['name'] ?? null) || trim($org['name']) === '' || strlen($org['name']) > 120) throw new RuntimeException('Invalid organisation'); } define('IN_MYBB', 1); +if(!defined('NO_PLUGINS'))define('NO_PLUGINS',1); define('MYBB_ROOT', '/home/dunerealms/apps/integrations/mybb/'); require MYBB_ROOT.'inc/init.php'; require __DIR__.'/system-board-policy.php'; diff --git a/website/integrations/mybb/system-board-embed.php b/website/integrations/mybb/system-board-embed.php index 28abc9ee..72a62728 100644 --- a/website/integrations/mybb/system-board-embed.php +++ b/website/integrations/mybb/system-board-embed.php @@ -16,8 +16,8 @@ function dune_system_board_embed(&$page): void { $path=parse_url($_SERVER['REQUEST_URI'] ?? '/index.php',PHP_URL_PATH);if(!in_array($path,['/forumdisplay.php','/showthread.php'],true))$path='/index.php'; $params=$_GET;unset($params['dune_embed']);$outside='https://forums.dunerealms.com'.$path.($params?'?'.http_build_query($params):''); $toolbar='
Internal BoardsPrivate conversations · Your organisation
'; - $page=preg_replace('/(]*>)/i','$1'.$toolbar,$page,1); - $style = ''; + if(!str_contains($page,'data-system-board-toolbar'))$page=preg_replace('/(]*>)/i','$1'.$toolbar,$page,1); + $style = ''; $script = <<<'JS' JS; diff --git a/website/integrations/mybb/system-board-manage-view.php b/website/integrations/mybb/system-board-manage-view.php new file mode 100644 index 00000000..ded751cf --- /dev/null +++ b/website/integrations/mybb/system-board-manage-view.php @@ -0,0 +1,23 @@ +htmlspecialchars((string)$value,ENT_QUOTES|ENT_SUBSTITUTE,'UTF-8'); + $kind=$view['kind']==='company'?'Company':'Clan';$back='/forumdisplay.php?fid='.(int)$view['root'].'&dune_embed=1'; + $options='';$list=''; + foreach($view['parents'] as $forum){ + $name=html_entity_decode($forum['name'],ENT_QUOTES|ENT_HTML5,'UTF-8'); + $options.=''; + $list.='
  • '.$h($name).''.($forum['type']==='c'?'Category':'Forum').'
  • '; + } + $error=$view['error']!==''?'':''; + $type=$view['type']==='c'?'c':'f'; + return 'Manage your board' + .'
    Board administration'.$kind.' workspace
    ' + .'
    YOUR ORGANISATION · YOUR CONVERSATIONS

    Manage your board

    Create a space for your people. Access and moderation follow your organisation.

    ' + .'

    Create a new space

    Choose its place, type and name.

    '.$error + .'
    ' + .'
    ' + .'' + .'
    ' + .'
    Cancel
    ' + .'
    '; +} diff --git a/website/integrations/mybb/system-board-manage.php b/website/integrations/mybb/system-board-manage.php index 43d95791..67abdd4e 100644 --- a/website/integrations/mybb/system-board-manage.php +++ b/website/integrations/mybb/system-board-manage.php @@ -38,9 +38,8 @@ if ($mybb->request_method==='post') { header('Location: /forumdisplay.php?fid='.$fid.'&dune_embed=1',true,303); exit; } } -$h=fn($value)=>htmlspecialchars((string)$value,ENT_QUOTES|ENT_SUBSTITUTE,'UTF-8'); -echo 'Manage your board

    Manage your board

    Create a forum or category inside your organisation. Membership and moderation are inherited.

    '; -if ($error) echo '

    '.$h($error).'

    '; -echo '

    Back to board

    '; +require_once __DIR__.'/system-board-manage-view.php'; +require_once __DIR__.'/system-board-embed.php'; +$allowedParents=array_values(array_filter($forums,fn($forum)=>!empty($forum['active'])&&dune_board_descendant((int)$forum['fid'],$root,$parents))); +$html=dune_render_board_management(['kind'=>$kind,'organisation'=>$id,'root'=>$root,'parents'=>$allowedParents,'postKey'=>$mybb->post_code,'parent'=>$mybb->request_method==='post'?$mybb->get_input('parent',MyBB::INPUT_INT):$root,'name'=>$mybb->request_method==='post'?$mybb->get_input('name'):'','type'=>$mybb->request_method==='post'?$mybb->get_input('forum_type'):'f','error'=>$error]); +$_GET['dune_embed']='1';dune_system_board_embed($html);echo $html; diff --git a/website/integrations/mybb/system-board.css b/website/integrations/mybb/system-board.css index 91e905c1..ac866640 100644 --- a/website/integrations/mybb/system-board.css +++ b/website/integrations/mybb/system-board.css @@ -56,3 +56,39 @@ body.dune-board-embedded .sceditor-toolbar{white-space:normal!important} body.dune-board-embedded .dune-author-identity{display:contents!important} body.dune-board-embedded label{color:var(--board-ink)!important} +body.dune-board-embedded .board-management{max-width:1180px;margin:0 auto} +body.dune-board-embedded .board-management-hero{display:flex;align-items:center;gap:20px;padding:22px;margin:0 0 18px;border:1px solid #8d8452;border-radius:10px;background:linear-gradient(110deg,#214c3bdd,#16372eea),url('https://www.dunerealms.com/assets/political-imperial-chamber-v1.png') center/cover} +body.dune-board-embedded .board-management-hero img{flex:0 0 72px;object-fit:contain} +body.dune-board-embedded .board-management-hero small{font-size:10px;letter-spacing:.12em;color:var(--board-gold)} +body.dune-board-embedded .board-management h1{font:700 25px/1.25 system-ui,sans-serif;color:#f0d99f;margin:6px 0 8px} +body.dune-board-embedded .board-management h2{font:650 16px/1.4 system-ui,sans-serif;color:#efd79e;margin:0 0 9px} +body.dune-board-embedded .board-management p{margin:5px 0 12px;color:var(--board-muted);font-size:13px} +body.dune-board-embedded .board-management-grid{display:grid;grid-template-columns:minmax(0,1.65fr) minmax(230px,1fr);align-items:start;gap:18px} +body.dune-board-embedded .board-management-card{min-width:0;padding:22px;border:1px solid #506d52;border-radius:10px;background:#16382eea;box-shadow:0 5px 20px #0001} +body.dune-board-embedded .board-form-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:22px 18px;margin-top:24px} +body.dune-board-embedded .board-form-fields label{display:flex;flex-direction:column;gap:9px;min-width:0;font-size:13px;font-weight:600} +body.dune-board-embedded .board-form-fields :is(input,select){width:100%;min-height:42px;padding:10px!important} +body.dune-board-embedded .board-form-fields small{font-size:11px;font-weight:400;color:var(--board-muted);line-height:1.6} +body.dune-board-embedded .board-form-fields input::placeholder{color:#91aa9b;opacity:1} +body.dune-board-embedded .board-form-full{grid-column:1/-1} +body.dune-board-embedded .board-form-actions{display:flex;align-items:center;gap:16px;flex-wrap:wrap;padding-top:22px;margin-top:24px;border-top:1px solid #48634c} +body.dune-board-embedded .board-management button.board-form-primary{background:#d0b165!important;color:#102b22!important;border-color:#e2c784!important;padding:11px 19px!important;min-height:42px} +body.dune-board-embedded .board-management button.board-form-primary:hover{background:#e5ca82!important} +body.dune-board-embedded .board-form-cancel{font-size:13px;color:var(--board-muted)!important;text-decoration:none} +body.dune-board-embedded .board-management-guide{display:grid;gap:18px} +body.dune-board-embedded .board-space-tip{padding-top:12px;margin-top:12px;border-top:1px solid #365444} +body.dune-board-embedded .board-space-tip strong{font-size:12px;color:#dfcd98} +body.dune-board-embedded .board-space-tip p{font-size:12px;margin-bottom:0} +body.dune-board-embedded .board-management-tree{list-style:none;padding:0;margin:12px 0} +body.dune-board-embedded .board-management-tree li{display:flex;align-items:center;justify-content:space-between;gap:12px;overflow-wrap:anywhere;border-top:1px solid #365444;padding:11px 0;font-size:12px} +body.dune-board-embedded .board-management-tree small{flex-shrink:0;color:#cbbb8e;font-size:10px;border:1px solid #596b4e;border-radius:20px;padding:2px 8px} +body.dune-board-embedded .board-inherited-note{font-size:11px!important;padding:12px;margin-top:16px!important;background:#102b22;border-radius:6px;color:#bdcdbd!important} +body.dune-board-embedded .board-form-alert{padding:12px 14px;border:1px solid #bd9458;border-radius:7px;background:#493d26;color:#f3d9a7;margin-top:16px;font-size:12px} +@media(max-width:720px){ + body.dune-board-embedded .board-management-grid{grid-template-columns:minmax(0,1fr)} + body.dune-board-embedded .board-management-hero{padding:17px;gap:14px} + body.dune-board-embedded .board-management-hero img{width:52px;height:52px;flex-basis:52px} + body.dune-board-embedded .board-management h1{font-size:22px} + body.dune-board-embedded .board-management-card{padding:18px} + body.dune-board-embedded .board-form-fields{grid-template-columns:minmax(0,1fr)} +} diff --git a/website/integrations/mybb/test-system-board-category.php b/website/integrations/mybb/test-system-board-category.php new file mode 100644 index 00000000..2b0eba8c --- /dev/null +++ b/website/integrations/mybb/test-system-board-category.php @@ -0,0 +1,25 @@ +['fid'=>1,'pid'=>0,'parentlist'=>'1','active'=>1,'disporder'=>1,'type'=>'c','name'=>'Community','description'=>''], + 2=>['fid'=>2,'pid'=>1,'parentlist'=>'1,2','active'=>1,'disporder'=>1,'type'=>'f','name'=>'Lounge','description'=>''], + 50=>['fid'=>50,'pid'=>0,'parentlist'=>'50','active'=>1,'disporder'=>1000,'type'=>'c','name'=>'System Boards','description'=>''], + 51=>['fid'=>51,'pid'=>50,'parentlist'=>'50,51','active'=>1,'disporder'=>1,'type'=>'c','name'=>'Clan Boards','description'=>''], + 52=>['fid'=>52,'pid'=>51,'parentlist'=>'50,51,52','active'=>1,'disporder'=>1,'type'=>'f','name'=>'Allowed House','description'=>''], + 99=>['fid'=>99,'pid'=>51,'parentlist'=>'50,51,99','active'=>1,'disporder'=>1,'type'=>'f','name'=>'Hidden House','description'=>''] + ];}} +class CategoryFixtureDatabase {function table_exists($table){return true;}function simple_select(...$unused){return [];}function fetch_array($query){return ['fid'=>50];}} +function forum_permissions($fid){return ['canview'=>$fid!==99];} +function forum_password_validated(...$unused){return true;} +function get_forum_link($fid){return 'forumdisplay.php?fid='.$fid;} +function build_forumbits(...$unused){return ['forum_list'=>'Visible native rows'];} +$cache=new CategoryFixtureCache();$db=new CategoryFixtureDatabase();$theme=['imgdir'=>'images'];$mybb=(object)['settings'=>['dune_sections_enabled'=>1,'hideprivateforums'=>0]];$fcache=[]; +$collapsed=['cat_50_e'=>'display: none;'];$collapsedimg=['cat_50'=>'_collapsed'];$collapsedthead=['cat_50'=>' thead_collapsed'];$forums=''; +dune_sections_index(); +foreach(['id="cat_50_img"','class="expander"','id="cat_50_e" style="display: none;"','images/collapse_collapsed.png'] as $expected)if(!str_contains($forums,$expected))throw new RuntimeException('Missing native collapse markup: '.$expected); +if(str_contains($forums,'cat_1_img'))throw new RuntimeException('Unrelated category controls changed'); +if(str_contains($forums,'Hidden House'))throw new RuntimeException('Hidden forum exposed'); +echo "System Boards native category control checks passed\n"; diff --git a/website/integrations/mybb/test-system-board-embed.php b/website/integrations/mybb/test-system-board-embed.php index 2982c286..3d211cfc 100644 --- a/website/integrations/mybb/test-system-board-embed.php +++ b/website/integrations/mybb/test-system-board-embed.php @@ -17,7 +17,7 @@ $_GET=['fid'=>'13','dune_embed'=>'1'];$_SERVER['REQUEST_URI']='/forumdisplay.php $GLOBALS['dune_system_board_identity']=['systemBoards'=>['organisations'=>[['kind'=>'clan','id'=>'ours','manage'=>true]]]]; $html=$original;dune_system_board_embed($html); check_embed(str_contains($html,'class="dune-board-embedded dune-forum"'),'Embedded body scope missing'); -check_embed(str_contains($html,'/system-board.css?v=dev1'),'Embedded stylesheet missing'); +check_embed(str_contains($html,'/system-board.css?v=dev2'),'Embedded stylesheet missing'); check_embed(str_contains($html,'>Manage board'),'Own-subtree management link missing'); check_embed(str_contains($html,'href="https://forums.dunerealms.com/forumdisplay.php?fid=13"'),'External link did not leave the compact view'); check_embed(str_contains($html,'data-system-board-external'),'Full forum link can be overwritten by embedded navigation'); @@ -27,4 +27,14 @@ dune_system_board_default_collapse(); check_embed($collapsed['cat_50_e']==='display: none;'&&$collapsedimg['cat_50']==='_collapsed','Native initial collapsed state missing'); check_embed($cookies_written['collapsed']==='cat_4|cat_50','Existing native collapse preferences were overwritten'); $mybb->cookies['dune_system_board_default']='1';$cookies_written=[];dune_system_board_default_collapse();check_embed($cookies_written===[],'Native expander preference was reset'); -echo "System board embed: 10 checks passed\n"; +require __DIR__.'/system-board-manage-view.php'; +$manage=dune_render_board_management(['kind'=>'clan','organisation'=>'ours','root'=>12,'parents'=>[['fid'=>12,'name'=>'House council','type'=>'f'],['fid'=>13,'name'=>'Planning & Treasury','type'=>'c']],'postKey'=>'preview-only-not-a-session-key','parent'=>12,'name'=>'','type'=>'f','error'=>'']); +$_GET=['kind'=>'clan','organisation'=>'ours','dune_embed'=>'1'];$_SERVER['REQUEST_URI']='/system-board-manage.php?kind=clan&organisation=ours&dune_embed=1'; +dune_system_board_embed($manage); +check_embed(substr_count($manage,'class="system-board-toolbar"')===1,'Management toolbar was duplicated'); +foreach(['my_post_key','organisation','kind','parent','forum_type','name'] as $field)check_embed(str_contains($manage,'name="'.$field.'"'),'Native management field missing: '.$field); +check_embed(str_contains($manage,'Planning & Treasury'),'Board name was not escaped'); +$unsafe=dune_render_board_management(['kind'=>'clan','organisation'=>'ours','root'=>12,'parents'=>[],'postKey'=>'key','parent'=>12,'name'=>'">','type'=>'c','error'=>'Untrusted error']); +check_embed(!str_contains($unsafe,'')&&!str_contains($unsafe,'Untrusted error'),'Form or error content was rendered as HTML'); +if(in_array('--render',$argv??[],true))echo $manage; +else echo "System board embed and management checks passed\n";