From 73bdf24b6a94c27cbaf2db72e92f12ba438ea6ad Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Wed, 12 Dec 2018 17:35:41 +0100 Subject: [PATCH] FEAT #8960 improve log maarchParapheur --- .../actions/sendToExternalSignatureBook.php | 4 ++++ modules/visa/class/MaarchParapheurController.php | 12 ++++++++++-- src/core/models/CurlModel.php | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php b/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php index e6118b13bc2..00956ba0449 100644 --- a/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php +++ b/apps/maarch_entreprise/actions/sendToExternalSignatureBook.php @@ -68,6 +68,10 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module, include_once 'modules/visa/class/FastParapheurController.php'; $htmlModal = FastParapheurController::getModal($config); + } elseif ($config['id'] == 'maarchParapheur') { + include_once 'modules/visa/class/MaarchParapheurController.php'; + + $htmlModal = MaarchParapheurController::getModal($config); } if (!empty($htmlModal['error'])) { diff --git a/modules/visa/class/MaarchParapheurController.php b/modules/visa/class/MaarchParapheurController.php index 52d2cea7c2b..c0a1d37dfae 100755 --- a/modules/visa/class/MaarchParapheurController.php +++ b/modules/visa/class/MaarchParapheurController.php @@ -18,7 +18,9 @@ class MaarchParapheurController public static function getModal($config) { $initializeDatas = MaarchParapheurController::getInitializeDatas($config); - + if (!empty($initializeDatas['error'])) { + return ['error' => $initializeDatas['error']]; + } $html .= '<label for="processingUser">' . _USER_MAARCH_PARAPHEUR . '</label><select name="processingUser" id="processingUser">'; if (!empty($initializeDatas['users'])) { foreach ($initializeDatas['users'] as $value) { @@ -39,7 +41,9 @@ class MaarchParapheurController public static function getInitializeDatas($config) { $rawResponse['users'] = MaarchParapheurController::getUsers(['config' => $config]); - + if (!empty($rawResponse['users']['error'])) { + return ['error' => $rawResponse['users']['error']]; + } return $rawResponse; } @@ -52,6 +56,10 @@ class MaarchParapheurController 'method' => 'GET' ]); + if (!empty($response['error'])) { + return ["error" => $response['error']]; + } + return $response['users']; } diff --git a/src/core/models/CurlModel.php b/src/core/models/CurlModel.php index b12fd25730b..5a74072bb7d 100644 --- a/src/core/models/CurlModel.php +++ b/src/core/models/CurlModel.php @@ -78,6 +78,7 @@ class CurlModel $curl = curl_init(); curl_setopt_array($curl, $opts); $rawResponse = curl_exec($curl); + $error = curl_error($curl); curl_close($curl); LogsController::add([ @@ -90,6 +91,19 @@ class CurlModel 'eventId' => $rawResponse ]); + if (!empty($error)) { + LogsController::add([ + 'isTech' => true, + 'moduleId' => 'curl', + 'level' => 'ERROR', + 'tableName' => '', + 'recordId' => '', + 'eventType' => 'Error Exec Curl : ' . $error, + 'eventId' => $rawResponse + ]); + return ['error' => $error]; + } + return json_decode($rawResponse, true); } -- GitLab