Further to my entry last month about a phpBB Hook to disable the post queue for certain users, I’ve written a really quick one to enable phpBB’s debugging mode for founder users. Debug mode is usually enabled by using the constants DEBUG and DEBUG_EXTRA in the configuration file but these can be defined anywhere. The only downside debugging information will only be available after the hook is included, however this is sufficient to get the page generation time, memory usage etc. in the footer which is what I was after.
includes/hooks/hook_enable-debug-for-founders.php
<?php
/**
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* This hook enables the debug mode for founders
*/
function hook_enable_debug_for_founders(&$hook)
{
global $user;
if ($user->data['user_type'] == USER_FOUNDER)
{
// Be careful when defining the constants
if (!defined('DEBUG'))
{
define('DEBUG', true);
}
if (!defined('DEBUG_EXTRA'))
{
define('DEBUG_EXTRA', true);
}
}
}
$phpbb_hook->register('phpbb_user_session_handler', 'hook_enable_debug_for_founders');