From f8f6a815b56eaf5c49ea1ed54fb0c58280ba8bd5 Mon Sep 17 00:00:00 2001
From: Damien <damien.burel@maarch.org>
Date: Wed, 23 May 2018 17:11:25 +0200
Subject: [PATCH] FIX #7726 Signature on smartphone is available for any
 baskets with visa_mail action

---
 apps/maarch_entreprise/smartphone/details.php     |  3 ++-
 apps/maarch_entreprise/smartphone/list_result.php | 11 +++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/apps/maarch_entreprise/smartphone/details.php b/apps/maarch_entreprise/smartphone/details.php
index 112a20147c5..cd67213f00e 100755
--- a/apps/maarch_entreprise/smartphone/details.php
+++ b/apps/maarch_entreprise/smartphone/details.php
@@ -234,7 +234,8 @@ else{
         </ul>-->
         <?php
     }
-    if ($_SESSION['current_basket']['id'] == "EsigBasket" && $infos_attach['attachment_type'] != 'signed_response'){
+    $action = \Action\models\ActionModel::getById(['id' => $_SESSION['current_basket']['default_action'], 'select' => ['action_page']]);
+    if (!empty($action) && $action['action_page'] == 'visa_mail' && $infos_attach['attachment_type'] != 'signed_response'){
         ?>
         <a href="signature_main_panel.php?id=<?php functions::xecho($s_id);?>&collId=<?php
                     functions::xecho($_SESSION['collection_id_choice']);
diff --git a/apps/maarch_entreprise/smartphone/list_result.php b/apps/maarch_entreprise/smartphone/list_result.php
index f9d01a164f7..c7ac0c96c0b 100755
--- a/apps/maarch_entreprise/smartphone/list_result.php
+++ b/apps/maarch_entreprise/smartphone/list_result.php
@@ -67,16 +67,19 @@ if (isset($whereRequest) && !empty($whereRequest)) {
             if ($view == "view_folders") {
                 $line = '<li>';
             } else {
+                $action = \Action\models\ActionModel::getById(['id' => $_SESSION['current_basket']['default_action'], 'select' => ['action_page']]);
                 if ($i < $nombreDeLignesAffiche) {
-                    if ($_SESSION['current_basket']['id'] == "EsigBasket" && $view != "res_view_attachments"){
+                    if (!empty($action) && $action['action_page'] == 'visa_mail' && $view != "res_view_attachments"){
                         $line = '<li id=res_' . $i . ' style="display:block;"><a href="view_attachments.php?id=';
+                    } else {
+                        $line = '<li id=res_' . $i . ' style="display:block;"><a href="details.php?id=';
                     }
-                    else $line = '<li id=res_' . $i . ' style="display:block;"><a href="details.php?id=';
                 } else {
-                    if ($_SESSION['current_basket']['id'] == "EsigBasket" && $view != "res_view_attachments"){
+                    if (!empty($action) && $action['action_page'] == 'visa_mail' && $view != "res_view_attachments"){
                         $line = '<li id=res_' . $i . ' style="display:block;"><a href="view_attachments.php?id=';
+                    } else {
+                        $line = '<li id=res_' . $i . ' style="display:none;"><a href="details.php?id=';
                     }
-                    else $line = '<li id=res_' . $i . ' style="display:none;"><a href="details.php?id=';
                 }
             }
             for ($j = 0; $j < count($tab[$i]); $j++) {
-- 
GitLab