I want to enhance build navigation so that it can take an optional $cm object parameter, and if this is passed in, then automatically build the 'Forums' and 'General Developer Forum' (for example) navigation links.
This requires that $cm was obtained using get_coursemodule_from_instance or get_coursemodule_from_id functions, so the $cm->modname and $cm->name fields are present. If they are missing, build_navigation will get them at the cost of two more DB queries, and print a developer debug message.
The attached patch implements the improvements in build_navigation. I would like to check this into Moodle 1.9 (I need it to make some OU-internal customisation easier), but leave updating all the callers until Moodle 2.0.