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

[Dashboard/Study Progression -- View recruitment per site] Restricting users to see statistics only from sites they have access to. #5861

Closed
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
28 changes: 23 additions & 5 deletions modules/dashboard/ajax/get_recruitment_line_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,41 @@
header("content-type:application/json");
ini_set('default_charset', 'utf-8');

$DB = Database::singleton();
$DB = Database::singleton();
$currentUser = \User::singleton();
$site = array();
$list_of_sites = array();

//TODO: Create a permission specific to statistics
if ($currentUser->hasPermission('access_all_profiles')) {
$list_of_sites = \Utility::getSiteList();
} else {
$site_id_arr = $currentUser->getCenterIDs();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to remove DCC center (ID=1) to follow current implementation

foreach ($site_id_arr as $key => $val) {
$site[$key] = &Site::singleton($val);
$list_of_sites[$val] = $site[$key]->getCenterName();
}
}

$sitesString = implode(",", array_keys($list_of_sites));

$recruitmentData = array();
$recruitmentStartDate = $DB->pselectOne(
"SELECT MIN(Date_registered) FROM candidate",
"SELECT MIN(Date_registered)
FROM candidate
WHERE RegistrationCenterID IN (" . $sitesString . ")",
array()
);
$recruitmentEndDate = $DB->pselectOne(
"SELECT MAX(Date_registered) FROM candidate",
"SELECT MAX(Date_registered)
FROM candidate
WHERE RegistrationCenterID IN (" . $sitesString . ")",
array()
);

$recruitmentData['labels']
= createChartLabels($recruitmentStartDate, $recruitmentEndDate);

$list_of_sites = Utility::getAssociativeSiteList(true, false);

foreach ($list_of_sites as $siteID => $siteName) {
$recruitmentData['datasets'][] = array(
"name" => $siteName,
Expand Down