From 63d91fa22971d3576c2010abeeaef42f1bf21d31 Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Tue, 7 Aug 2018 16:06:45 +0000 Subject: [PATCH] FEAT batch retrieveMailsFromExternalSB --- modules/visa/batch/batch_tools.php | 18 +++++++++++++++++- modules/visa/batch/config/config.xml.default | 3 +++ .../batch/process_mailsFromSignatoryBook.php | 5 ++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/modules/visa/batch/batch_tools.php b/modules/visa/batch/batch_tools.php index 379a1994280..a940a2d0407 100755 --- a/modules/visa/batch/batch_tools.php +++ b/modules/visa/batch/batch_tools.php @@ -176,7 +176,23 @@ function Bt_createAttachment($aArgs = []) "status" => 'TRA' ]; - // TODO curl storeResource + $opts = [ + CURLOPT_URL => $GLOBALS['applicationUrl'] . 'rest/res', + CURLOPT_HTTPHEADER => [ + 'accept:application/json', + 'content-type:application/json' + ], + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HTTPHEADER => 'Authorization: Basic ' . base64_encode($GLOBALS['userWS']. ':' .$GLOBALS['passwordWS']), + CURLOPT_POSTFIELDS => json_encode($allDatas), + CURLOPT_POST => true + ]; + + $curl = curl_init(); + curl_setopt_array($curl, $opts); + $rawResponse = curl_exec($curl); + + return json_decode($rawResponse, true); } function Bt_refusedSignedMail($aArgs = []) diff --git a/modules/visa/batch/config/config.xml.default b/modules/visa/batch/config/config.xml.default index d3da49a0cb2..4c16cdaa720 100755 --- a/modules/visa/batch/config/config.xml.default +++ b/modules/visa/batch/config/config.xml.default @@ -5,6 +5,9 @@ <CustomId>cs_maarch_v2</CustomId> <validatedStatus>VAL</validatedStatus> <refusedStatus>COU</refusedStatus> + <applicationUrl>http://localhost/maarch_v2/</applicationUrl> + <userWS>superadmin</userWS> + <passwordWS>superadmin</passwordWS> </CONFIG> <LOG4PHP> <enabled>true</enabled> diff --git a/modules/visa/batch/process_mailsFromSignatoryBook.php b/modules/visa/batch/process_mailsFromSignatoryBook.php index df81ab12680..f0355cc14f4 100755 --- a/modules/visa/batch/process_mailsFromSignatoryBook.php +++ b/modules/visa/batch/process_mailsFromSignatoryBook.php @@ -121,6 +121,9 @@ $config = $xmlconfig->CONFIG; $GLOBALS['MaarchDirectory'] = $_SESSION['config']['corepath'] = (string)$config->MaarchDirectory; $_SESSION['config']['app_id'] = 'maarch_entreprise'; $GLOBALS['CustomId'] = $_SESSION['custom_override_id'] = (string)$config->CustomId; +$GLOBALS['applicationUrl'] = (string)$config->applicationUrl; +$GLOBALS['userWS'] = (string)$config->userWS; +$GLOBALS['passwordWS'] = (string)$config->passwordWS; $GLOBALS['batchDirectory'] = $GLOBALS['MaarchDirectory'] . 'modules' . DIRECTORY_SEPARATOR . 'visa' . DIRECTORY_SEPARATOR . 'batch'; $validatedStatus = (string)$config->validatedStatus; $refusedStatus = (string)$config->refusedStatus; @@ -163,7 +166,7 @@ try { } } } else { - $GLOBALS['logger']->write($path . ' dfoes not exist', 'ERROR', 102); + $GLOBALS['logger']->write($path . ' does not exist', 'ERROR', 102); echo "\nConfiguration file ".$path." does not exist ! \nThe batch cannot be launched !\n\n"; exit(102); } -- GitLab