Merged changes from stable branch up to 2.3.12
[fa-stable.git] / includes / hooks.inc
index 90bf2071b231bd2f2b059ccd717e38f939624f0e..521e48a6b862742b10daa40c66d3c72183705b8a 100644 (file)
@@ -103,6 +103,7 @@ class hooks {
        function price_in_words($amount, $doc_type)
        {
        }
+
        //
        // Exchange rate currency $curr as on date $date.
        // Keep in mind FA has internally implemented 3 exrate providers
@@ -212,7 +213,7 @@ function install_hooks()
 function activate_hooks($ext, $comp)
 {
        global $Hooks;
-       
+
        $hooks = @$Hooks[$ext];
        if (!$hooks) {
                $hookclass = 'hooks_'.$ext;
@@ -272,15 +273,15 @@ function hook_invoke_first($method, &$data, $opts=null)
 {
 
        global $Hooks;
-       
+
        $result = null;
        foreach($Hooks as $ext => $hook) {
                if (method_exists($hook, $method)) {
                        set_ext_domain('modules/'.$ext);
                        $result = $hook->$method($data, $opts);
+                       set_ext_domain();
                        if (isset($result))
                                break;
-                       set_ext_domain();
                }
        }
        return $result;
@@ -300,9 +301,9 @@ function hook_invoke_last($method, &$data, $opts=null)
                if (method_exists($hook, $method)) {
                        set_ext_domain('modules/'.$ext);
                        $result = $hook->$method($data, $opts);
+                       set_ext_domain();
                        if (isset($result))
                                break;
-                       set_ext_domain();
                }
        }
        return $result;