From: Janusz Dobrowolski Date: Tue, 6 Oct 2015 07:28:40 +0000 (+0200) Subject: Fixed deactive_extension hook execution on extension deactivation. X-Git-Tag: 2.3-final~42 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=8a2ac7536a58c7860cbebba4f786f51f761ac2bf Fixed deactive_extension hook execution on extension deactivation. --- diff --git a/admin/inst_module.php b/admin/inst_module.php index 77a16cbd..437c3264 100644 --- a/admin/inst_module.php +++ b/admin/inst_module.php @@ -211,12 +211,10 @@ if (get_post('Refresh')) { $result = true; foreach($exts as $i => $ext) { - if ($ext['package'] && ($ext['active'] ^ check_value('Active'.$i))) { - if (!$ext['active']) - $activated = activate_hooks($ext['package'], $comp); - else - $activated = hook_invoke($ext['package'], check_value('Active'.$i) ? - 'activate_extension':'deactivate_extension', $comp, false); + if ($ext['package'] && ($ext['active'] ^ check_value('Active'.$i))) + { + $activated = activate_hooks($ext['package'], $comp, !$ext['active']); // change active state + if ($activated !== null) $result &= $activated; if ($activated || ($activated === null)) diff --git a/includes/hooks.inc b/includes/hooks.inc index 71717fc1..6f15d0b0 100644 --- a/includes/hooks.inc +++ b/includes/hooks.inc @@ -246,7 +246,7 @@ function install_hooks() Non active hooks are not included in $Hooks array, so we can use special function to activate. */ -function activate_hooks($ext, $comp) +function activate_hooks($ext, $comp, $on=true) { global $Hooks; @@ -260,8 +260,10 @@ function activate_hooks($ext, $comp) } if (!$hooks) return false; - else + elseif ($on) return $hooks->activate_extension($comp, false); + else + return $hooks->deactivate_extension($comp, false); } /* Calls hook $method defined in extension $ext (if any)