design: compact illustrated internal boards with native controls

This commit is contained in:
unimatrixgit 2026-11-16 19:46:07 +01:00
commit f1cd1a5c6c
7 changed files with 122 additions and 11 deletions

View file

@ -52,3 +52,7 @@ Ordinary SSH as unimatrix works; sudo -n currently requires interactive authenti
## Deleted organisations
On clan deletion, current central membership grants disappear. Preserve forum history and let native MyBB autoprune handle eventual post cleanup. No custom clan/forum deletion or cleanup worker is required (user decision, 16 November 2026).
## 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.

View file

@ -7,6 +7,7 @@ if(is_file(MYBB_ROOT.'system-board-membership.php')){
require_once MYBB_ROOT.'system-board-policy.php';
require_once MYBB_ROOT.'system-board-embed.php';
$plugins->add_hook('pre_output_page','dune_system_board_embed',20);
$plugins->add_hook('index_start','dune_system_board_default_collapse');
}
$plugins->add_hook('global_intermediate','dune_central_account_permissions');
$plugins->add_hook('usercp_menu','dune_central_account_menu',1);

View file

@ -48,9 +48,14 @@ try {
foreach ($input['organisations'] as $org) {
$board = make_board($org['kind'], $org['id'], $org['name'], (int)($org['kind']==='clan' ? $clans['fid'] : $companies['fid']), 'f');
foreach (['member_gid','leader_gid'] as $field) {
if ((int)$board[$field] > 0) continue;
$role=$field==='leader_gid'?'leaders':'members';
$title=my_substr(($org['kind']==='clan'?'Clan':'Company').' '.$role.' · '.$org['name'],0,45);
if ((int)$board[$field] > 0) {
$db->update_query('usergroups',['title'=>$db->escape_string($title)],'gid='.(int)$board[$field]);
continue;
}
$group = $groups[2]; unset($group['gid']);
$group['title'] = 'System Board '.substr(hash('sha256', $org['kind'].':'.$org['id']),0,12).' '.$field;
$group['title'] = $title;
$group['cancp'] = 0; $group['issupermod'] = 0; $group['canmodcp'] = $field==='leader_gid' ? 1 : 0;
foreach ($group as $key=>$value) if (is_string($value)) $group[$key]=$db->escape_string($value);
$gid = (int)$db->insert_query('usergroups', $group);

View file

@ -1,25 +1,38 @@
<?php
function dune_system_board_embed(&$page): void {
global $db;
if (basename($_SERVER['SCRIPT_NAME'] ?? '')==='index.php' && $db->table_exists('dune_system_boards')) {
$root=$db->fetch_array($db->simple_select('dune_system_boards','fid',"kind='system' AND organisation_id='root'"));
$fid=(int)($root['fid'] ?? 0);
if ($fid>0) $page=str_replace('</body>','<script>(()=>{const key="system-boards-expanded",body=document.getElementById("cat_'.$fid.'_e"),button=document.getElementById("cat_'.$fid.'_img");if(!body||!button)return;try{if(localStorage.getItem(key)!=="1"){body.style.display="none";button.src=button.src.replace("collapse.png","collapse_collapsed.png");button.alt="+";}button.addEventListener("click",()=>setTimeout(()=>localStorage.setItem(key,body.style.display==="none"?"0":"1"),0));}catch{}})();</script></body>',$page);
}
if (($_GET['dune_embed'] ?? '') !== '1') return;
$fid=(int)($_GET['fid'] ?? 0); $identity=$GLOBALS['dune_system_board_identity'] ?? [];
$boards=dune_system_board_registry(); $parents=[];
$query=$db->simple_select('forums','fid,pid'); while($row=$db->fetch_array($query))$parents[(int)$row['fid']]=(int)$row['pid'];
$manage='';
foreach($identity['systemBoards']['organisations'] ?? [] as $grant){
$board=$boards[($grant['kind'] ?? '').':'.($grant['id'] ?? '')] ?? null;
if(!$board||($grant['manage'] ?? false)!==true||!dune_board_descendant($fid,(int)$board['fid'],$parents))continue;
$href='/system-board-manage.php?kind='.rawurlencode($grant['kind']).'&amp;organisation='.rawurlencode($grant['id']).'&amp;dune_embed=1';
$page=preg_replace('/(<body\b[^>]*>)/i','$1<div class="system-board-tools"><a href="'.$href.'">Manage board · Add forum or category</a></div>',$page,1);
$manage='<a href="'.$href.'">Manage board</a>';
}
$style = '<style>html,body{min-height:0!important;height:auto!important}#header,#footer,.navigation,.breadcrumb,.dune-shared-header,.dune-shared-footer{display:none!important}#container,#content{width:auto!important;max-width:none!important;margin:0!important;padding:14px!important}.system-board-tools{margin:12px 0}</style>';
$page=preg_replace_callback('/<body\b([^>]*)>/i',function($match){$attributes=$match[1];if(str_contains($attributes,'class="'))$attributes=str_replace('class="','class="dune-board-embedded ',$attributes);else $attributes.=' class="dune-board-embedded"';return '<body'.$attributes.'>';},$page,1);
$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='<section class="system-board-toolbar"><div><strong>Internal Boards</strong><small>Private conversations · Your organisation</small></div><nav>'.$manage.'<a href="'.htmlspecialchars($outside,ENT_QUOTES|ENT_SUBSTITUTE,'UTF-8').'" target="_blank" rel="noopener" data-system-board-external>Open in Boards ↗</a></nav></section>';
$page=preg_replace('/(<body\b[^>]*>)/i','$1'.$toolbar,$page,1);
$style = '<link rel="stylesheet" href="/system-board.css?v=dev1">';
$script = <<<'JS'
<script>(()=>{const parents=new Set(['https://cp.dunerealms.com','https://clans.dunerealms.com','https://corp.dunerealms.com','https://pol.dunerealms.com']);const send=()=>{const height=Math.ceil(Math.max(document.body.scrollHeight,document.body.getBoundingClientRect().height))+16;if(parent!==window&&height>=100&&height<=200000)for(const origin of parents)parent.postMessage({type:'dune-embed-size',height},origin);};for(const a of document.querySelectorAll('a[href]')){try{const u=new URL(a.href);if(u.origin===location.origin&&!u.pathname.startsWith('/admin/')&&!u.pathname.endsWith('dune-sso.php')){u.searchParams.set('dune_embed','1');a.href=u.href;}}catch{}}for(const f of document.forms){const input=document.createElement('input');input.type='hidden';input.name='dune_embed';input.value='1';f.append(input);try{const u=new URL(f.action);if(u.origin===location.origin){u.searchParams.set('dune_embed','1');f.action=u.href;}}catch{}}window.addEventListener('message',e=>{if(e.source===parent&&parents.has(e.origin)&&e.data?.type==='dune-embed-measure')send();});new ResizeObserver(send).observe(document.body);send();})();</script>
<script>(()=>{const parents=new Set(['https://cp.dunerealms.com','https://clans.dunerealms.com','https://corp.dunerealms.com','https://pol.dunerealms.com']);const send=()=>{const height=Math.ceil(Math.max(document.body.scrollHeight,document.body.getBoundingClientRect().height))+16;if(parent!==window&&height>=100&&height<=200000)for(const origin of parents)parent.postMessage({type:'dune-embed-size',height},origin);};for(const a of document.querySelectorAll('a[href]')){try{const u=new URL(a.href);if(u.origin===location.origin&&!u.pathname.startsWith('/admin/')&&!u.pathname.endsWith('dune-sso.php')&&!a.hasAttribute('data-system-board-external')){u.searchParams.set('dune_embed','1');a.href=u.href;}}catch{}}for(const f of document.forms){const input=document.createElement('input');input.type='hidden';input.name='dune_embed';input.value='1';f.append(input);try{const u=new URL(f.action);if(u.origin===location.origin){u.searchParams.set('dune_embed','1');f.action=u.href;}}catch{}}window.addEventListener('message',e=>{if(e.source===parent&&parents.has(e.origin)&&e.data?.type==='dune-embed-measure')send();});new ResizeObserver(send).observe(document.body);send();})();</script>
JS;
$page = str_replace('</head>', $style.'</head>', $page);
$page = str_replace('</body>', $script.'</body>', $page);
}
// Initialize once, then let MyBB's existing category expander and cookie keep
// the user's preference. No second collapse implementation or local storage.
function dune_system_board_default_collapse(): void {
global $mybb,$db,$collapse,$collapsed,$collapsedimg,$collapsedthead;
if(!empty($mybb->cookies['dune_system_board_default'])||!$db->table_exists('dune_system_boards'))return;
$root=$db->fetch_array($db->simple_select('dune_system_boards','fid',"kind='system' AND organisation_id='root'"));
if(empty($root['fid']))return;$key='cat_'.(int)$root['fid'];
$collapse=array_values(array_unique(array_merge($collapse??[],[$key])));
$collapsed[$key.'_e']='display: none;';$collapsedimg[$key]='_collapsed';$collapsedthead[$key]=' thead_collapsed';
my_setcookie('collapsed',implode('|',$collapse));my_setcookie('dune_system_board_default','1');
}

View file

@ -0,0 +1,58 @@
/* Internal CP view only. The public forum keeps its original theme. */
html:has(body.dune-board-embedded){height:auto!important;min-height:0!important;background:#102b25}
body.dune-board-embedded{--board-ink:#e1e8dd;--board-muted:#b2c5b8;--board-gold:#e1c37f;--board-line:#496355;box-sizing:border-box!important;min-width:0!important;min-height:0!important;height:auto!important;margin:0!important;padding:16px!important;color:var(--board-ink)!important;font:14px/1.6 system-ui,sans-serif!important;background:linear-gradient(125deg,#102d27ed,#142d28f5),url('https://www.dunerealms.com/assets/political-imperial-chamber-v1.png') center top/cover!important}
body.dune-board-embedded *{box-sizing:border-box}
body.dune-board-embedded :is(#header,#footer,#copyright,.navigation,.breadcrumb,.dune-site-header,.dune-memorial,.dune-shared-header,.dune-shared-footer){display:none!important}
body.dune-board-embedded :is(#container,#content,.wrapper){width:100%!important;min-width:0!important;max-width:100%!important;height:auto!important;min-height:0!important;padding:0!important;margin:0!important;background:transparent!important;border:0!important;box-shadow:none!important;overflow-wrap:anywhere}
body.dune-board-embedded .system-board-toolbar{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px;margin:0 0 18px;padding:14px 16px;border:1px solid #b49b57;border-radius:10px;background:linear-gradient(110deg,#1f4638ed,#142e29e6),url('https://www.dunerealms.com/assets/political-imperial-chamber-v1.png') center/cover;box-shadow:0 6px 22px #0002}
body.dune-board-embedded .system-board-toolbar strong{color:var(--board-gold);font-size:16px;letter-spacing:.02em}
body.dune-board-embedded .system-board-toolbar small{display:block;color:var(--board-muted);font-size:12px}
body.dune-board-embedded .system-board-toolbar nav{display:flex;flex-wrap:wrap;gap:8px}
body.dune-board-embedded :is(a, .largetext a){color:var(--board-gold)!important}
body.dune-board-embedded :is(a.button,button,input.button,input[type=submit],.postbit_buttons a,.system-board-toolbar a){display:inline-flex;align-items:center;justify-content:center;gap:6px;max-width:100%;min-height:36px;padding:7px 12px!important;border:1px solid #8e864d!important;border-radius:7px!important;background:#234838!important;color:#f2dda4!important;font:600 13px/1.4 system-ui,sans-serif!important;text-decoration:none!important;white-space:normal!important;vertical-align:middle}
body.dune-board-embedded :is(button,input[type=submit],.system-board-toolbar a):hover{background:#315c46!important;border-color:#ddc079!important}
body.dune-board-embedded :is(input,select,textarea){min-width:0!important;max-width:100%!important;border:1px solid #4a6c5b!important;border-radius:6px!important;background:#102c25!important;color:var(--board-ink)!important;padding:7px!important;font:inherit!important}
body.dune-board-embedded textarea{width:100%!important;resize:vertical}
body.dune-board-embedded :is(table.tborder,table.tborder>tbody){max-width:100%!important}
body.dune-board-embedded table.tborder{width:100%!important;table-layout:auto;border:1px solid var(--board-line)!important;border-spacing:0!important;border-radius:9px!important;overflow:hidden;background:#15352c!important;margin:12px 0!important}
body.dune-board-embedded table.tborder :is(td,th){min-width:0!important;overflow-wrap:anywhere;padding:10px!important;border-color:#385345!important;color:var(--board-ink)!important}
body.dune-board-embedded :is(.thead,.tcat){background:#23483a!important;color:#f2dda4!important;font-size:13px!important}
body.dune-board-embedded :is(.trow1,.trow2){background:#16362c!important;color:var(--board-ink)!important}
body.dune-board-embedded :is(.tfoot,.trow_sep){background:#1d4032!important;color:var(--board-muted)!important}
body.dune-board-embedded [nowrap]{white-space:normal!important}
body.dune-board-embedded :is(.float_left,.float_right){max-width:100%;margin-bottom:8px}
body.dune-board-embedded :is(.pagination,.multipage){max-width:100%;white-space:normal!important}
body.dune-board-embedded .post{width:100%!important;min-width:0!important;margin:14px 0!important;border:1px solid var(--board-line)!important;border-radius:9px!important;background:#14342b!important;overflow:hidden}
body.dune-board-embedded .post .post_author{display:flex!important;align-items:center;gap:12px;flex-wrap:wrap;float:none!important;width:100%!important;min-width:0!important;max-width:100%!important;padding:12px 14px!important;border:0!important;border-bottom:1px solid #506d52!important;background:linear-gradient(110deg,#234b3d,#19372f)!important}
body.dune-board-embedded .post .post_author::before,body.dune-board-embedded .post .post_author::after{display:none!important}
body.dune-board-embedded .post .author_information{float:none!important;width:auto!important;min-width:0!important;flex:1;padding:0!important;margin:0!important;font-size:13px!important}
body.dune-board-embedded .post .author_information .largetext{font-size:14px!important;line-height:1.4!important}
body.dune-board-embedded :is(.author_statistics,.dune-author-recognition,.dune-author-bio,.dune-clan-emblem,.dune-author-clan,.signature,.dune-managed-signature-panel){display:none!important}
body.dune-board-embedded .author_information :is(.smalltext,img,br){display:none!important}
body.dune-board-embedded .post .author_avatar{float:none!important;flex:0 0 32px;width:32px!important;height:32px!important;margin:0!important;overflow:hidden;border-radius:6px}
body.dune-board-embedded .author_avatar img{display:block;width:32px!important;height:32px!important;max-width:32px!important;padding:0!important;border:0!important}
body.dune-board-embedded .author_avatar span[role=img]{transform:scale(.5);transform-origin:top left}
body.dune-board-embedded .post :is(.post_content,.post_body,.post_head){width:100%!important;min-width:0!important;max-width:100%!important;float:none!important}
body.dune-board-embedded .post .post_content{padding:14px!important;background:#14342b!important}
body.dune-board-embedded .post_body{overflow-wrap:anywhere;line-height:1.75!important;color:var(--board-ink)!important}
body.dune-board-embedded .post_body :is(img,video,iframe){max-width:100%!important;height:auto}
body.dune-board-embedded .post_body pre{max-width:100%;overflow:auto;white-space:pre-wrap}
body.dune-board-embedded .post_controls{display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap;padding:9px!important;background:#1a3b2e!important}
body.dune-board-embedded .postbit_buttons{display:flex;gap:4px;flex-wrap:wrap;float:none!important}
body.dune-board-embedded .postbit_buttons a{margin:0!important}
body.dune-board-embedded :is(.sceditor-container,.sceditor-container iframe,.sceditor-container textarea){width:100%!important;max-width:100%!important;min-width:0!important}
body.dune-board-embedded .sceditor-toolbar{white-space:normal!important}
@media(max-width:760px){
body.dune-board-embedded{padding:10px!important}
body.dune-board-embedded .system-board-toolbar{padding:12px;align-items:flex-start}
body.dune-board-embedded table.tborder :is(td,th){padding:7px!important;font-size:12px!important}
body.dune-board-embedded .post .post_author{padding:10px!important}
body.dune-board-embedded :is(.float_left,.float_right){float:none!important;display:flex;gap:6px;flex-wrap:wrap}
body.dune-board-embedded .thead .float_right{margin-top:8px}
body.dune-board-embedded :is(#quickreply_e,form table.tborder)>tbody>tr{display:flex;flex-wrap:wrap}
body.dune-board-embedded :is(#quickreply_e,form table.tborder)>tbody>tr>td{width:100%!important}
}
body.dune-board-embedded .dune-author-identity{display:contents!important}
body.dune-board-embedded label{color:var(--board-ink)!important}

View file

@ -0,0 +1,30 @@
<?php
// Isolated output checks: no native database or production sessions.
require __DIR__.'/system-board-policy.php';
require __DIR__.'/system-board-embed.php';
function dune_system_board_registry(){return ['clan:ours'=>['fid'=>12]];}
function my_setcookie($key,$value){$GLOBALS['cookies_written'][$key]=$value;}
class BoardFixtureDatabase {
function table_exists($name){return true;}
function simple_select($table,...$unused){return (object)['rows'=>$table==='forums'?[['fid'=>12,'pid'=>0],['fid'=>13,'pid'=>12]]:[['fid'=>50]],'index'=>0];}
function fetch_array($query){return $query->rows[$query->index++]??false;}
}
$db=new BoardFixtureDatabase();
function check_embed($ok,$message){if(!$ok)throw new RuntimeException($message);}
$original='<!doctype html><html><head></head><body class="dune-forum"><main>Thread content</main></body></html>';
$_GET=[];$html=$original;dune_system_board_embed($html);check_embed($html===$original,'Public forum output was changed');
$_GET=['fid'=>'13','dune_embed'=>'1'];$_SERVER['REQUEST_URI']='/forumdisplay.php?fid=13&dune_embed=1';
$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,'>Manage board</a>'),'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');
$_GET['fid']='99';$html=$original;dune_system_board_embed($html);check_embed(!str_contains($html,'>Manage board</a>'),'Management link escaped own subtree');
$mybb=(object)['cookies'=>[]];$collapse=['cat_4'];$collapsed=$collapsedimg=$collapsedthead=[];$cookies_written=[];
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";

View file

@ -5,7 +5,7 @@ $_SERVER['SCRIPT_NAME']='/dune-sso.php'; $_SERVER['REQUEST_METHOD']='GET';
$_SERVER['REMOTE_ADDR']='127.0.0.1'; $_SERVER['HTTP_HOST']='forums.dunerealms.com';
define('IN_MYBB',1); chdir('/home/dunerealms/apps/integrations/mybb');
ob_start(); require 'global.php'; ob_end_clean();
require_once __DIR__.'/system-board-membership.php';
if(!function_exists('dune_system_board_registry'))require_once __DIR__.'/system-board-membership.php';
$boards=dune_system_board_registry(); $count=0;
if (!$boards) throw new RuntimeException('No organisation boards were provisioned');
foreach ($boards as $key=>$board) {