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='
.'.png').')
COMMUNITY FORUMS
'.dune_sections_escape(strip_tags($panel['description'])).'
| Forum | Threads | Posts | Last post | |
|---|---|---|---|---|
No visible forums in this section.
'; $html.='