Skip to content

Commit 67f0578

Browse files
committed
Update for multiple redcap_data tables
Update for multiple redcap_data tables (REDCap v14) Remove constructor
1 parent 22c1eaf commit 67f0578

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

LockingAPI.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,18 @@ protected static function sendResponse($status=200, $response='') {
5353
private $arm;
5454
private $format;
5555

56-
public function __construct() {
57-
parent::__construct();
58-
global $lang, $user_rights;
56+
protected function isModuleEnabledForProject() {
57+
return ExternalModules::getProjectSetting($this->PREFIX, $this->project_id, ExternalModules::KEY_ENABLED);
58+
}
59+
60+
protected function processLockingApiRequest() {
61+
global $Proj, $longitudinal, $lang, $user_rights;
5962
$this->page = PAGE;
6063
$this->lang = &$lang;
6164
$this->user_rights = &$user_rights;
6265
$this->get = &$_GET;
6366
$this->post = &$_POST;
64-
}
6567

66-
protected function isModuleEnabledForProject() {
67-
return ExternalModules::getProjectSetting($this->PREFIX, $this->project_id, ExternalModules::KEY_ENABLED);
68-
}
69-
70-
protected function processLockingApiRequest() {
71-
global $Proj, $longitudinal;
72-
7368
$this->request = RestUtility::processRequest(true);
7469

7570
$this->user = $this->request->getRequestVars()['username'];
@@ -163,12 +158,14 @@ protected function validateRecord() {
163158
# Accept multiple records if record level lock request only
164159
if ($this->lock_record_level) {
165160
$records = array();
161+
if ($this->format == 'json') {
162+
$this->post['record'] = json_decode($this->post['record']);
163+
}
164+
166165
if(is_array($this->post['record'])) {
167-
# Support array parameter via php/curl
168166
$records = $this->post['record'];
169-
} else if ($this->format == 'json') {
170-
# Transform json into array
171-
$records = json_decode($this->post['record']);
167+
} else {
168+
$records[] = $this->post['record'];
172169
}
173170

174171
# Taken and edited from API > record > delete.php:delRecords()
@@ -464,7 +461,8 @@ protected function readLockStatusDataLevel() {
464461
}
465462

466463
// read recorded form status values
467-
$sql = "select record, event_id, field_name, value, instance from redcap_data where project_id=".db_escape($this->project_id)." and record='".db_escape($this->record)."' ";
464+
$redcap_data = method_exists('\REDCap', 'getDataTable') ? \REDCap::getDataTable($this->project_id) : "redcap_data";
465+
$sql = "select record, event_id, field_name, value, instance from $redcap_data where project_id=".db_escape($this->project_id)." and record='".db_escape($this->record)."' ";
468466
$sql .= "and event_id in (".implode(',',array_keys($eventForms)).") ";
469467
$sql .= "and field_name in ('".implode("','",$includedFormStatusFields)."') ";
470468

0 commit comments

Comments
 (0)