Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CO-2130_CO_Person_can_not_view_MVPA_attribute_under_OrgIdentity #213

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/Controller/AdHocAttributesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ function isAuthorized() {
} elseif(!empty($aha['AdHocAttribute']['org_identity_id'])) {
$managed = $this->Role->isCoOrCouAdminForOrgidentity($roles['copersonid'],
$aha['AdHocAttribute']['org_identity_id']);
if(!empty($roles['orgidentities'])) {
$org_ids = Hash::extract($roles, 'orgidentities.{n}.org_id');
if(in_array($aha['AdHocAttribute']['org_identity_id'], $org_ids)) {
$self = true;
}
}
}
}
break;
Expand Down
6 changes: 6 additions & 0 deletions app/Controller/AddressesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ function isAuthorized() {
} elseif(!empty($address['Address']['org_identity_id'])) {
$managed = $this->Role->isCoOrCouAdminForOrgidentity($roles['copersonid'],
$address['Address']['org_identity_id']);
if(!empty($roles['orgidentities'])) {
$org_ids = Hash::extract($roles, 'orgidentities.{n}.org_id');
if(in_array($address['Address']['org_identity_id'], $org_ids)) {
$self = true;
}
}
}
}
break;
Expand Down
1 change: 1 addition & 0 deletions app/Controller/CoDepartmentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ function isAuthorized() {
// View identifiers? This correlates with IdentifiersController
$p['identifiers'] = ($roles['cmadmin']
|| $roles['coadmin']
|| $self
|| ($managed && $roles['couadmin']));

$this->set('permissions', $p);
Expand Down
1 change: 1 addition & 0 deletions app/Controller/CoPeopleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ public function isAuthorized() {
// View identifiers? This correlates with IdentifiersController
$p['identifiers'] = ($roles['cmadmin']
|| $roles['coadmin']
|| $self
|| ($managed && $roles['couadmin']));

// View history? This correlates with HistoryRecordsController
Expand Down
6 changes: 6 additions & 0 deletions app/Controller/EmailAddressesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ function isAuthorized() {
} elseif(!empty($emailaddress['EmailAddress']['org_identity_id'])) {
$managed = $this->Role->isCoOrCouAdminForOrgidentity($roles['copersonid'],
$emailaddress['EmailAddress']['org_identity_id']);
if(!empty($roles['orgidentities'])) {
$org_ids = Hash::extract($roles, 'orgidentities.{n}.org_id');
if(in_array($emailaddress['EmailAddress']['org_identity_id'], $org_ids)) {
$self = true;
}
}
}
}
break;
Expand Down
13 changes: 12 additions & 1 deletion app/Controller/IdentifiersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ function isAuthorized() {
// the identifier passed in the URL, otherwise we lookup based on the record ID.

$managed = false;
$self = false;

if(!empty($roles['copersonid'])) {
switch($this->action) {
Expand Down Expand Up @@ -318,9 +319,18 @@ function isAuthorized() {
if(!empty($identifier['Identifier']['co_person_id'])) {
$managed = $this->Role->isCoOrCouAdminForCoPerson($roles['copersonid'],
$identifier['Identifier']['co_person_id']);
if($identifier['Identifier']['co_person_id'] == $roles['copersonid']) {
$self = true;
}
} elseif(!empty($identifier['Identifier']['org_identity_id'])) {
$managed = $this->Role->isCoOrCouAdminForOrgidentity($roles['copersonid'],
$identifier['Identifier']['org_identity_id']);
if(!empty($roles['orgidentities'])) {
$org_ids = Hash::extract($roles, 'orgidentities.{n}.org_id');
if(in_array($identifier['Identifier']['org_identity_id'], $org_ids)) {
$self = true;
}
}
}
}
break;
Expand Down Expand Up @@ -356,7 +366,8 @@ function isAuthorized() {

// View an existing Identifier?
$p['view'] = ($roles['cmadmin']
|| $roles['coadmin']
|| $roles['coadmin']
|| $self
|| ($managed && $roles['couadmin']));

$this->set('permissions', $p);
Expand Down
6 changes: 6 additions & 0 deletions app/Controller/NamesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ function isAuthorized() {
} elseif(!empty($name['Name']['org_identity_id'])) {
$managed = $this->Role->isCoOrCouAdminForOrgidentity($roles['copersonid'],
$name['Name']['org_identity_id']);
if(!empty($roles['orgidentities'])) {
$org_ids = Hash::extract($roles, 'orgidentities.{n}.org_id');
if(in_array($name['Name']['org_identity_id'], $org_ids)) {
$self = true;
}
}
}
}
break;
Expand Down
1 change: 1 addition & 0 deletions app/Controller/OrgIdentitiesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ function isAuthorized() {
// View identifiers? This correlates with IdentifiersController
$p['identifiers'] = ($roles['cmadmin']
|| $roles['coadmin']
|| $self
|| ($managed && $roles['couadmin']));

// View history? This correlates with HistoryRecordsController
Expand Down
6 changes: 6 additions & 0 deletions app/Controller/TelephoneNumbersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ function isAuthorized() {
} elseif(!empty($number['TelephoneNumber']['org_identity_id'])) {
$managed = $this->Role->isCoOrCouAdminForOrgidentity($roles['copersonid'],
$number['TelephoneNumber']['org_identity_id']);
if(!empty($roles['orgidentities'])) {
$org_ids = Hash::extract($roles, 'orgidentities.{n}.org_id');
if(in_array($number['TelephoneNumber']['org_identity_id'], $org_ids)) {
$self = true;
}
}
}
}
break;
Expand Down
6 changes: 6 additions & 0 deletions app/Controller/UrlsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ function isAuthorized() {
} elseif(!empty($url['Url']['org_identity_id'])) {
$managed = $this->Role->isCoOrCouAdminForOrgidentity($roles['copersonid'],
$url['Url']['org_identity_id']);
if(!empty($roles['orgidentities'])) {
$org_ids = Hash::extract($roles, 'orgidentities.{n}.org_id');
if(in_array($url['Url']['org_identity_id'], $org_ids)) {
$self = true;
}
}
}
}
break;
Expand Down