Skip to content

Commit

Permalink
Alter redirect from record home for new record
Browse files Browse the repository at this point in the history
Redirect using JavaScript rather than internal redirect() function to avoid EM framework exception emails.
  • Loading branch information
lsgs committed May 18, 2021
1 parent b72bc48 commit 9e8c696
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions RecordAutonumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ public function redcap_every_page_top($project_id) {
} else if (strpos($this->page, 'ExternalModules/manager/project.php')>0) {
$this->includeModuleManagerPageContent();
}
else if ($this->page==='DataEntry/record_home.php' && isset($_GET['id']) && isset($_GET['auto'])) {

if (isset($_GET['arm']) && array_key_exists($_GET['arm'], $this->Proj->events)) {
$armFirstEventId = key($this->Proj->events[$_GET['arm']]['events']);
$armFirstForm = $this->Proj->eventsForms[$armFirstEventId][0];
} else {
$armFirstEventId = $this->Proj->firstEventId;
$armFirstForm = $this->Proj->firstForm;
}
$tempRecId = \htmlspecialchars($_GET['id']);
$gotoUrl = APP_PATH_WEBROOT."DataEntry/index.php?pid={$this->project_id}&id=$tempRecId&event_id=$armFirstEventId&page=$armFirstForm";
// use javascript to redirect to first form because can't use redirect($loc) due to EM framework exceptions
echo "<script type=\"text/javascript\">window.location.href=\"$gotoUrl\";</script>";
}
if ($this->crossPageMessageIsSet()) {
$this->includeMessagePopup($this->getCrossPageMessage());
$this->clearCrossPageMessage();
Expand Down Expand Up @@ -157,19 +171,6 @@ public function redcap_every_page_before_render($project_id) {
}

}
else if ($this->page==='DataEntry/record_home.php' && isset($_GET['id']) && isset($_GET['auto'])) {

if (isset($_GET['arm']) && array_key_exists($_GET['arm'], $this->Proj->events)) {
$armFirstEventId = key($this->Proj->events[$_GET['arm']]['events']);
$armFirstForm = $this->Proj->eventsForms[$armFirstEventId][0];
} else {
$armFirstEventId = $this->Proj->firstEventId;
$armFirstForm = $this->Proj->firstForm;
}
$tempRecId = \htmlspecialchars($_GET['id']);
$gotoUrl = APP_PATH_WEBROOT."DataEntry/index.php?pid={$this->project_id}&id=$tempRecId&event_id=$armFirstEventId&page=$armFirstForm";
redirect($gotoUrl);
}
}

protected function handleAutonumberException($postRec, $msg) {
Expand Down

0 comments on commit 9e8c696

Please sign in to comment.