Skip to content
Snippets Groups Projects
Verified Commit ac1d0ba1 authored by Damien's avatar Damien
Browse files

FEAT #11158 TIME 0:45 Only office available + refactoring for front

parent 466a81aa
No related branches found
No related tags found
No related merge requests found
...@@ -6,5 +6,7 @@ ...@@ -6,5 +6,7 @@
<onlyoffice> <onlyoffice>
<enabled>true</enabled> <enabled>true</enabled>
<server_uri>onlyoffice.maarchcourrier.com</server_uri> <server_uri>onlyoffice.maarchcourrier.com</server_uri>
<server_port>80</server_port>
<server_ssl>false</server_ssl>
</onlyoffice> </onlyoffice>
</ROOT> </ROOT>
...@@ -36,7 +36,15 @@ class OnlyOfficeController ...@@ -36,7 +36,15 @@ class OnlyOfficeController
$coreUrl = str_replace('rest/', '', UrlController::getCoreUrl()); $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) public static function saveMergedFile(Request $request, Response $response)
...@@ -168,14 +176,18 @@ class OnlyOfficeController ...@@ -168,14 +176,18 @@ class OnlyOfficeController
public static function isAvailable(Request $request, Response $response) public static function isAvailable(Request $request, Response $response)
{ {
$loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/documentEditorsConfig.xml']); $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)) { if (empty($loadedXml) || empty($loadedXml->onlyoffice->enabled) || $loadedXml->onlyoffice->enabled == 'false') {
return $response->withStatus(400)->withJson(['errors' => 'Onlyoffice is not enabled']); 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 = (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; $isAvailable = strpos($exec, 'succeeded!') !== false;
......
...@@ -64,8 +64,9 @@ class ListInstanceController ...@@ -64,8 +64,9 @@ class ListInstanceController
return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); 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) { foreach ($listInstances as $key => $value) {
$listInstances[$key]['item_id'] = $listInstances[$key]['id'];
$listInstances[$key]['labelToDisplay'] = $listInstances[$key]['item_firstname'].' '.$listInstances[$key]['item_lastname']; $listInstances[$key]['labelToDisplay'] = $listInstances[$key]['item_firstname'].' '.$listInstances[$key]['item_lastname'];
} }
...@@ -78,8 +79,9 @@ class ListInstanceController ...@@ -78,8 +79,9 @@ class ListInstanceController
return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); 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) { foreach ($listInstances as $key => $value) {
$listInstances[$key]['item_id'] = $listInstances[$key]['id'];
$listInstances[$key]['labelToDisplay'] = $listInstances[$key]['item_firstname'].' '.$listInstances[$key]['item_lastname']; $listInstances[$key]['labelToDisplay'] = $listInstances[$key]['item_firstname'].' '.$listInstances[$key]['item_lastname'];
} }
...@@ -153,6 +155,9 @@ class ListInstanceController ...@@ -153,6 +155,9 @@ class ListInstanceController
foreach ($ListInstanceByRes['listInstances'] as $instance) { foreach ($ListInstanceByRes['listInstances'] as $instance) {
$listControl = ['item_id', 'item_type', 'item_mode', 'difflist_type']; $listControl = ['item_id', 'item_type', 'item_mode', 'difflist_type'];
foreach ($listControl as $itemControl) { foreach ($listControl as $itemControl) {
if ($itemControl == 'item_mode' && $ListInstanceByRes['listInstances'][0]['difflist_type'] != 'entity_id') {
continue;
}
if (empty($instance[$itemControl])) { if (empty($instance[$itemControl])) {
return ['errors' => "ListInstance {$itemControl} is not set or empty", 'code' => 400]; return ['errors' => "ListInstance {$itemControl} is not set or empty", 'code' => 400];
} }
...@@ -175,11 +180,13 @@ class ListInstanceController ...@@ -175,11 +180,13 @@ class ListInstanceController
DatabaseModel::rollbackTransaction(); DatabaseModel::rollbackTransaction();
return ['errors' => 'User has not enough privileges', 'code' => 400]; 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') { } elseif ($ListInstanceByRes['listInstances'][0]['difflist_type'] == 'AVIS_CIRCUIT') {
if (!PrivilegeController::hasPrivilege(['privilegeId' => 'avis_documents', 'userId' => $user['id']])) { if (!PrivilegeController::hasPrivilege(['privilegeId' => 'avis_documents', 'userId' => $user['id']])) {
DatabaseModel::rollbackTransaction(); DatabaseModel::rollbackTransaction();
return ['errors' => 'User has not enough privileges', 'code' => 400]; return ['errors' => 'User has not enough privileges', 'code' => 400];
} }
$instance['item_mode'] = 'avis';
} }
} elseif (in_array($instance['item_type'], ['entity_id', 'entity'])) { } elseif (in_array($instance['item_type'], ['entity_id', 'entity'])) {
if ($instance['item_type'] == 'entity_id') { if ($instance['item_type'] == 'entity_id') {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment