Index: includes/module.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/module.inc,v retrieving revision 1.207 diff -u -p -r1.207 module.inc --- includes/module.inc 24 Nov 2010 16:47:44 -0000 1.207 +++ includes/module.inc 25 Nov 2010 23:30:27 -0000 @@ -596,6 +596,66 @@ function module_hook($module, $hook) { } /** + * Finds the file path of a hook implementation. + */ +function module_hook_implementation($module, $hook) { + $includes = array(); + $function = $module . '_' . $hook; + $hook_info = module_hook_info(); + $module_path = drupal_get_path('module', $module); + // First, look in a file for the hook's group. + if (isset($hook_info[$hook]['group'])) { + $includes[$module . '.' . $hook_info[$hook]['group'] . '.inc'] = TRUE; + } + // Add other potential locations for the hook. + if (function_exists('system_get_info')) { + $info = system_get_info('module', $module); + foreach ($info['files'] as $file) { + if (pathinfo($file, PATHINFO_EXTENSION) == 'inc') { + $includes[$file] = TRUE; + } + } + } + $includes = array_keys($includes); + while (!($exists = function_exists($function)) && ($file = array_shift($includes))) { + $path = DRUPAL_ROOT . '/' . $module_path . '/' . $file; + if (is_file($path)) { + require_once $path; + } + } + if ($exists) { + $function_meta = new ReflectionFunction($function); + // @todo: Make this string replacement more accurate. + return str_replace(DRUPAL_ROOT . '/', '', $function_meta->getFileName()); + } + + return FALSE; +} + +/** * Determine which modules are implementing a hook. * * @param $hook