Commit 3b3d84b8 authored by Arnaud Pauget's avatar Arnaud Pauget
Browse files

Merge branch 'fix/17793_children_archive_communnication' into 'develop'

fix/17793 : prevent communication if one of children archive is not communicable

See merge request !696
parents 65a1b3bc b0886099
Pipeline #14395 failed with stages
in 48 seconds
......@@ -189,22 +189,28 @@ class ArchiveDeliveryRequest extends abstractMessage
}
}
foreach ($communicableArchives as $key => $archives) {
while ($this->sdoFactory->exists("medona/message", $unique)) {
$i++;
$unique['reference'] = $reference = $identifier.'_'.$i;
if (isset($communicableArchives['notCommunicable']) && !empty($communicableArchives['notCommunicable'])) {
throw \laabs::newException("medona/notCommunicableException");
}
if (isset($communicableArchives['communicable']) && !empty($communicableArchives['communicable'])) {
foreach ($communicableArchives['communicable'] as $key => $archives) {
while ($this->sdoFactory->exists("medona/message", $unique)) {
$i++;
$unique['reference'] = $reference = $identifier.'_'.$i;
}
$message = $this->send(
$reference,
$archives,
$derogation,
$comment,
$requesterOrgRegNumber,
$archiverOrgRegNumber,
null,
$format
);
$messages[] = $message;
}
$message = $this->send(
$reference,
$archives,
$derogation,
$comment,
$requesterOrgRegNumber,
$archiverOrgRegNumber,
null,
$format
);
$messages[] = $message;
}
}
......@@ -227,6 +233,20 @@ class ArchiveDeliveryRequest extends abstractMessage
}
}
$hasNonCommunicableDescendants = false;
$childrenArchives = $this->sdoFactory->readDescendants('recordsManagement/archive', $archive);
if (!empty($childrenArchives)) {
foreach ($childrenArchives as $childArchive) {
if (!$this->isCommunicable($childArchive)) {
$hasNonCommunicableDescendants = true;
}
}
}
if ($hasNonCommunicableDescendants) {
return false;
}
return true;
}
......
......@@ -40,7 +40,7 @@ class ArchiveModificationNotification extends ArchiveNotification
*
* @return The message generated
*/
public function send($reference, $archives = array(), $senderOrg, $recipientOrg, $comment = false, $format = null)
public function send($reference, $archives = array(), $senderOrg = null, $recipientOrg = null, $comment = false, $format = null)
{
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
......
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