diff --git a/apps/maarch_entreprise/actions/index_mlb.php b/apps/maarch_entreprise/actions/index_mlb.php index 2e5ec8a100cbeef6298f1a7ad15c82e970adcf09..28f34942510bb45b4b97f89a342788197c0dfec6 100755 --- a/apps/maarch_entreprise/actions/index_mlb.php +++ b/apps/maarch_entreprise/actions/index_mlb.php @@ -1487,7 +1487,7 @@ function get_value_fields($values, $field) * @param $table String Table * @param $formValues String Values of the form to load * - * @return false or an array + * @return array * $data['result'] : res_id of the new file followed by # * $data['history_msg'] : Log complement (empty by default) * $data['page_result'] : Page to load when action is done and modal closed @@ -2005,17 +2005,31 @@ function manage_form($arrId, $history, $actionId, $label_action, $status, $collI include_once 'modules'.DIRECTORY_SEPARATOR.'tags'.DIRECTORY_SEPARATOR.'tags_update.php'; } - // $_SESSION['indexing'] = array(); unset($_SESSION['upfile']); unset($_SESSION['data']); $_SESSION['action_error'] = _NEW_DOC_ADDED; $_SESSION['indexation'] = true; - return array( + if (\SrcCore\models\CurlModel::isEnabled(['curlCallId' => 'sendResourceToExternalApplication'])) { + + $config = \SrcCore\models\CurlModel::getConfigByCallId(['curlCallId' => 'sendResourceToExternalApplication']); + $select = []; + foreach ($config['data'] as $value) { + $select[] = $value; + } + + $document = \Resource\models\ResModel::getOnView(['select' => $select, 'where' => ['res_id = ?'], 'data' => [$resId]]); + + $response = \SrcCore\models\CurlModel::exec(['curlCallId' => 'sendResourceToExternalApplication', 'bodyData' => $document[0]]); + +// \Resource\models\ResModel::update(['set' => ['custom_t1' => $response['publikId']], 'where' => ['res_id = ?'], 'data' => [$document['res_id']]]); + } + + return [ 'result' => $resId.'#', 'history_msg' => '', 'page_result' => $_SESSION['config']['businessappurl'] .'index.php?page=details&dir=indexing_searching' .'&coll_id='.$collId.'&id='.$resId, - ); + ]; } diff --git a/apps/maarch_entreprise/xml/curlCall.xml b/apps/maarch_entreprise/xml/curlCall.xml index a0c3f89c8d4c8bdb3121b562a474ec84056852ef..bb0d80a217772aac2dacbe30c1216a6d77484a45 100644 --- a/apps/maarch_entreprise/xml/curlCall.xml +++ b/apps/maarch_entreprise/xml/curlCall.xml @@ -16,4 +16,18 @@ <value>custom_t1</value> </data> </call> + <call> + <id>sendResourceToExternalApplication</id> + <enabled>false</enabled> + <url></url> + <method>POST</method> + <data> + <key>res_id</key> + <value>res_id</value> + </data> + <data> + <key>status</key> + <value>status</value> + </data> + </call> </ROOT> diff --git a/src/core/models/CurlModel.php b/src/core/models/CurlModel.php index 15306e164048848420ca477ad7877ef04b368492..241f3a12b531294cc88138b23261934581813b09 100644 --- a/src/core/models/CurlModel.php +++ b/src/core/models/CurlModel.php @@ -127,4 +127,23 @@ class CurlModel return $curlConfig; } + + public static function isEnabled(array $aArgs) + { + ValidatorModel::notEmpty($aArgs, ['curlCallId']); + ValidatorModel::stringType($aArgs, ['curlCallId']); + + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/curlCall.xml']); + if ($loadedXml) { + foreach ($loadedXml->call as $call) { + if ((string)$call->id == $aArgs['curlCallId']) { + if (!empty((string)$call->enabled) && (string)$call->enabled == 'true') { + return true; + } + } + } + } + + return false; + } }