Temporary fixes for php encoding library bugs ending with segfault.
[fa-stable.git] / includes / hooks.inc
index 71717fc154202a4071612a4060bb428b3f371e6b..501d4a0f7eb1ca441a103b2d4efc85773e75899d 100644 (file)
@@ -116,6 +116,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
@@ -202,15 +203,14 @@ class hooks {
         * more than one in  the cart.
         */
        /* Default behavior check if there is enough quantity on hand and change the css
- * class if needed */
       * class if needed */
        static function  default_get_dispatchable_quantity($line_item, $location, $date, $qoh) {
-    global $SysPrefs;
+       global $SysPrefs;
 
                if ($SysPrefs->allow_negative_stock() || ($line_item->qty_dispatched <= $qoh)) {
                        return true;
                }
                return array($qoh, 'stockmankobg');
-               return array($line_item->qty_dispatched, 'stockmankobg');
        }
 
 }
@@ -236,20 +236,20 @@ function install_hooks()
        }
        // install hooks provided by active extensions
        foreach($installed_extensions as $ext) {
-                       $hook_class = 'hooks_'.$ext['package'];
-                       if ($ext['active'] && class_exists($hook_class)) {
-                               $Hooks[$ext['package']] = new $hook_class;
-                       }
+               $hook_class = 'hooks_'.$ext['package'];
+               if ($ext['active'] && class_exists($hook_class)) {
+                       $Hooks[$ext['package']] = new $hook_class;
+               }
        }
 }
 /*
        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;
-       
+
        $hooks = @$Hooks[$ext];
        if (!$hooks) {
                $hookclass = 'hooks_'.$ext;
@@ -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)
@@ -312,7 +314,7 @@ function hook_invoke_first($method, &$data, $opts=null)
 {
 
        global $Hooks;
-       
+
        $result = null;
        foreach($Hooks as $ext => $hook) {
                if (method_exists($hook, $method)) {