Commit 9d116791 authored by Prosper De Laure's avatar Prosper De Laure
Browse files

Bug correction

parent f62897d4
......@@ -361,45 +361,45 @@ class archivalProfile
*/
protected function updateContainedProfiles($archivalProfile, $containedProfiles)
{
if ($archivalProfile->acceptAnyProfile) {
$containedProfiles = null;
$containedProfiles = [];
}
if (!count($containedProfiles)) {
$oldcontainedProfiles = $this->sdoFactory->find("recordsManagement/archivalProfileRelationship", "parentProfileId = '$archivalProfile->archivalProfileId'");
if (count($oldcontainedProfiles)) {
$this->sdoFactory->deleteCollection($oldcontainedProfiles, "recordsManagement/archivalProfileRelationship");
}
if (count($containedProfiles)) {
// Validation
foreach ($containedProfiles as $profileId) {
try {
$profile = $this->sdoFactory->read("recordsManagement/archivalProfile", $profileId);
return;
} catch (\Exception $e) {
throw new \core\Exception\NotFoundException("$profileId can't be found.");
}
if (!$this->validateContainedProfile($archivalProfile->archivalProfileId, $profileId)) {
throw new \core\Exception\ForbiddenException("$profile->reference can't be content in this archival profile.");
}
}
}
// Validation
foreach ($containedProfiles as $profileId) {
try {
$profile = $this->sdoFactory->read("recordsManagement/archivalProfile", $profileId);
} catch (\Exception $e) {
throw new \core\Exception\NotFoundException("$profileId can't be found.");
}
if (!$this->validateContainedProfile($archivalProfile->archivalProfileId, $profileId)) {
throw new \core\Exception\ForbiddenException("$profile->reference can't be content in this archival profile.");
}
$oldcontainedProfiles = $this->sdoFactory->find("recordsManagement/archivalProfileRelationship", "parentProfileId = '$archivalProfile->archivalProfileId'");
if (count($oldcontainedProfiles)) {
$this->sdoFactory->deleteCollection($oldcontainedProfiles, "recordsManagement/archivalProfileRelationship");
}
if (count($containedProfiles)) {
$archivalProfileRelationships = [];
foreach ($containedProfiles as $containedProfileId) {
$archivalProfileRelationship = \laabs::newInstance('recordsManagement/archivalProfileRelationship');
$archivalProfileRelationship->parentProfileId = $archivalProfile->archivalProfileId;
$archivalProfileRelationship->containedProfileId = $containedProfileId;
$archivalProfileRelationships = [];
foreach ($containedProfiles as $containedProfileId) {
$archivalProfileRelationship = \laabs::newInstance('recordsManagement/archivalProfileRelationship');
$archivalProfileRelationship->parentProfileId = $archivalProfile->archivalProfileId;
$archivalProfileRelationship->containedProfileId = $containedProfileId;
$archivalProfileRelationships[] = $archivalProfileRelationship;
}
$archivalProfileRelationships[] = $archivalProfileRelationship;
$this->sdoFactory->createCollection($archivalProfileRelationships, "recordsManagement/archivalProfileRelationship");
}
$this->sdoFactory->createCollection($archivalProfileRelationships, "recordsManagement/archivalProfileRelationship");
return true;
}
......
......@@ -354,10 +354,11 @@ trait archiveEntryTrait
public function completeArchivalProfileCodes($archive)
{
if ($archive->archivalProfileReference == "") {
$archive->archivalProfileReference = $this->currentArchivalProfile->reference;
return;
}
$this->useArchivalProfile($archive->archivalProfileReference);
if (!empty($this->currentArchivalProfile->retentionRuleCode)) {
$archive->retentionRuleCode = $this->currentArchivalProfile->retentionRuleCode;
......@@ -640,11 +641,11 @@ trait archiveEntryTrait
for ($i = 0; $i < $nbArchiveObjects; $i++) {
if (($archive->contents[$i]->archivalProfileReference == "" && !$this->currentArchivalProfile->acceptArchiveWithoutProfile) || (!$this->currentArchivalProfile->acceptAnyProfile && !in_array($archive->contents[$i]->archivalProfileReference, $containedProfiles))) {
throw new \core\Exception\ForbiddenException("Invalid contained archive profile");
}
}
$this->validateManagementMetadata($archive->contents[$i]);
}
}
}
......
......@@ -164,19 +164,20 @@ class welcome
$archive->depositDate = $archive->depositDate->format('Y-m-d H:i:s');
$depositPrivilege = \laabs::callService('auth/userAccount/readHasprivilege', "archiveDeposit/deposit");
if (!empty($archive->archivalProfileReference)) {
$archivalProfile = \laabs::callService('recordsManagement/archivalProfile/readByreference_reference_', $archive->archivalProfileReference);
$archive->archivalProfileName = $archivalProfile->name;
if (!count($archivalProfile->containedProfiles) && !$archivalProfile->acceptArchiveWithoutProfile && !$archivalProfile->acceptAnyProfile) {
$depositPrivilege = false;
}
}
$depositPrivilege = \laabs::callService('auth/userAccount/readHasprivilege', "archiveDeposit/deposit");
if (count($archivalProfile->containedProfiles) && $archivalProfile->acceptArchiveWithoutProfile == false) {
$depositPrivilege = false;
}
$this->view->translate();
$this->view->setSource('containedProfiles', $archivalProfiles->containedProfiles);
// $this->view->setSource('containedProfiles', $archivalProfiles->containedProfiles);
$this->view->setSource("status", $archive->status);
$archive->status = $this->view->translator->getText($archive->status, false, "recordsManagement/messages");
......
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