Skip to content

Commit

Permalink
Merge pull request #650 from emanuele45/admin_hooks
Browse files Browse the repository at this point in the history
Fix for integration hooks page
  • Loading branch information
emanuele45 committed Jul 14, 2013
2 parents 663bddf + e90e14c commit e3e87b5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 3 additions & 3 deletions sources/admin/ManageAddonSettings.php
Expand Up @@ -383,16 +383,16 @@ function list_getIntegrationHooksCount()
if (isset($_GET['filter']))
$context['filter'] = $_GET['filter'];

return get_integration_hooks_count($context['filter']);
return integration_hooks_count($context['filter']);
}

/**
* Callback for createList().
*
* @return array
*/
function list_getIntegrationHooks()
function list_getIntegrationHooks($start, $per_page, $sort)
{
return get_integration_hooks();
return list_integration_hooks_data($start, $per_page, $sort);
}
}
20 changes: 17 additions & 3 deletions sources/subs/ManageAddonSettings.subs.php
Expand Up @@ -70,7 +70,7 @@ function list_integration_hooks_data($start, $per_page, $sort)
if (is_file($file['dir'] . '/' . $file['name']) && substr($file['name'], -4) === '.php')
{
$fp = fopen($file['dir'] . '/' . $file['name'], 'rb');
$fc = fread($fp, filesize($file['dir'] . '/' . $file['name']));
$fc = strtr(fread($fp, filesize($file['dir'] . '/' . $file['name'])), array("\r" => '', "\n" => ''));
fclose($fp);

foreach ($temp_hooks as $hook => $functions)
Expand All @@ -81,10 +81,14 @@ function list_integration_hooks_data($start, $per_page, $sort)
if (strpos($hook_name, '::') !== false)
{
$function = explode('::', $hook_name);
$class = $function[0];
$function = $function[1];
}
else
{
$class = '';
$function = $hook_name;
}
$function = explode(':', $function);
$function = $function[0];

Expand All @@ -95,11 +99,21 @@ function list_integration_hooks_data($start, $per_page, $sort)
$temp_data['include'][basename($function)] = array('hook' => $hook, 'function' => $function);
unset($temp_hooks[$hook][$function_o]);
}
elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($function) . '(') !== false)
// Procedural functions as easy
elseif (empty($class) && strpos(str_replace(' (', '(', $fc), 'function ' . trim($function) . '(') !== false)
{
$hook_status[$hook][$hook_name]['exists'] = true;
$hook_status[$hook][$hook_name]['in_file'] = $file['name'];
// I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrate_*_include of that file can be disabled too)
$temp_data['function'][$file['name']][] = $function_o;
unset($temp_hooks[$hook][$function_o]);
}
// OOP a bit more difficult
elseif (!empty($class) && preg_match('~class\s*' . preg_quote(trim($class)) . '.*function\s*' . preg_quote(trim($function)) . '\s*\(~i', $fc) != 0)
{
$hook_status[$hook][$hook_name]['exists'] = true;
$hook_status[$hook][$hook_name]['in_file'] = $file['name'];
// I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrare_*_include of that file can be disabled too)
// I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrate_*_include of that file can be disabled too)
$temp_data['function'][$file['name']][] = $function_o;
unset($temp_hooks[$hook][$function_o]);
}
Expand Down

0 comments on commit e3e87b5

Please sign in to comment.