From 9195d08c7335ecb7fd88a815847604190873576f Mon Sep 17 00:00:00 2001
From: Nestor <npegane@hotmail.com>
Date: Thu, 11 Jan 2018 10:15:39 +0100
Subject: [PATCH] FIX #6457 control added on mail category and on id type +
 validation rules modified

---
 apps/maarch_entreprise/actions/process.php              | 9 ++++++++-
 apps/maarch_entreprise/indexing_searching/watermark.php | 9 ++++++++-
 apps/maarch_entreprise/xml/IVS/validation_rules.xml     | 1 +
 modules/attachments/xml/IVS/validation_rules.xml        | 1 +
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/apps/maarch_entreprise/actions/process.php b/apps/maarch_entreprise/actions/process.php
index 7165b9d5a6e..dffab964d9c 100755
--- a/apps/maarch_entreprise/actions/process.php
+++ b/apps/maarch_entreprise/actions/process.php
@@ -743,9 +743,16 @@ function get_form_txt($values, $path_manage_action,  $id_action, $table, $module
     $frm_str .='</div>';
     
     //RESOURCE FRAME
+
+    if($data['category_id']['value'] == "outgoing"){
+        $watermark_outgoing = "true";
+    } else {
+        $watermark_outgoing = "false";
+    }
+
     $frm_str .= '<iframe src="' . $_SESSION['config']['businessappurl']
         . 'index.php?display=true&dir=indexing_searching&page=view_resource_controler&id='
-        . $res_id . '&watermark_outgoing=true" name="viewframe" id="viewframe" scrolling="auto" frameborder="0" width="100%" style="width:100% !important;"></iframe>';
+        . $res_id . '&watermark_outgoing='.$watermark_outgoing.'" name="viewframe" id="viewframe" scrolling="auto" frameborder="0" width="100%" style="width:100% !important;"></iframe>';
 
     $frm_str .= '</div>';
 
diff --git a/apps/maarch_entreprise/indexing_searching/watermark.php b/apps/maarch_entreprise/indexing_searching/watermark.php
index 7dd63638e2f..a176abb6723 100755
--- a/apps/maarch_entreprise/indexing_searching/watermark.php
+++ b/apps/maarch_entreprise/indexing_searching/watermark.php
@@ -58,10 +58,17 @@ if ($watermarkTab['text'] == '') {
     	} elseif ($matches[1][$z] == 'hour_now') {
     		$currentText = date('H:m:i');
     	} elseif($matches[1][$z] == 'alt_identifier'){
+            
+            if($_REQUEST['watermark_outgoing'] == "true"){
+                $res_id = $_REQUEST['res_id_master'];
+            } else {
+                $res_id = $s_id;
+            }
+
             $dbView = new Database();
 		    $query = " select " . $matches[1][$z] 
 		        . " as thecolumn from mlb_coll_ext where res_id = ?";
-		    $stmt = $dbView->query($query, array($_REQUEST['res_id_master']));
+		    $stmt = $dbView->query($query, array($res_id));
             $returnQuery = $stmt->fetchObject();
             $currentText = $returnQuery->thecolumn;
         } else {
diff --git a/apps/maarch_entreprise/xml/IVS/validation_rules.xml b/apps/maarch_entreprise/xml/IVS/validation_rules.xml
index ca1b5456e1c..664f247a097 100755
--- a/apps/maarch_entreprise/xml/IVS/validation_rules.xml
+++ b/apps/maarch_entreprise/xml/IVS/validation_rules.xml
@@ -513,6 +513,7 @@
       <parameter name="aVersion" type="boolean" />
       <parameter name="dir" type="identifier" />
       <parameter name="editingMode" type="string" />
+      <parameter name="watermark_outgoing" type="string" />
     </validationRule>
 
     <validationRule name="multi_contacts" extends="standardForm" mode="error">  
diff --git a/modules/attachments/xml/IVS/validation_rules.xml b/modules/attachments/xml/IVS/validation_rules.xml
index bf273bf765b..2394fd843c1 100755
--- a/modules/attachments/xml/IVS/validation_rules.xml
+++ b/modules/attachments/xml/IVS/validation_rules.xml
@@ -81,6 +81,7 @@
 		<parameter name="res_id_master" type="integer" />
 		<parameter name="id" type="identifier" />
 		<parameter name="editingMode" type="string" />
+		<parameter name="watermark_outgoing" type="string" />
 	</validationRule>
 
 </validationRules>
-- 
GitLab