Verified Commit ad80bdf0 authored by Arnaud Pauget's avatar Arnaud Pauget
Browse files

fix (#11217) : manage eliminations blocking

parent e5dea60e
......@@ -41,28 +41,37 @@ trait archiveDestructionTrait
$archiveChildrenIds = [];
foreach ($archiveIds as $archiveId) {
$archiveChildrenIds = array_merge($archiveChildrenIds, $this->listChildrenArchiveId($archiveId));
$archiveChildrenIds[$archiveId] = $this->listChildrenArchiveId($archiveId);
}
foreach ($archiveChildrenIds as $archiveChildrenId) {
$archive = $this->sdoFactory->read('recordsManagement/archive', $archiveChildrenId);
$res = [];
$res['success'] = [];
$res['error'] = [];
foreach ($archives as $a) {
if ($a->archiveId == $archive->archiveId) {
continue 2;
foreach ($archiveChildrenIds as $archiveParentId => $childrenArchiveIds) {
foreach ($childrenArchiveIds as $childrenArchiveId) {
$archive = $this->sdoFactory->read('recordsManagement/archive', $childrenArchiveId);
foreach ($archives as $a) {
if ($a->archiveId == $archive->archiveId) {
continue 2;
}
}
}
$this->checkRights($archive);
$this->checkDisposalRights($archive) ;
$this->listChildrenArchive($archive, true);
$this->checkRights($archive);
if ($this->checkDisposalRights($archive)) {
$res['error'][] = $archiveParentId;
continue 2;
} else {
$res['success'][] = $archiveParentId;
}
$archives[] = $archive;
$this->listChildrenArchive($archive, true);
$archives[] = $archive;
}
}
$archiveList = $this->setStatus($archiveIds, 'disposable');
$archiveList = $this->setStatus($res['success'], 'disposable');
foreach ($archives as $archive) {
$this->logDestructionRequest($archive);
}
......@@ -71,7 +80,7 @@ trait archiveDestructionTrait
$this->sendDestructionRequest($archives, $identifier, $comment);
}
return $archiveList;
return $res;
}
/**
......@@ -341,7 +350,7 @@ trait archiveDestructionTrait
*/
public function checkDisposalRights($archive, $isChild = false)
{
$archiveIds = [];
$error = "";
$this->checkRights($archive);
$currentDate = \laabs::newTimestamp();
......@@ -355,18 +364,27 @@ trait archiveDestructionTrait
}
if (isset($archive->finalDisposition) && $archive->finalDisposition != "destruction") {
throw new \bundle\recordsManagement\Exception\notDisposableArchiveException(
// throw new \bundle\recordsManagement\Exception\notDisposableArchiveException(
// $beforeError."Archive not set for destruction."
// );
return new \bundle\recordsManagement\Exception\notDisposableArchiveException(
$beforeError."Archive not set for destruction."
);
}
if (isset($archive->disposalDate) && $archive->disposalDate > $currentDate) {
throw new \bundle\recordsManagement\Exception\notDisposableArchiveException(
// throw new \bundle\recordsManagement\Exception\notDisposableArchiveException(
// $beforeError."Disposal date not reached."
// );
return new \bundle\recordsManagement\Exception\notDisposableArchiveException(
$beforeError."Disposal date not reached."
);
}
if ($archive->status === "frozen") {
throw new \bundle\recordsManagement\Exception\notDisposableArchiveException(
// throw new \bundle\recordsManagement\Exception\notDisposableArchiveException(
// $beforeError."Archive not set for destruction."
// );
return new \bundle\recordsManagement\Exception\notDisposableArchiveException(
$beforeError."Archive not set for destruction."
);
}
......@@ -376,12 +394,13 @@ trait archiveDestructionTrait
|| empty($archive->disposalDate)
)
&& $actionWithoutRetentionRule == "preserve") {
throw new \bundle\recordsManagement\Exception\notDisposableArchiveException(
// throw new \bundle\recordsManagement\Exception\notDisposableArchiveException(
// $beforeError."There is a missing management information (date or retention rule)."
// );
return new \bundle\recordsManagement\Exception\notDisposableArchiveException(
$beforeError."There is a missing management information (date or retention rule)."
);
}
return $archiveIds ;
}
public function deleteResource($archiveId, $resIds)
......
......@@ -753,15 +753,42 @@ class archive
public function dispose($result)
{
$echec = 0;
$success = 0;
$success = count($result['success']);
if (array_key_exists('error', $result)) {
$echec = count($result['error']);
}
$archivesNumber = $echec+$success;
$this->translator->setCatalog('recordsManagement/messages');
$this->json->message = '%1$s / %2$s archive(s) flagged for destruction.';
$this->json->message = $this->translator->getText($this->json->message);
$this->json->message = sprintf($this->json->message, $success, ($echec+$success));
$this->json->message = $message = "";
if ($archivesNumber > 1) {
if ($success) {
$message = '%1$s / %3$s archive(s) flagged for destruction.';
$message = $this->translator->getText($message);
$this->json->message .= $message;
$this->json->message .= "</br>";
}
if ($echec) {
(!empty($this->json->message)) ? $this->json->message .= "</br>" : "";
$message = '%2$s / %3$s archive(s) not eliminable.';
$message = $this->translator->getText($message);
$this->json->message .= $message;
}
} else {
if ($success) {
$this->json->message = 'The archive is flagged for destruction.';
$this->json->message = $this->translator->getText($this->json->message);
} else {
$this->json->message = 'The archive cannot be eliminated.';
$this->json->message = $this->translator->getText($this->json->message);
}
}
$this->json->message = sprintf($this->json->message, $success, $echec, $archivesNumber);
return $this->json->save();
}
......
......@@ -698,9 +698,18 @@ msgctxt "validationModal"
msgid "%1$s archive(s) flagged for restitution."
msgstr "%1$s archive(s) marquée(s) pour restitution."
msgid "%1$s / %2$s archive(s) flagged for destruction."
msgid "%1$s / %3$s archive(s) flagged for destruction."
msgstr "%1$s archive(s) marquée(s) pour destruction."
msgid "%2$s / %3$s archive(s) not eliminable."
msgstr "%2$s archive(s) non éliminable(s)."
msgid "The archive is flagged for destruction."
msgstr "L'archive est marquée pour la destruction."
msgid "The archive cannot be eliminated."
msgstr "L'archive n'est pas éliminable."
msgid "%1$s archive(s) flagged for conversion."
msgstr "%1$s archive(s) marquée(s) pour conversion."
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment