Skip to content
Snippets Groups Projects
Commit c1c1b09f authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FEAT #17163 TIME 1:30 add is writable check when creating scheduler script +...

FEAT #17163 TIME 1:30 add is writable check when creating scheduler script + fix fill stack + delete stack after doc is processed + WIP scheduler log
parent e25bca63
Branches
Tags
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
use Configuration\models\ConfigurationModel; use Configuration\models\ConfigurationModel;
use Document\models\DocumentModel; use Document\models\DocumentModel;
use Email\controllers\EmailController; use Email\controllers\EmailController;
use History\controllers\HistoryController;
use Notification\models\NotificationsScheduleModel; use Notification\models\NotificationsScheduleModel;
use Notification\models\NotificationStackModel; use Notification\models\NotificationStackModel;
use SrcCore\controllers\LanguageController; use SrcCore\controllers\LanguageController;
...@@ -27,10 +28,17 @@ $GLOBALS['id'] = $restUser['id']; ...@@ -27,10 +28,17 @@ $GLOBALS['id'] = $restUser['id'];
$configuration = ConfigurationModel::getByIdentifier(['identifier' => 'customization']); $configuration = ConfigurationModel::getByIdentifier(['identifier' => 'customization']);
$configuration = $configuration[0]; $configuration = $configuration[0];
$configuration = json_decode($configuration['value'], true); $configuration['value'] = json_decode($configuration['value'], true);
$applicationUrl = $configuration['applicationUrl']; $applicationUrl = $configuration['value']['applicationUrl'];
if (empty($applicationUrl)) { if (empty($applicationUrl)) {
HistoryController::add([
'code' => 'KO',
'objectType' => 'configurations',
'objectId' => $configuration['id'],
'type' => 'ERROR',
'message' => "{schedulerError} : Cannot run scheduler : no applicationUrl defined"
]);
echo "Cannot run scheduler : no applicationUrl defined\n"; echo "Cannot run scheduler : no applicationUrl defined\n";
exit(1); exit(1);
} }
...@@ -182,7 +190,7 @@ function sendNotifications(array $args) ...@@ -182,7 +190,7 @@ function sendNotifications(array $args)
'data' => [$stackIds] 'data' => [$stackIds]
]); ]);
return true; return $stackIds;
} }
#!/bin/sh
cd /var/www/html/MaarchParapheur/
filePath='/var/www/html/MaarchParapheur/bin/scheduler.php'
php $filePath /var/www/html/MaarchParapheur/config/
...@@ -572,7 +572,7 @@ ...@@ -572,7 +572,7 @@
"scheduleUpdated": "Planification modifiée", "scheduleUpdated": "Planification modifiée",
"frequency": "Fréquence", "frequency": "Fréquence",
"notificationDocumentsAddedBody": "Bonjour,<br/><br/>Des documents vous ont été transmis sur Maarch Parapheur.<br/><br/>", "notificationDocumentsAddedBody": "Bonjour,<br/><br/>Des documents vous ont été transmis sur Maarch Parapheur.<br/><br/>",
"notificationTemplateTable": "<table style=\"border: 1pt solid #000000; width: 1582px; height: 77px;\" border=\"1\" frame=\"box\" cellspacing=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: small;\"><strong>Objet</strong></span></td>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: small;\"><strong>Liens</strong></span></td>\n</tr>\n{{rows}}\n</tbody>\n</table>", "notificationTemplateTable": "<table style=\"border: 1pt solid #000000; width: 582px; height: 77px;\" border=\"1\" frame=\"box\" cellspacing=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: small;\"><strong>Objet</strong></span></td>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: small;\"><strong>Liens</strong></span></td>\n</tr>\n{{rows}}\n</tbody>\n</table>",
"notificationTemplateRow": "<tr>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: small;\">{{object}}</span></td>\n<td><span style=\"font-family: arial,helvetica,sans-serif;\"><a href=\"{{link}}\">Voir</a></span></td>\n</tr>", "notificationTemplateRow": "<tr>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: small;\">{{object}}</span></td>\n<td><span style=\"font-family: arial,helvetica,sans-serif;\"><a href=\"{{link}}\">Voir</a></span></td>\n</tr>",
"notificationDocumentsAddedSubject": "[Maarch Parapheur] Nouveaux documents à traiter", "notificationDocumentsAddedSubject": "[Maarch Parapheur] Nouveaux documents à traiter",
"applicationUrl": "URL de l'application", "applicationUrl": "URL de l'application",
...@@ -599,6 +599,7 @@ ...@@ -599,6 +599,7 @@
"schedulerInitialized": "Planificateur initialisé", "schedulerInitialized": "Planificateur initialisé",
"scheduleDeleted": "Planification supprimée", "scheduleDeleted": "Planification supprimée",
"manage_notificationsDesc": "Planifier les récapitulatifs d'évènements", "manage_notificationsDesc": "Planifier les récapitulatifs d'évènements",
"notifications_schedule": "Planification de notifications" "notifications_schedule": "Planification de notifications",
"schedulerError": "Erreur planificateur "
} }
} }
...@@ -18,6 +18,7 @@ use Attachment\controllers\AttachmentController; ...@@ -18,6 +18,7 @@ use Attachment\controllers\AttachmentController;
use Docserver\models\AdrModel; use Docserver\models\AdrModel;
use Email\controllers\EmailController; use Email\controllers\EmailController;
use Group\controllers\PrivilegeController; use Group\controllers\PrivilegeController;
use Notification\models\NotificationStackModel;
use Respect\Validation\Validator; use Respect\Validation\Validator;
use setasign\Fpdi\Tcpdf\Fpdi; use setasign\Fpdi\Tcpdf\Fpdi;
use SrcCore\controllers\UrlController; use SrcCore\controllers\UrlController;
...@@ -969,6 +970,11 @@ class DocumentController ...@@ -969,6 +970,11 @@ class DocumentController
$historyMessagePart = "{actionDoneInPlaceOf} {$user} : "; $historyMessagePart = "{actionDoneInPlaceOf} {$user} : ";
} }
NotificationStackModel::delete([
'where' => ['main_document_id = ?', 'type = ?', 'recipient_id = ?'],
'data' => [$args['id'], 'next_user', $GLOBALS['id']]
]);
HistoryController::add([ HistoryController::add([
'code' => 'OK', 'code' => 'OK',
'objectType' => 'main_documents', 'objectType' => 'main_documents',
......
...@@ -298,7 +298,7 @@ class EmailController ...@@ -298,7 +298,7 @@ class EmailController
$schedule = NotificationsScheduleModel::get([ $schedule = NotificationsScheduleModel::get([
'select' => ['id'], 'select' => ['id'],
'where' => ['type = ?'], 'where' => ['type = ?'],
'data' => ['typist_' . $args['mode']] 'data' => ['next_user']
]); ]);
$schedule = array_column($schedule, 'id'); $schedule = array_column($schedule, 'id');
if (!empty($nextUser['preferences']['notifications']['summaries'])) { if (!empty($nextUser['preferences']['notifications']['summaries'])) {
...@@ -323,7 +323,7 @@ class EmailController ...@@ -323,7 +323,7 @@ class EmailController
$schedule = NotificationsScheduleModel::get([ $schedule = NotificationsScheduleModel::get([
'select' => ['id'], 'select' => ['id'],
'where' => ['type = ?'], 'where' => ['type = ?'],
'data' => ['typist_' . $args['mode']] 'data' => ['next_user']
]); ]);
$schedule = array_column($schedule, 'id'); $schedule = array_column($schedule, 'id');
if (!empty($nextSubstituteUser['preferences']['notifications']['summaries'])) { if (!empty($nextSubstituteUser['preferences']['notifications']['summaries'])) {
......
...@@ -227,6 +227,9 @@ class NotificationsScheduleController ...@@ -227,6 +227,9 @@ class NotificationsScheduleController
if (empty($configuration['value']['schedulerPath']) || !is_file($configuration['value']['schedulerPath'])) { if (empty($configuration['value']['schedulerPath']) || !is_file($configuration['value']['schedulerPath'])) {
$schedulerScript = NotificationsScheduleController::createSchedulerScript(); $schedulerScript = NotificationsScheduleController::createSchedulerScript();
if (!empty($schedulerScript['errors'])) {
return $response->withStatus(500)->withJson(['errors' => $schedulerScript['errors']]);
}
$configuration['value']['schedulerPath'] = $schedulerScript['path']; $configuration['value']['schedulerPath'] = $schedulerScript['path'];
} }
...@@ -324,6 +327,10 @@ class NotificationsScheduleController ...@@ -324,6 +327,10 @@ class NotificationsScheduleController
$fullPath = $corePath . 'bin/' . $filename; $fullPath = $corePath . 'bin/' . $filename;
if (!is_writable($corePath . 'bin/')) {
return ['errors' => 'Cannot create scheduler script in ' . $corePath . 'bin/'];
}
$file_open = fopen($fullPath, 'w+'); $file_open = fopen($fullPath, 'w+');
fwrite($file_open, '#!/bin/sh'); fwrite($file_open, '#!/bin/sh');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment