-
Notifications
You must be signed in to change notification settings - Fork 174
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
[Statistics] Behavioural Statistics > Double Data Entry - Site permission fix #6659
[Statistics] Behavioural Statistics > Double Data Entry - Site permission fix #6659
Conversation
@ridz1208 I retested this rebase and it works as expected. |
977bc1a
to
689b824
Compare
if (!empty($centerID)) { | ||
$this->query_criteria .= " AND s.CenterID =:cid "; | ||
$this->query_vars['cid'] = $centerID; | ||
} else { | ||
$list_of_permitted_sites = (array) null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting way to make an empty array. I've never seen this way until today. 🙂
I'm going to manually test. The code looks good! |
Hi @laemtl here are my results from what my test user could see visible. The General Demographics Statistics seems to be correct with only showing the two projects the user has access. The other statistics tabs in the module show all the projects for the select field. |
Thank you @maltheism. I will apply the same fix to the other sections as well! |
I think this PR will fix #6675 @kongtiaowang |
@maltheism This PR will fix Behavioural Statistics. But Imaging Statistics has the same issue. |
@laemtl What's the status? Is this ready for @maltheism's re-review? If so, please also ask Karim and/or Alex to help you test and review this today. |
@christinerogers All the comments were addressed and merged with #6706 |
@AlexandraLivadas @h-karim Does any of you have time to test this as well? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I manually tested and the fix works as expected!
0c6793b
to
d8fad7f
Compare
@pierre-p-s please review and test |
The behavioural statistics tab seems to be working for all sites except for 'Data Coordinating Center' (DCC). When you have the permission to access only DCC data, nothing appears in the behavioural statistics tab (see screenshot below). I am not getting any error in the console or error log. Is this intended? When clicking on breakdown per participant with only DCC permission this is what I am getting: |
@pierre-p-s DCC is not included in stats by design |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad you linked new issues to this.
I highlighted the typos and polished it in the suggestions.
Not sure how i feel about issue #s appearing in the text but can't think of a better way to do it right now.
// in near versions when the permission framework allow it | ||
// The filter _checkCriteria() takes care of restricting | ||
// the user access only to the sites it belongs to. | ||
// TODO (#6743): _checkCriteria takes care of restricting access |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO (#6743): _checkCriteria takes care of restricting access | |
// TODO (#6743): _checkCriteria takes care of restricting data access |
clarifying that it's data access not e.g. page-loading access
d8fad7f
to
1342585
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Travis failed for the PR.
I tested, the breakdown per participant, it only outputs data for sites that the user has access to as intended.
I am also linking another issue here that I encountered when testing the behavioural statistics tab: #6573
*/ | ||
function _hasAccess(\User $user) : bool | ||
{ | ||
// TODO (#6742): Create a permission specific to statistics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this should not be in the code but rather should be documented in the PR. Same thing for all the other mentions of issues.
@pierre-p-s Restarted the build and it succeeded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
$hasAccessToAllProfiles = $user->hasAllPermissions( | ||
array( | ||
'access_all_profiles', | ||
'data_entry', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
access_all_profiles
should be sufficient. There's no reason to check for both that and data_entry
. And you can just immediately return true if the user has it, there's no reason to check for center permissions once you've already determine that they should have access.
if (!empty($centerID)) { | ||
$this->query_criteria .= " AND s.CenterID =:cid "; | ||
$this->query_vars['cid'] = $centerID; | ||
} else { | ||
$list_of_permitted_sites = (array) null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @maltheism that this is weird. Why not just set it to []
?
if (!empty($centerID)) { | ||
$this->query_criteria .= " AND s.CenterID =:cid "; | ||
$this->query_vars['cid'] = $centerID; | ||
} else { | ||
$list_of_permitted_sites = (array) null; | ||
$currentUser = \User::singleton(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should come from the factory
$list_of_permitted_sites = array_keys(\Utility::getSiteList()); | ||
} else { | ||
foreach ($currentUser->getCenterIDs() as $centerID) { | ||
if ($currentUser->hasCenterPermission( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this check.. under what situations would the user have the centerID returned from getCenterIDs but not have permission to the centerID?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the suggestions make sense. I can't comment on the code as I didn't write it. Maybe @racostas can comment.
1b616c3
to
3426070
Compare
} else { | ||
// FIXME (#6742): For the short term the user will be granted access | ||
// if they have permission for a minimum of one of the centers | ||
foreach ($user->getCenterIDs() as $centerID) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment from 6 days ago.. not sure why GitHub removed it:
I don't understand this check.. under what situations would the user have the centerID returned from getCenterIDs but not have permission to the centerID?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for bring this back. This code is a bit old now I think. I will take a look but sure there are lot of things could be refactored/fixed.
#6861 refactors the code in this PR. Also includes permission restrictions by project . Please refer to this new version. |
closed by #6861 |
…ermission fix (aces#6861) Code refactorization of the functions _hasAccess and _checkCriteria. Adds per projects permissions restrictions. A user with permission data_entry should be now able to access the 'breakdown per participant' only for the sites and projects it have access to. Resolves aces#6659
…ermission fix (aces#6861) Code refactorization of the functions _hasAccess and _checkCriteria. Adds per projects permissions restrictions. A user with permission data_entry should be now able to access the 'breakdown per participant' only for the sites and projects it have access to. Resolves aces#6659
…ermission fix (aces#6861) Code refactorization of the functions _hasAccess and _checkCriteria. Adds per projects permissions restrictions. A user with permission data_entry should be now able to access the 'breakdown per participant' only for the sites and projects it have access to. Resolves aces#6659
…ermission fix (aces#6861) Code refactorization of the functions _hasAccess and _checkCriteria. Adds per projects permissions restrictions. A user with permission data_entry should be now able to access the 'breakdown per participant' only for the sites and projects it have access to. Resolves aces#6659
…ermission fix (aces#6861) Code refactorization of the functions _hasAccess and _checkCriteria. Adds per projects permissions restrictions. A user with permission data_entry should be now able to access the 'breakdown per participant' only for the sites and projects it have access to. Resolves aces#6659
Description of the issue
In Statistics / Behavioural Statistics / Double Data Entry Statistics, users were allowed to see the double data entry breakdown per participant from sites they don't have access to.
Brief summary of changes
The
_hasAccess
function was incorpoerate to this class (same functionality that the one in #5591)The function
_checkCriteria
was modified for only retrieve data from the sites(centers) the user have access to.Note: In future developments the capacity of setting permissions per site per user could be desirable. A note in rapport was included in the codeset. In this case the proposed function
_hasAccess
should be updated accordingly .Testing instructions (if applicable)
A user with permission 'data_entry' should be now able to access the 'breakdown per participant' for the double data entry page only for the sites it have access to.
Links to related PRs
#5950
#5591
Duplicates of #5966 (rebased on 23.0)