Skip to content

Commit

Permalink
Merge pull request #1039 from TIP-Global-Health/develop
Browse files Browse the repository at this point in the history
WIP: Developments starting February 27, 2024
  • Loading branch information
anvmn authored Feb 28, 2024
2 parents 645a72c + 3026396 commit 622691e
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .ddev/config.local.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@ hooks:
- exec: drush mi --group=default --user=1
- exec: drush mi --group=counseling --user=1
- exec: drush mi --group=forms --user=1
- exec: "cd .. && rm -f hedley/modules/custom/hedley_migrate/csv/health_center.csv"
- exec: "cd .. && rm -f hedley/modules/custom/hedley_migrate/csv/person.csv"
- exec: "cd .. && rm -f hedley/modules/custom/hedley_migrate/csv/village.csv"
- exec: drush uli
16 changes: 15 additions & 1 deletion server/hedley/hedley.install
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,16 @@ function hedley_standard_install() {
// Set this as the administrator role.
variable_set('user_admin_role', $admin_role->rid);

// Creating a E-ledger viewer role and add the permissions.
// Creating a E-ledger viewer role.
$ledger_viewer_role = new stdClass();
$ledger_viewer_role->name = 'E-ledger viewer';
user_role_save($ledger_viewer_role);

// Creating a Data Manager role.
$data_manager_role = new stdClass();
$data_manager_role->name = 'Data Manager';
user_role_save($data_manager_role);

// Creating a Nurse role and add the permissions.
$nurse_role = new stdClass();
$nurse_role->name = 'nurse';
Expand Down Expand Up @@ -678,3 +683,12 @@ function hedley_update_7039() {
variable_set('hedley_general_site_name', 'rwanda');
}
}

/**
* Create 'Data Manager' role.
*/
function hedley_update_7040() {
$data_manager_role = new stdClass();
$data_manager_role->name = 'Data Manager';
user_role_save($data_manager_role);
}
5 changes: 5 additions & 0 deletions server/hedley/modules/custom/hedley_admin/hedley_admin.module
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ function hedley_admin_block_view($delta) {
return;
}

if (!hedley_admin_administrators_access()) {
// Only administrators can view the block.
return;
}

$query = db_select('menu_links', 'm');
$query->fields('m', ['link_path', 'link_title', 'options']);
$query->condition('menu_name', 'menu-eheza-app-admin-menu');
Expand Down
22 changes: 17 additions & 5 deletions server/hedley/modules/custom/hedley_ncda/hedley_ncda.module
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,56 @@ function hedley_ncda_menu() {
'title' => 'Aggregated NCDA scoreboard',
'description' => 'View Aggregated NCDA scoreboard',
'page callback' => 'hedley_ncda_aggregated_callback_menu',
'access callback' => 'hedley_admin_administrators_access',
'access callback' => 'hedley_ncda_aggregated_ncda_report_access',
);

$items['admin/reports/aggregated-ncda/%/%'] = array(
'title' => 'Aggregated NCDA scoreboard for district',
'description' => 'View Aggregated NCDA scoreboard for district',
'page callback' => 'hedley_ncda_aggregated_callback_district',
'page arguments' => [3, 4],
'access callback' => 'hedley_admin_administrators_access',
'access callback' => 'hedley_ncda_aggregated_ncda_report_access',
);

$items['admin/reports/aggregated-ncda/%/%/%'] = array(
'title' => 'Aggregated NCDA scoreboard for sector',
'description' => 'View Aggregated NCDA scoreboard for sector',
'page callback' => 'hedley_ncda_aggregated_callback_sector',
'page arguments' => [3, 4, 5],
'access callback' => 'hedley_admin_administrators_access',
'access callback' => 'hedley_ncda_aggregated_ncda_report_access',
);

$items['admin/reports/aggregated-ncda/%/%/%/%'] = array(
'title' => 'Aggregated NCDA scoreboard for cell',
'description' => 'View Aggregated NCDA scoreboard for cell',
'page callback' => 'hedley_ncda_aggregated_callback_cell',
'page arguments' => [3, 4, 5, 6],
'access callback' => 'hedley_admin_administrators_access',
'access callback' => 'hedley_ncda_aggregated_ncda_report_access',
);

$items['admin/reports/aggregated-ncda/%/%/%/%/%'] = array(
'title' => 'Aggregated NCDA scoreboard for village',
'description' => 'View Aggregated NCDA scoreboard for village',
'page callback' => 'hedley_ncda_aggregated_callback_village',
'page arguments' => [3, 4, 5, 6, 7],
'access callback' => 'hedley_admin_administrators_access',
'access callback' => 'hedley_ncda_aggregated_ncda_report_access',
);

return $items;
}

/**
* Grants access to Aggregated NCDA viewers, superuser and administrators.
*
* @return bool
* TRUE if the user has access, FALSE otherwise.
*/
function hedley_ncda_aggregated_ncda_report_access() {
$data_mananger_role = user_role_load_by_name('Data Manager');

return user_has_role($data_mananger_role->rid) || hedley_admin_administrators_access();
}

/**
* Implements hook_node_insert().
*/
Expand Down
25 changes: 25 additions & 0 deletions server/hedley/modules/custom/hedley_patient/hedley_patient.module
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,31 @@ function hedley_patient_menu() {
return $items;
}

/**
* Implements hook_user_login().
*
* When Data Manager users log in, redirect them
* to Aggregated NCDA report page.
*/
function hedley_patient_user_login(&$edit, $account) {
$data_mananger_role = user_role_load_by_name('Data Manager');
if (!user_has_role($data_mananger_role->rid, $account)) {
return;
}

// Path of Aggregated NCDA report page.
$path = 'admin/reports/aggregated-ncda';
// The 'Location' HTTP header must be absolute.
$options['absolute'] = TRUE;
$url = url($path, $options);

header('Location: ' . $url, TRUE, 302);
// The "Location" header sends a redirect status code to the HTTP daemon. In
// some cases this can be wrong, so we make sure none other
// gets executed upon redirection.
drupal_exit($url);
}

/**
* Implements hook_node_insert().
*/
Expand Down

0 comments on commit 622691e

Please sign in to comment.