Fixed deactive_extension hook execution on extension deactivation.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 6 Oct 2015 07:28:40 +0000 (09:28 +0200)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 6 Oct 2015 07:33:23 +0000 (09:33 +0200)
admin/inst_module.php
includes/hooks.inc

index 77a16cbd5ba85b1536fa8676b49ffa56a7fa1889..437c326459b444d1e6f3da8f8c48d5b6c9369bf4 100644 (file)
@@ -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))
index 71717fc154202a4071612a4060bb428b3f371e6b..6f15d0b0b7138c7a8f3542b89d4e55144fab7bec 100644 (file)
@@ -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)