From 2e7aebd41fb6f63569478c4d9d2fc73be958dc9a Mon Sep 17 00:00:00 2001
From: Alex Orluc <alex.orluc@maarch.org>
Date: Wed, 7 Dec 2016 08:38:14 +0000
Subject: [PATCH] FIX #4937 add hist var in action management in order to not
 log main action if secondary action chosen

---
 core/trunk/core/manage_action.php            | 15 +++++++++++----
 core/trunk/core/xml/IVS/validation_rules.xml |  1 +
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/core/trunk/core/manage_action.php b/core/trunk/core/manage_action.php
index 418f9cd2a31..706ba78499d 100644
--- a/core/trunk/core/manage_action.php
+++ b/core/trunk/core/manage_action.php
@@ -80,7 +80,11 @@ if($_POST['req'] == 'valid_form' && !empty($_POST['action_id']) && isset($_POST[
     $label_action = $res->label_action;
     $status = $res->id_status;
     $action_page = $res->action_page;
-    $bool_history = $res->history;
+    if($res->history == 'Y' && $_POST['hist']!='N'){
+        $bool_history = $res->history;
+    }else{
+        $bool_history = 'N';
+    }
     $create_id = $res->create_id;
 
         //No script defined for this action
@@ -194,8 +198,11 @@ else if(empty($_POST['values']) || !isset($_POST['action_id']) || empty($_POST['
     $label_action = $res->label_action;
     $status = $res->id_status;
     $action_page = $res->action_page;
-    $bool_history = $res->history;
-
+    if($res->history == 'Y' && $_POST['hist']!='N'){
+        $bool_history = $res->history;
+    }else{
+        $bool_history = 'N';
+    }
     //No script defined for this action
     if($action_page == '')
     {
@@ -386,7 +393,7 @@ else if(empty($_POST['values']) || !isset($_POST['action_id']) || empty($_POST['
         require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_history.php");
         $hist = new history();
         $arr_res = explode('#', $res_action['result']);
-        for($i=0; $i<count($arr_res );$i++)
+		for($i=0; $i<count($arr_res );$i++)
         {
             if(!empty($arr_res[$i]))
             {
diff --git a/core/trunk/core/xml/IVS/validation_rules.xml b/core/trunk/core/xml/IVS/validation_rules.xml
index 62d76de2527..01e89598e6d 100755
--- a/core/trunk/core/xml/IVS/validation_rules.xml
+++ b/core/trunk/core/xml/IVS/validation_rules.xml
@@ -9,5 +9,6 @@
         <parameter name="values" type="string" />
         <parameter name="form_to_check" type="identifier" />
         <parameter name="new_status" type="identifier" />
+        <parameter name="hist" type="string" />
     </validationRule>
 </validationRules>
\ No newline at end of file
-- 
GitLab