|
From: Meik S. <acy...@us...> - 2007-09-22 19:18:11
|
Update of /cvsroot/phpbb/phpBB2/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27284/includes Modified Files: cache.php functions.php session.php template.php Log Message: new hook system (do not get it confused with events or plugins please) - introducing two new hookable functions too Index: template.php =================================================================== RCS file: /cvsroot/phpbb/phpBB2/includes/template.php,v retrieving revision 1.112 retrieving revision 1.113 diff -C2 -d -r1.112 -r1.113 *** template.php 17 Aug 2007 21:29:20 -0000 1.112 --- template.php 22 Sep 2007 19:18:13 -0000 1.113 *************** *** 148,152 **** function display($handle, $include_once = true) { ! global $user; if (defined('IN_ERROR_HANDLER')) --- 148,161 ---- function display($handle, $include_once = true) { ! global $user, $phpbb_hook; ! ! // To let users change the complete templated page (all variables available) ! if ($phpbb_hook->call_hook(array(get_class(), __FUNCTION__), $handle, $include_once)) ! { ! if ($phpbb_hook->hook_return(array(get_class(), __FUNCTION__))) ! { ! return $phpbb_hook->hook_return_result(array(get_class(), __FUNCTION__)); ! } ! } if (defined('IN_ERROR_HANDLER')) Index: functions.php =================================================================== RCS file: /cvsroot/phpbb/phpBB2/includes/functions.php,v retrieving revision 1.624 retrieving revision 1.625 diff -C2 -d -r1.624 -r1.625 *** functions.php 22 Sep 2007 18:29:39 -0000 1.624 --- functions.php 22 Sep 2007 19:18:13 -0000 1.625 *************** *** 1565,1569 **** /** ! * Append session id to url * * @param string $url The url the session id needs to be appended to (can have params) --- 1565,1570 ---- /** ! * Append session id to url. ! * This function supports hooks. * * @param string $url The url the session id needs to be appended to (can have params) *************** *** 1580,1594 **** * </code> * - * Ability to use own function <code>append_sid_phpbb_hook</code> as a hook. It is called in favor of this function. */ function append_sid($url, $params = false, $is_amp = true, $session_id = false) { ! global $_SID, $_EXTRA_URL; // Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropiatly. // They could mimick most of what is within this function ! if (function_exists('append_sid_phpbb_hook')) { ! return append_sid_phpbb_hook($url, $params, $is_amp, $session_id); } --- 1581,1597 ---- * </code> * */ function append_sid($url, $params = false, $is_amp = true, $session_id = false) { ! global $_SID, $_EXTRA_URL, $phpbb_hook; // Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropiatly. // They could mimick most of what is within this function ! if ($phpbb_hook->call_hook(__FUNCTION__, $url, $params, $is_amp, $session_id)) { ! if ($phpbb_hook->hook_return(__FUNCTION__)) ! { ! return $phpbb_hook->hook_return_result(__FUNCTION__); ! } } *************** *** 4334,4346 **** /** ! * Handler for exit calls in phpBB * ! * Ability to use own function <code>exit_handler_phpbb_hook</code> as a hook. It is called in favor of this function. */ function exit_handler() { ! if (function_exists('exit_handler_phpbb_hook')) { ! return exit_handler_phpbb_hook(); } --- 4337,4355 ---- /** ! * Handler for exit calls in phpBB. ! * This function supports hooks. * ! * Note: This function is called after the template has been outputted. */ function exit_handler() { ! global $phpbb_hook; ! ! if ($phpbb_hook->call_hook(__FUNCTION__)) { ! if ($phpbb_hook->hook_return(__FUNCTION__)) ! { ! return $phpbb_hook->hook_return_result(__FUNCTION__); ! } } *************** *** 4349,4352 **** --- 4358,4380 ---- /** + * Handler for init calls in phpBB. This function is called in user::setup(); + * This function supports hooks. + */ + function phpbb_user_session_handler() + { + global $phpbb_hook; + + if ($phpbb_hook->call_hook(__FUNCTION__)) + { + if ($phpbb_hook->hook_return(__FUNCTION__)) + { + return $phpbb_hook->hook_return_result(__FUNCTION__); + } + } + + return; + } + + /** * @package phpBB3 */ Index: session.php =================================================================== RCS file: /cvsroot/phpbb/phpBB2/includes/session.php,v retrieving revision 1.310 retrieving revision 1.311 diff -C2 -d -r1.310 -r1.311 *** session.php 22 Sep 2007 18:21:58 -0000 1.310 --- session.php 22 Sep 2007 19:18:13 -0000 1.311 *************** *** 1519,1522 **** --- 1519,1526 ---- } + // Call phpbb_user_session_handler() in case external application want to "bend" some variables or replace classes... + // After calling it we continue script execution... + phpbb_user_session_handler(); + // If this function got called from the error handler we are finished here. if (defined('IN_ERROR_HANDLER')) Index: cache.php =================================================================== RCS file: /cvsroot/phpbb/phpBB2/includes/cache.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** cache.php 9 Jun 2007 11:06:22 -0000 1.10 --- cache.php 22 Sep 2007 19:18:13 -0000 1.11 *************** *** 404,407 **** --- 404,439 ---- return $usernames; } + + /** + * Obtain hooks... + */ + function obtain_hooks() + { + global $phpbb_root_path, $phpEx; + + if (($hook_files = $this->get('_hooks')) === false) + { + $hook_files = array(); + + // Now search in acp and mods folder for permissions_ files. + $dh = @opendir($phpbb_root_path . 'includes/hooks/'); + + if ($dh) + { + while (($file = readdir($dh)) !== false) + { + if (strpos($file, 'hook_') === 0 && substr($file, -(strlen($phpEx) + 1)) === '.' . $phpEx) + { + $hook_files[] = substr($file, 0, -(strlen($phpEx) + 1)); + } + } + closedir($dh); + } + + $this->put('_hooks', $hook_files); + } + + return $hook_files; + } } |