Commit 719aec11 authored by Charlotte Bataille's avatar Charlotte Bataille
Browse files

feat/18593 : display other org owner in search form

parent 30b9a80b
Pipeline #16660 failed with stages
in 30 seconds
......@@ -1650,20 +1650,22 @@ class organization
*/
protected function getOwnerOrgsByRole($currentService, $role)
{
$organizationController = \laabs::newController('organization/organization');
$orgUnits = $organizationController->getOrgsByRole($role);
$orgUnits = $this->getOrgsByRole($role);
$userPositionController = \laabs::newController('organization/userPosition');
$orgController = \laabs::newController('organization/organization');
$archivalAgreementController = \laabs::newController('medona/archivalAgreement');
$owner = false;
$archiver = false;
$userOrgUnits = [];
$userOrgs = [];
$allArchivalAgreements = $archivalAgreementController->index();
$originatorOrgIds = [];
$userOrgUnitOrgRegNumbers = array_merge(array($currentService->registrationNumber), $userPositionController->readDescandantService((string)$currentService->orgId));
foreach ($userOrgUnitOrgRegNumbers as $userOrgUnitOrgRegNumber) {
$userOrgUnit = $orgController->getOrgByRegNumber($userOrgUnitOrgRegNumber);
$userOrgUnit = $this->getOrgByRegNumber($userOrgUnitOrgRegNumber);
$userOrgUnits[] = $userOrgUnit;
if (isset($userOrgUnit->orgRoleCodes)) {
foreach ($userOrgUnit->orgRoleCodes as $orgRoleCode) {
......@@ -1672,6 +1674,12 @@ class organization
}
if ($orgRoleCode == 'archiver') {
$archiver = true;
$myOriginatorOrgs = [];
foreach ($allArchivalAgreements as $archivalAgreement) {
if($archivalAgreement->archiverOrgRegNumber == $userOrgUnitOrgRegNumber) {
$myOriginatorOrgs = array_merge($myOriginatorOrgs, $archivalAgreement->originatorOrgIds->jsonSerialize());
}
}
}
}
}
......@@ -1681,14 +1689,14 @@ class organization
foreach ($orgUnits as $orgUnit) {
if (// Owner = all originators
$owner
// Archiver = all originators fo the same org
|| ($archiver && $orgUnit->ownerOrgId == $userOrgUnit->ownerOrgId)
// Archiver = all originators for the same org
|| ($archiver && ($orgUnit->ownerOrgId == $userOrgUnit->ownerOrgId || in_array($orgUnit->orgId, $myOriginatorOrgs)))
// Originator = all originators at position and sub-services
|| ($role == 'originator' && $orgUnit->registrationNumber == $userOrgUnit->registrationNumber)
// Depositor = all
|| $role == 'depositor') {
if (!isset($userOrgs[(string)$orgUnit->ownerOrgId])) {
$orgObject = $organizationController->read((string)$orgUnit->ownerOrgId);
$orgObject = $this->read((string)$orgUnit->ownerOrgId);
$userOrgs[(string)$orgObject->orgId] = new \stdClass();
$userOrgs[(string)$orgObject->orgId]->displayName = $orgObject->displayName;
......
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