From ac1d0ba1f6af596a436fb908bbbd596f3d48b737 Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Fri, 10 Jan 2020 17:17:38 +0100 Subject: [PATCH] FEAT #11158 TIME 0:45 Only office available + refactoring for front --- .../xml/documentEditorsConfig.xml | 2 ++ .../controllers/OnlyOfficeController.php | 22 ++++++++++++++----- .../controllers/ListInstanceController.php | 11 ++++++++-- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/apps/maarch_entreprise/xml/documentEditorsConfig.xml b/apps/maarch_entreprise/xml/documentEditorsConfig.xml index 88f83195b9a..3d625f1c741 100644 --- a/apps/maarch_entreprise/xml/documentEditorsConfig.xml +++ b/apps/maarch_entreprise/xml/documentEditorsConfig.xml @@ -6,5 +6,7 @@ <onlyoffice> <enabled>true</enabled> <server_uri>onlyoffice.maarchcourrier.com</server_uri> + <server_port>80</server_port> + <server_ssl>false</server_ssl> </onlyoffice> </ROOT> diff --git a/src/app/contentManagement/controllers/OnlyOfficeController.php b/src/app/contentManagement/controllers/OnlyOfficeController.php index 5fb1d9be78d..5dd5e463c6d 100644 --- a/src/app/contentManagement/controllers/OnlyOfficeController.php +++ b/src/app/contentManagement/controllers/OnlyOfficeController.php @@ -36,7 +36,15 @@ class OnlyOfficeController $coreUrl = str_replace('rest/', '', UrlController::getCoreUrl()); - return $response->withJson(['enabled' => true, 'serverUri' => (string)$loadedXml->onlyoffice->server_uri, 'coreUrl' => $coreUrl]); + $configurations = [ + 'enabled' => true, + 'serverUri' => (string)$loadedXml->onlyoffice->server_uri, + 'serverPort' => (int)$loadedXml->onlyoffice->server_port, + 'serverSsl' => filter_var((string)$loadedXml->onlyoffice->server_ssl, FILTER_VALIDATE_BOOLEAN), + 'coreUrl' => $coreUrl + ]; + + return $response->withJson($configurations); } public static function saveMergedFile(Request $request, Response $response) @@ -168,14 +176,18 @@ class OnlyOfficeController public static function isAvailable(Request $request, Response $response) { $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/documentEditorsConfig.xml']); - if (empty($loadedXml) || empty($loadedXml->onlyoffice->enabled) || $loadedXml->onlyoffice->enabled == 'false' || empty($loadedXml->onlyoffice->server_uri)) { - return $response->withStatus(400)->withJson(['errors' => 'Onlyoffice is not enabled']); + if (empty($loadedXml) || empty($loadedXml->onlyoffice->enabled) || $loadedXml->onlyoffice->enabled == 'false') { + return $response->withStatus(400)->withJson(['errors' => 'Onlyoffice is not enabled', 'lang' => '']); + } elseif (empty($loadedXml->onlyoffice->server_uri)) { + return $response->withStatus(400)->withJson(['errors' => 'Onlyoffice server_uri is empty', 'lang' => '']); + } elseif (empty($loadedXml->onlyoffice->server_port)) { + return $response->withStatus(400)->withJson(['errors' => 'Onlyoffice server_port is empty', 'lang' => '']); } $uri = (string)$loadedXml->onlyoffice->server_uri; - $uri = str_replace(':', ' ', $uri); + $port = (string)$loadedXml->onlyoffice->server_port; - $exec = shell_exec("nc -vz -w 5 {$uri} 2>&1"); + $exec = shell_exec("nc -vz -w 5 {$uri} {$port} 2>&1"); $isAvailable = strpos($exec, 'succeeded!') !== false; diff --git a/src/app/entity/controllers/ListInstanceController.php b/src/app/entity/controllers/ListInstanceController.php index 5b61c976410..718052dc2a6 100755 --- a/src/app/entity/controllers/ListInstanceController.php +++ b/src/app/entity/controllers/ListInstanceController.php @@ -64,8 +64,9 @@ class ListInstanceController return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); } - $listInstances = ListInstanceModel::getVisaCircuitByResId(['select' => ['listinstance_id', 'sequence', 'item_id', 'item_type', 'firstname as item_firstname', 'lastname as item_lastname', 'entity_label as item_entity', 'viewed', 'process_date', 'process_comment', 'signatory', 'requested_signature'], 'id' => $aArgs['resId']]); + $listInstances = ListInstanceModel::getVisaCircuitByResId(['select' => ['listinstance_id', 'sequence', 'item_id', 'item_type', 'users.id', 'firstname as item_firstname', 'lastname as item_lastname', 'entity_label as item_entity', 'viewed', 'process_date', 'process_comment', 'signatory', 'requested_signature'], 'id' => $aArgs['resId']]); foreach ($listInstances as $key => $value) { + $listInstances[$key]['item_id'] = $listInstances[$key]['id']; $listInstances[$key]['labelToDisplay'] = $listInstances[$key]['item_firstname'].' '.$listInstances[$key]['item_lastname']; } @@ -78,8 +79,9 @@ class ListInstanceController return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); } - $listInstances = ListInstanceModel::getAvisCircuitByResId(['select' => ['listinstance_id', 'sequence', 'item_id', 'item_type', 'firstname as item_firstname', 'lastname as item_lastname', 'entity_label as item_entity', 'viewed', 'process_date', 'process_comment'], 'id' => $aArgs['resId']]); + $listInstances = ListInstanceModel::getAvisCircuitByResId(['select' => ['listinstance_id', 'sequence', 'item_id', 'item_type', 'users.id', 'firstname as item_firstname', 'lastname as item_lastname', 'entity_label as item_entity', 'viewed', 'process_date', 'process_comment'], 'id' => $aArgs['resId']]); foreach ($listInstances as $key => $value) { + $listInstances[$key]['item_id'] = $listInstances[$key]['id']; $listInstances[$key]['labelToDisplay'] = $listInstances[$key]['item_firstname'].' '.$listInstances[$key]['item_lastname']; } @@ -153,6 +155,9 @@ class ListInstanceController foreach ($ListInstanceByRes['listInstances'] as $instance) { $listControl = ['item_id', 'item_type', 'item_mode', 'difflist_type']; foreach ($listControl as $itemControl) { + if ($itemControl == 'item_mode' && $ListInstanceByRes['listInstances'][0]['difflist_type'] != 'entity_id') { + continue; + } if (empty($instance[$itemControl])) { return ['errors' => "ListInstance {$itemControl} is not set or empty", 'code' => 400]; } @@ -175,11 +180,13 @@ class ListInstanceController DatabaseModel::rollbackTransaction(); return ['errors' => 'User has not enough privileges', 'code' => 400]; } + $instance['item_mode'] = $instance['requested_signature'] ? 'sign' : 'visa'; } elseif ($ListInstanceByRes['listInstances'][0]['difflist_type'] == 'AVIS_CIRCUIT') { if (!PrivilegeController::hasPrivilege(['privilegeId' => 'avis_documents', 'userId' => $user['id']])) { DatabaseModel::rollbackTransaction(); return ['errors' => 'User has not enough privileges', 'code' => 400]; } + $instance['item_mode'] = 'avis'; } } elseif (in_array($instance['item_type'], ['entity_id', 'entity'])) { if ($instance['item_type'] == 'entity_id') { -- GitLab