Scripts that do not want buffered output just define NO_OUTPUT_BUFFERING before including config.php.
The fileserving code now checks if the headers are already sent which detects misconfigured servers.
At the same time this commit introduces a standardised dialogue YUI module to enrol and implements it across the board.
This commit also addresses MDL-23292 and MDL-23319.