Skip to content

Commit 56a636b

Browse files
authored
Merge pull request #8909 from driusan/Push2415To25
Push v24.1.5 bug fixes into v25.0.x release branch
2 parents 72bd0fd + e1de313 commit 56a636b

15 files changed

+101
-41
lines changed

modules/api/php/endpoints/candidates.class.inc

+4
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ class Candidates extends Endpoint implements \LORIS\Middleware\ETagCalculator
154154
return new \LORIS\Http\Response\JSON\NotFound('Candidate not found');
155155
}
156156

157+
if (!$candidate->isAccessibleBy($user)) {
158+
return new \LORIS\Http\Response\JSON\Forbidden();
159+
}
160+
157161
$endpoint = new Candidate\Candidate($candidate);
158162

159163
$pathparts = array_slice($pathparts, 2);

modules/configuration/templates/form_configuration.tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
{elseif $node['DataType'] eq 'date_format'}
108108
{call createDateFormat k=$id v=$v d=$node['Disabled']}
109109
{elseif $node['DataType'] eq 'email'}
110-
{call createEmail k=$id v=$id d=$node['Disabled']}
110+
{call createEmail k=$id v=$v d=$node['Disabled']}
111111
{elseif $node['DataType'] eq 'textarea'}
112112
{call createTextArea k=$id v=$v d=$node['Disabled']}
113113
{elseif $node['DataType'] eq 'lookup_center'}

modules/imaging_uploader/jsx/UploadForm.js

+30-6
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,22 @@ class UploadForm extends Component {
6666
let ids = patientName.split('_');
6767
formData.candID = ids[1];
6868
formData.pSCID = ids[0];
69-
// visitLabel can contain underscores
70-
// join the remaining elements of patientName and use as visitLabel
69+
// visitLabel can contain underscores, filename can have suffix appended to PSCID_CandID_VisitLabel
70+
// join the remaining elements of patientName and pattern match
71+
// against each visit label. Use as visitLabel the best (longest) match
7172
ids.splice(0, 2);
72-
formData.visitLabel = ids.join('_');
73+
const suffix = ids.join('_');
74+
const visitLabels = Object.keys(form.visitLabel.options);
75+
let bestMatch = '';
76+
visitLabels.map((visitLabel) => {
77+
if (suffix.match(visitLabel) !== null) {
78+
// consider the first match only
79+
if (suffix.match(visitLabel)[0].length > bestMatch.length) {
80+
bestMatch = suffix.match(visitLabel)[0];
81+
}
82+
}
83+
});
84+
formData.visitLabel = bestMatch;
7385
}
7486
}
7587

@@ -81,10 +93,22 @@ class UploadForm extends Component {
8193
let ids = patientName.split('_');
8294
formData.candID = ids[1];
8395
formData.pSCID = ids[0];
84-
// visitLabel can contain underscores
85-
// join the remaining elements of patientName and use as visitLabel
96+
// visitLabel can contain underscores, filename can have suffix appended to PSCID_CandID_VisitLabel
97+
// join the remaining elements of patientName and pattern match
98+
// against each visit label. Use as visitLabel the best (longest) match
8699
ids.splice(0, 2);
87-
formData.visitLabel = ids.join('_');
100+
const suffix = ids.join('_');
101+
const visitLabels = Object.keys(form.visitLabel.options);
102+
let bestMatch = '';
103+
visitLabels.map((visitLabel) => {
104+
if (suffix.match(visitLabel) !== null) {
105+
// consider the first match only
106+
if (suffix.match(visitLabel)[0].length > bestMatch.length) {
107+
bestMatch = suffix.match(visitLabel)[0];
108+
}
109+
}
110+
});
111+
formData.visitLabel = bestMatch;
88112
}
89113
}
90114

modules/issue_tracker/php/edit.class.inc

+4-4
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,11 @@ class Edit extends \NDB_Page implements ETagCalculator
481481
$historyValues = $this->getChangedValues($issueValues, $issueID, $user);
482482

483483
if (!empty($issueID)) {
484-
$db->update('issues', $issueValues, ['issueID' => $issueID]);
484+
$db->unsafeUpdate('issues', $issueValues, ['issueID' => $issueID]);
485485
} else {
486486
$issueValues['reporter'] = $user->getUsername();
487487
$issueValues['dateCreated'] = date('Y-m-d H:i:s');
488-
$db->insert('issues', $issueValues);
488+
$db->unsafeInsert('issues', $issueValues);
489489
$issueID = intval($db->getLastInsertId());
490490
}
491491

@@ -873,7 +873,7 @@ class Edit extends \NDB_Page implements ETagCalculator
873873
'issueID' => $issueID,
874874
'addedBy' => $user->getUsername(),
875875
];
876-
$db->insert('issues_history', $changedValues);
876+
$db->unsafeInsert('issues_history', $changedValues);
877877
}
878878
}
879879
}
@@ -896,7 +896,7 @@ class Edit extends \NDB_Page implements ETagCalculator
896896
'addedBy' => $user->getUsername(),
897897
'issueID' => $issueID,
898898
];
899-
$db->insert('issues_comments', $commentValues);
899+
$db->unsafeInsert('issues_comments', $commentValues);
900900
}
901901
}
902902

modules/media/ajax/FileUpload.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ function getUploadFields()
349349
$mediaData = $db->pselectRow(
350350
"SELECT " .
351351
"m.session_id as sessionID, " .
352-
"(SELECT PSCID from candidate WHERE CandID=s.CandID) as pscid, " .
352+
"c.PSCID as pscid, " .
353353
"Visit_label as visitLabel, " .
354354
"instrument, " .
355355
"CenterID as forSite, " .
@@ -358,9 +358,10 @@ function getUploadFields()
358358
"file_name as fileName, " .
359359
"hide_file as hideFile, " .
360360
"language_id as language," .
361-
"m.id FROM media m LEFT JOIN session s ON m.session_id = s.ID " .
362-
"WHERE m.id = $idMediaFile",
363-
[]
361+
"m.id FROM media m LEFT JOIN session s ON m.session_id = s.ID
362+
LEFT JOIN candidate c ON (c.CandID=s.CandID) " .
363+
"WHERE m.id = :mediaId",
364+
['mediaId' => $idMediaFile]
364365
);
365366
}
366367

modules/survey_accounts/js/survey_accounts_helper.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ $(document).ready(function () {
1616
// Handles cases where there was an error on the page and we're resubmitting
1717
var email2 = $("input[name=Email2]").val();
1818
var email = $("input[name=Email]").val();
19-
if (email.length > 0 && email2.length > 0 && email == email2)
20-
{
21-
$('#email_survey').removeAttr('disabled');
22-
} else {
23-
$('#email_survey').attr('disabled','disabled');
19+
if (email && email2) {
20+
if (email.length > 0 && email2.length > 0 && email == email2)
21+
{
22+
$('#email_survey').removeAttr('disabled');
23+
} else {
24+
$('#email_survey').attr('disabled','disabled');
25+
}
2426
}
2527
// Reset Test_name so that the template can be loaded by ajax below
2628
$("select[name=Test_name]").val("");
@@ -93,7 +95,7 @@ $(document).ready(function () {
9395
$("#emailContent").val(content);
9496
}
9597
);
96-
98+
9799

98100
});
99101
});

modules/survey_accounts/jsx/surveyAccountsIndex.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ class SurveyAccountsIndex extends Component {
112112
options: options.instruments,
113113
}},
114114
{label: 'URL', show: true},
115-
{label: 'Status', show: true},
115+
{label: 'Status', show: true, filter: {
116+
name: 'Status',
117+
type: 'select',
118+
options: options.statusOptions,
119+
}},
116120
];
117121
const addSurvey = () => {
118122
location.href='/survey_accounts/addSurvey/';

modules/survey_accounts/php/addsurvey.class.inc

+5-4
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ class AddSurvey extends \NDB_Form
162162
];
163163
}
164164
}
165-
166-
if ($_REQUEST['fire_away'] !== 'Create survey') {
165+
if (!isset($_REQUEST['fire_away'])
166+
|| ($_REQUEST['fire_away'] !== 'Create survey')
167+
) {
167168
if (!filter_var(
168169
$values['Email'],
169170
FILTER_VALIDATE_EMAIL
@@ -241,11 +242,11 @@ class AddSurvey extends \NDB_Form
241242
'CommentID' => $commentID,
242243
]
243244
);
245+
$this->tpl_data['success'] = true;
244246
} catch (\DatabaseException $e) {
245247
error_log($e->getMessage());
246248
$this->tpl_data['success'] = false;
247249
}
248-
$this->tpl_data['success'] = true;
249250

250251
if ($email && ($values['send_email'] == 'true')) {
251252
$config = \NDB_Config::singleton();
@@ -291,7 +292,7 @@ class AddSurvey extends \NDB_Form
291292
"Instrument",
292293
array_merge(
293294
['' => ''],
294-
\Utility::getDirectInstruments()
295+
\NDB_BVL_Instrument::getDirectEntryInstrumentNamesList($this->loris)
295296
)
296297
);
297298
$this->addBasicText("Email", "Email address");

modules/survey_accounts/php/survey_accounts.class.inc

+10-2
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,22 @@ class Survey_Accounts extends \DataFrameworkMenu
7474
*/
7575
public function getFieldOptions() : array
7676
{
77+
$statusOptions = [
78+
'Created' => 'Created',
79+
'Sent' => 'Sent',
80+
'In Progress' => 'In Progress',
81+
'Complete' => 'Complete',
82+
];
83+
7784
$instruments
7885
= \NDB_BVL_Instrument::getDirectEntryInstrumentNamesList(
7986
$this->loris
8087
);
8188

8289
return [
83-
'visits' => \Utility::getVisitList(),
84-
'instruments' => $instruments,
90+
'visits' => \Utility::getVisitList(),
91+
'instruments' => $instruments,
92+
'statusOptions' => $statusOptions,
8593
];
8694
}
8795

php/libraries/BVL_Feedback_Panel.class.inc

+9-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,15 @@ class BVL_Feedback_Panel
101101
$summary = $this->feedbackThread->getSummaryOfThreads();
102102
$this->tpl_data['thread_summary_headers'] = json_encode($summary);
103103

104-
$field_names = Utility::getSourcefields($_REQUEST['test_name'] ?? '');
104+
$test_name = '';
105+
if (array_key_exists('test_name', $_REQUEST)) {
106+
$test_name = $_REQUEST['test_name'];
107+
} else if (array_key_exists('lorispath', $_REQUEST)) {
108+
$test_name = preg_split("#/#", $_REQUEST['lorispath'])[1] ?? '';
109+
}
110+
111+
// Get field names
112+
$field_names = Utility::getSourcefields($test_name);
105113
$fields = [];
106114
$fields['Across All Fields'] = 'Across All Fields';
107115
foreach ($field_names as $field_name) {

php/libraries/LorisForm.class.inc

+5-1
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,7 @@ class LorisForm
15921592
$checked = '';
15931593
$value = '';
15941594
$disabled = '';
1595+
$required = '';
15951596
if (!empty($val)) {
15961597
$checked = 'checked="checked"';
15971598
}
@@ -1601,6 +1602,9 @@ class LorisForm
16011602
if (isset($el['disabled']) || $this->frozen) {
16021603
$disabled = 'disabled';
16031604
}
1605+
if (isset($el['required'])) {
1606+
$required = 'required';
1607+
}
16041608
/// XXX: There seems to be a problem when using   to separate the
16051609
// checkbox from the label. Both Firefox and Chrome will still put a
16061610
// linebreak between the space and the checkbox. Instead, we wrap use
@@ -1609,7 +1613,7 @@ class LorisForm
16091613
// label it's still allowed to have linebreaks.
16101614
return "<span style=\"white-space: nowrap\"><input name=\"$el[name]\""
16111615
. " type=\"checkbox\" $checked $value "
1612-
. "$disabled/>"
1616+
. "$disabled $required/>"
16131617
. " </span>$el[label]";
16141618
}
16151619

php/libraries/LorisFormDictionaryImpl.class.inc

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ trait LorisFormDictionaryImpl
131131
$t = new \LORIS\Data\Types\StringType(255);
132132
break;
133133
case 'header':
134+
case 'hidden':
134135
continue 2;
135136
default:
136137
throw new \LorisException(

php/libraries/NDB_BVL_Instrument_LINST.class.inc

+8-8
Original file line numberDiff line numberDiff line change
@@ -743,15 +743,15 @@ class NDB_BVL_Instrument_LINST extends \NDB_BVL_Instrument
743743
case 'numeric':
744744
if ($addElements) {
745745
$this->addNumericElement($pieces[1], $pieces[2]);
746-
$this->dictionary[] = new DictionaryItem(
747-
$this->testName."_".$pieces[1],
748-
$pieces[2],
749-
$scope,
750-
new IntegerType(),
751-
new Cardinality(Cardinality::SINGLE),
752-
$pieces[1],
753-
);
754746
}
747+
$this->dictionary[] = new DictionaryItem(
748+
$this->testName."_".$pieces[1],
749+
$pieces[2],
750+
$scope,
751+
new IntegerType(),
752+
new Cardinality(Cardinality::SINGLE),
753+
$pieces[1],
754+
);
755755
if ($firstFieldOfPage) {
756756
$this->_requiredElements[] = $fieldname;
757757
$firstFieldOfPage = false;

test/unittests/LorisForms_Test.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ function testCheckboxHTMLWithNoAttributes()
13361336
$this->form->addCheckbox("abc", "Hello", []);
13371337
$this->assertEquals(
13381338
"<span style=\"white-space: nowrap\"><input name=\"abc\" " .
1339-
"type=\"checkbox\" /> </span>Hello",
1339+
"type=\"checkbox\" /> </span>Hello",
13401340
$this->form->checkboxHTML($this->form->form['abc'])
13411341
);
13421342
}
@@ -1358,7 +1358,7 @@ function testCheckboxHTMLWithAttributesSet()
13581358
$this->assertEquals(
13591359
"<span style=\"white-space: nowrap\"><input name=\"abc\" " .
13601360
"type=\"checkbox\" checked=\"checked\"" .
1361-
" value=\"value1\" disabled/> </span>Hello",
1361+
" value=\"value1\" disabled /> </span>Hello",
13621362
$this->form->checkboxHTML($this->form->form['abc'])
13631363
);
13641364
}

tools/importers/CouchDB_MRI_Importer.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,10 @@ function _addMRIHeaderInfo($FileObj, $scan_type)
234234
$FileObj,
235235
'acquisition_date'
236236
);
237-
$header['FileInsertDate_'.$type] = $FileObj->getParameter('InsertTime');
237+
$header['FileInsertDate_'.$type] = date(
238+
'Y-m-d',
239+
$FileObj->getParameter('InsertTime')
240+
);
238241
$header['SeriesDescription_'.$type] = $FileObj->getParameter($ser_desc);
239242
$header['SeriesNumber_'.$type] = $FileObj->getParameter($ser_num);
240243
$header['EchoTime_'.$type] = number_format(

0 commit comments

Comments
 (0)