MyBB Community Forums

Full Version: ACP menu not sorted
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Found that the submenu creation in ACP is designed for plugin devs to adding own menu entry's in the spaces between of exist entry's. Good to see at the choosed numbers for the core menu entrys like here:
https://crossreference.mybb.de/admin/modules/tools/module_meta.php.source.html

But the add_menu_items function missed to sort them before generating the output for the sidemenu:
https://crossreference.mybb.de/nav.html?admin/inc/class_page.php.source.html#l1106


This can easy be fixed by adding a ksort befor the foreach loop.
function add_menu_items($items, $active)
{
	global $run_module;

	ksort($items, SORT_NUMERIC);
	$this->_contents = "<ul class=\"menu\">";
	foreach($items as $item)
	{
		if(!check_admin_permissions(array("module" => $run_module, "action" => $item['id']), false))
		{
			continue;
		}

		$class = "";
		if($item['id'] == $active)
		{
			$class = "active";
		}
		$item['link'] = htmlspecialchars_uni($item['link']);
		$this->_contents .= "<li class=\"{$class}\"><a href=\"{$item['link']}\">{$item['title']}</a></li>\n";
	}
	$this->_contents .= "</ul>";
}

And the menus can be now better sorted by plug devs. This give the ability for a better overview and readability.
This is not a bug, or at least, not intrinsically. You can ksort $sub_menu in your plugin's function and obtain the same result. Personally, I would not patch this in order to give plugin developers more flexibility.