Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.
Open
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
9 changes: 6 additions & 3 deletions ExternalModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Survey;
use RCView;
use REDCap;
use UserRights;

/**
* ExternalModule class for REDCap Form Render Skip Logic.
Expand Down Expand Up @@ -396,6 +397,8 @@ protected function loadFRSL($location, $record = null, $event_id = null, $instru

$next_step_path = '';
$forms_access = $this->getFormsAccessMatrix($event_id, $record);
$current_user = UserRights::isImpersonatingUser() ? UserRights::getUsernameImpersonating() : USERID;
$user_rights_forms = reset(REDCap::getUserRights($current_user))['forms'];

if ($record && $event_id && $instrument) {
$instruments = $Proj->eventsForms[$event_id];
Expand All @@ -405,7 +408,7 @@ protected function loadFRSL($location, $record = null, $event_id = null, $instru
$len = count($instruments);

while ($i < $len) {
if ($curr_forms_access[$instruments[$i]]) {
if ($curr_forms_access[$instruments[$i]] && $user_rights_forms[$instruments[$i]]) {
$next_instrument = $instruments[$i];
break;
}
Expand All @@ -415,7 +418,7 @@ protected function loadFRSL($location, $record = null, $event_id = null, $instru

if (isset($next_instrument)) {
// Path to the next available form in the current event.
$next_step_path = APP_PATH_WEBROOT . 'DataEntry/index.php?pid=' . $Proj->project_id . '&id=' . $record . '&event_id=' . $event_id . '&page=' . $next_instrument;
$next_step_path = APP_PATH_WEBROOT . 'DataEntry/index.php?auto=1&pid=' . $Proj->project_id . '&id=' . $record . '&event_id=' . $event_id . '&page=' . $next_instrument;

// If this is a repeating event, maintain the instance
if ($Proj->hasRepeatingFormsEvents() && $instance) {
Expand All @@ -429,7 +432,7 @@ protected function loadFRSL($location, $record = null, $event_id = null, $instru
if (!$forms_access[$record][$event_id][$instrument]) {
if (!$next_step_path) {
$arm = $event_id ? $Proj->eventInfo[$event_id]['arm_num'] : $this->getQueryParam('arm', 1);
$next_step_path = APP_PATH_WEBROOT . 'DataEntry/record_home.php?pid=' . $Proj->project_id . '&id=' . $record . '&arm=' . $arm;
$next_step_path = APP_PATH_WEBROOT . 'DataEntry/record_home.php?auto=1&pid=' . $Proj->project_id . '&id=' . $record . '&arm=' . $arm;
}

$this->redirect($next_step_path);
Expand Down