From 43d57fcd486571238f32b505fb73f5867478ad39 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Sun, 19 Mar 2017 23:37:55 +0100
Subject: [PATCH] FIX #5328 unlock resource after action

---
 core/manage_action.php | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/core/manage_action.php b/core/manage_action.php
index 1b5453198e9..1453b5499c9 100644
--- a/core/manage_action.php
+++ b/core/manage_action.php
@@ -386,20 +386,23 @@ else if(empty($_POST['values']) || !isset($_POST['action_id']) || empty($_POST['
             echo "{status : 0, error_txt : '".addslashes(functions::xssafe($_SESSION['action_error']))."'".$comp.", result_id : '".$res_action['result']."'}";
         }
     }
-    // Save action in history if needed
-    if($bool_history=='Y')
+
+    require_once 'apps/maarch_entreprise/actions/docLocker.php';
+    require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_history.php");
+    $hist = new history();
+    $arr_res = explode('#', $res_action['result']);
+    if(!is_array($res_action['history_msg'])){
+        $res_action['history_msg'] = [$res_action['history_msg']];
+    }
+    
+	for($i=0; $i<count($arr_res);$i++)
     {
-		$db = new Database();
-        require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_history.php");
-        $hist = new history();
-        $arr_res = explode('#', $res_action['result']);
-        if(!is_array($res_action['history_msg'])){
-            $res_action['history_msg'] = [$res_action['history_msg']];
-        }
-        
-		for($i=0; $i<count($arr_res );$i++)
+        if(!empty($arr_res[$i]))
         {
-            if(!empty($arr_res[$i]))
+            $docLocker = new docLocker($arr_res[$i]);
+            $docLocker->unlock();
+            // Save action in history if needed
+            if($bool_history=='Y')
             {
                 $what = '';
                 if (isset($_SESSION['current_basket']['id']) && !empty($_SESSION['current_basket']['id'])) {
-- 
GitLab