forked from unimatrix/web
Merge pull request 'Match board administration to compact CP style and restore index collapse' (#353) from release/board-management-polish into main
This commit is contained in:
commit
791de13743
9 changed files with 165 additions and 10 deletions
|
|
@ -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_<fid>_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.
|
||||
|
|
|
|||
57
website/integrations/mybb/inc/plugins/dune_sections.php
Normal file
57
website/integrations/mybb/inc/plugins/dune_sections.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
if(!defined('IN_MYBB'))die('Direct access denied');
|
||||
$plugins->add_hook('index_end','dune_sections_index');
|
||||
$plugins->add_hook('pre_output_page','dune_sections_style');
|
||||
function dune_sections_style($html){return str_replace('</head>','<link rel="stylesheet" href="/dune-sections.css"></head>',$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)=>'<a href="'.dune_sections_escape(get_forum_link($f['fid'])).'">'.dune_sections_escape($f['name']).'</a>',$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='<div class="expcolimage"><img src="'.dune_sections_escape($theme['imgdir'].'/collapse'.($collapsedimg[$key]??'').'.png').'" id="'.$key.'_img" class="expander" alt="'.$label.'" title="'.$label.'"></div>';}
|
||||
$html.='<section class="dune-board-category"><div class="dune-board-heading'.($system?($collapsedthead[$key]??''):'').'">'.$toggle.'<p>COMMUNITY FORUMS</p><h2>'.dune_sections_escape($root['name']).'</h2></div>';
|
||||
if($system)$html.='<div id="'.$key.'_e" style="'.($collapsed[$key.'_e']??'').'">';
|
||||
$html.='<div class="dune-board-children"><span>Subcategories</span>'.dune_sections_links($panels).'</div><div class="dune-board-panels">';
|
||||
foreach($panels as$panel){
|
||||
$children=dune_sections_children((int)$panel['fid'],$all);
|
||||
$html.='<section class="dune-board-panel"><div class="dune-board-panel-title"><img src="https://www.dunerealms.com/assets/nav-boards-v2.webp" alt="" width="44" height="44"><div><h3><a href="'.dune_sections_escape(get_forum_link($panel['fid'])).'">'.dune_sections_escape($panel['name']).'</a></h3><p>'.dune_sections_escape(strip_tags($panel['description'])).'</p></div><span>SUBCATEGORY</span></div>';
|
||||
$previous=$mybb->settings['hideprivateforums'];$mybb->settings['hideprivateforums']=1;
|
||||
try{
|
||||
if($children){$html.='<div class="dune-board-children"><span>Forums</span>'.dune_sections_links($children).'</div>';$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.='<table class="tborder dune-board-forums"><thead><tr><th colspan="2">Forum</th><th>Threads</th><th>Posts</th><th>Last post</th></tr></thead><tbody>'.$rows['forum_list'].'</tbody></table>';
|
||||
else $html.='<p class="dune-board-empty">No visible forums in this section.</p>';
|
||||
$html.='</section>';
|
||||
}
|
||||
$html.='</div>'.($system?'</div>':'').'</section>';
|
||||
}
|
||||
if($html)$forums=$html;
|
||||
}
|
||||
|
||||
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -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='<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">';
|
||||
if(!str_contains($page,'data-system-board-toolbar'))$page=preg_replace('/(<body\b[^>]*>)/i','$1'.$toolbar,$page,1);
|
||||
$style = '<link rel="stylesheet" href="/system-board.css?v=dev2">';
|
||||
$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')&&!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;
|
||||
|
|
|
|||
23
website/integrations/mybb/system-board-manage-view.php
Normal file
23
website/integrations/mybb/system-board-manage-view.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
function dune_render_board_management(array $view): string {
|
||||
$h=fn($value)=>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.='<option value="'.(int)$forum['fid'].'"'.((int)$view['parent']===(int)$forum['fid']?' selected':'').'>'.$h($name).'</option>';
|
||||
$list.='<li><span>'.$h($name).'</span><small>'.($forum['type']==='c'?'Category':'Forum').'</small></li>';
|
||||
}
|
||||
$error=$view['error']!==''?'<div class="board-form-alert" role="alert">'.$h($view['error']).'</div>':'';
|
||||
$type=$view['type']==='c'?'c':'f';
|
||||
return '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Manage your board</title><link rel="stylesheet" href="/dune-theme.css"></head><body class="dune-forum">'
|
||||
.'<section class="system-board-toolbar" data-system-board-toolbar><div><strong>Board administration</strong><small>'.$kind.' workspace</small></div><nav><a href="'.$back.'">Back to board</a><a data-system-board-external href="https://forums.dunerealms.com/forumdisplay.php?fid='.(int)$view['root'].'" target="_blank" rel="noopener">Open in Boards ↗</a></nav></section>'
|
||||
.'<main class="board-management"><header class="board-management-hero"><img src="https://www.dunerealms.com/assets/nav-boards-v2.webp" width="72" height="72" alt=""><div><small>YOUR ORGANISATION · YOUR CONVERSATIONS</small><h1>Manage your board</h1><p>Create a space for your people. Access and moderation follow your organisation.</p></div></header>'
|
||||
.'<div class="board-management-grid"><section class="board-management-card"><h2>Create a new space</h2><p class="board-form-intro">Choose its place, type and name.</p>'.$error
|
||||
.'<form method="post" class="board-management-form"><input type="hidden" name="my_post_key" value="'.$h($view['postKey']).'"><input type="hidden" name="kind" value="'.$h($view['kind']).'"><input type="hidden" name="organisation" value="'.$h($view['organisation']).'">'
|
||||
.'<div class="board-form-fields"><label for="board-parent">Parent board<select id="board-parent" name="parent" required aria-describedby="board-parent-help">'.$options.'</select><small id="board-parent-help">The space will appear inside this board or category.</small></label>'
|
||||
.'<label for="board-type">Space type<select id="board-type" name="forum_type" required><option value="f"'.($type==='f'?' selected':'').'>Discussion forum</option><option value="c"'.($type==='c'?' selected':'').'>Category</option></select><small>Start conversations, or group related forums.</small></label>'
|
||||
.'<label for="board-name" class="board-form-full">Name<input id="board-name" name="name" maxlength="70" required value="'.$h($view['name']).'" placeholder="'.($kind==='Clan'?'House council':'Trade desk').'" aria-describedby="board-name-help"><small id="board-name-help">A clear name, up to 70 characters.</small></label></div>'
|
||||
.'<div class="board-form-actions"><button type="submit" class="board-form-primary">Create board</button><a href="'.$back.'" class="board-form-cancel">Cancel</a></div></form></section>'
|
||||
.'<aside class="board-management-guide"><section class="board-management-card"><h2>Choose the right space</h2><div class="board-space-tip"><strong>Discussion forum</strong><p>A place for topics, replies and shared decisions.</p></div><div class="board-space-tip"><strong>Category</strong><p>A section that groups related forums together.</p></div></section><section class="board-management-card"><h2>Your board structure</h2><ul class="board-management-tree">'.$list.'</ul><p class="board-inherited-note">Member access and leadership moderation are inherited automatically.</p></section></aside></div></main></body></html>';
|
||||
}
|
||||
|
|
@ -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 '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Manage your board</title><link rel="stylesheet" href="/dune-theme.css"></head><body><main style="max-width:760px;margin:24px auto;padding:24px"><h1>Manage your board</h1><p>Create a forum or category inside your organisation. Membership and moderation are inherited.</p>';
|
||||
if ($error) echo '<p role="alert">'.$h($error).'</p>';
|
||||
echo '<form method="post"><input type="hidden" name="my_post_key" value="'.$h($mybb->post_code).'"><input type="hidden" name="kind" value="'.$h($kind).'"><input type="hidden" name="organisation" value="'.$h($id).'"><label>Parent <select name="parent">';
|
||||
foreach ($forums as $fid=>$forum) if (!empty($forum['active']) && dune_board_descendant($fid,$root,$parents)) echo '<option value="'.$fid.'">'.$h($forum['name']).'</option>';
|
||||
echo '</select></label><p><label>Name <input name="name" maxlength="70" required></label></p><p><label>Type <select name="forum_type"><option value="f">Discussion forum</option><option value="c">Category</option></select></label></p><button type="submit">Create board</button></form><p><a href="/forumdisplay.php?fid='.$root.'&dune_embed=1">Back to board</a></p></main></body></html>';
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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)}
|
||||
}
|
||||
|
|
|
|||
25
website/integrations/mybb/test-system-board-category.php
Normal file
25
website/integrations/mybb/test-system-board-category.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
define('IN_MYBB',1);
|
||||
class CategoryFixturePlugins {function add_hook(...$unused){}}
|
||||
$plugins=new CategoryFixturePlugins();
|
||||
require __DIR__.'/inc/plugins/dune_sections.php';
|
||||
class CategoryFixtureCache {function read($key){return [
|
||||
1=>['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'=>'<tr><td>Visible native rows</td></tr>'];}
|
||||
$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";
|
||||
|
|
@ -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</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');
|
||||
|
|
@ -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'=>'"><script>unsafe</script>','type'=>'c','error'=>'<b>Untrusted error</b>']);
|
||||
check_embed(!str_contains($unsafe,'<script>unsafe</script>')&&!str_contains($unsafe,'<b>Untrusted error</b>'),'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";
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff