From b7019c073ae713bfb10f7aef97edb5dee6298c81 Mon Sep 17 00:00:00 2001 From: CamilleBeau <51176779+CamilleBeau@users.noreply.github.com> Date: Thu, 1 Feb 2024 14:53:06 -0500 Subject: [PATCH 1/5] [issue_tracker] Fix inactive user query (#8904) This fixes the logic in the inactive users query for the assignee drop down of the issue tracker. The query was missing brackets in the logic and was querying active users in the inactive users array. This resulted in all users being unset from the assignees object for users who do not have the "access_all_profiles" permission. With brackets, users without the "access_all_profiles" permission should be able to see the appropriate users in the assignee drop down of a new issue. --- modules/issue_tracker/php/edit.class.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/issue_tracker/php/edit.class.inc b/modules/issue_tracker/php/edit.class.inc index b4705d6f83..15710ac1a5 100644 --- a/modules/issue_tracker/php/edit.class.inc +++ b/modules/issue_tracker/php/edit.class.inc @@ -96,7 +96,7 @@ class Edit extends \NDB_Page implements ETagCalculator $inactive_users_expanded = $db->pselect( "SELECT DISTINCT u.Real_name, u.UserID FROM users u LEFT JOIN user_psc_rel upr ON (upr.UserID=u.ID) - WHERE FIND_IN_SET(upr.CenterID,:CenterID) OR (upr.CenterID=:DCC) + WHERE (FIND_IN_SET(upr.CenterID,:CenterID) OR (upr.CenterID=:DCC)) AND Active='N'", [ 'CenterID' => $CenterID, From 3d0093daed70c26f5878542fafe46fbb1368ffe2 Mon Sep 17 00:00:00 2001 From: regis Date: Fri, 16 Feb 2024 15:22:04 -0500 Subject: [PATCH 2/5] [instrument_list] Fix deprecation warning (24.1) (#9053) Backport #8867 to 24.1. --- .../php/instrument_list_controlpanel.class.inc | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/modules/instrument_list/php/instrument_list_controlpanel.class.inc b/modules/instrument_list/php/instrument_list_controlpanel.class.inc index 811efeec2b..dafeeb2045 100644 --- a/modules/instrument_list/php/instrument_list_controlpanel.class.inc +++ b/modules/instrument_list/php/instrument_list_controlpanel.class.inc @@ -470,11 +470,8 @@ class Instrument_List_ControlPanel extends \TimePoint $qcStatus = $this->getBVLQCStatus(); foreach ($this->bvlQcTypes as $type) { - $isSelected =$type == $this->getBVLQCType(); - $type =strtolower($type); - if ($type==null) { - $type ="none"; - } + $isSelected = $type == $this->getBVLQCType(); + $type = strtolower($type ?? 'none'); if ($isSelected) { $this->tpl_data['bvl_qc_type_'.$type]['icon'] = 'far fa-check-square'; @@ -509,11 +506,8 @@ class Instrument_List_ControlPanel extends \TimePoint $qcType = $this->getBVLQCType(); foreach ($this->bvlQcStatuses as $status) { - $isSelected =$status == $this->getBVLQCStatus(); - $status =strtolower($status); - if ($status==null) { - $status ="none"; - } + $isSelected = $status == $this->getBVLQCStatus(); + $status = strtolower($status ?? 'none'); if ($isSelected) { $this->tpl_data['bvl_qc_status_'.$status]['icon'] = 'far fa-check-square'; From e733cae2ba3b64c888376e4ba942ab33c35b3142 Mon Sep 17 00:00:00 2001 From: regis Date: Wed, 27 Mar 2024 08:28:57 -0400 Subject: [PATCH 3/5] StaticDataTable mixed column types sorting (#9120) When mixing numbers with strings in an instrument field value (e.g. text field) results in a DQT column that has a sorting issues. This happened for a "summary" instrument in HBCD project that import results from multiple other instruments. This instrument has to clearly display the value of the field (i.e. numeric) or "No data" (i.e. string). --- jsx/StaticDataTable.js | 67 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/jsx/StaticDataTable.js b/jsx/StaticDataTable.js index d0b1ba6331..40bf2f11a8 100644 --- a/jsx/StaticDataTable.js +++ b/jsx/StaticDataTable.js @@ -295,6 +295,63 @@ class StaticDataTable extends Component { }); } + /** + * Get if the current sorting column has mixed types in its values. + * + * @return {bool} true if mixed types, else false. + */ + hasMixedTypes() { + // TODO: data column type check should probably be done once at init, + // meaning when receiving data, to find which columns have mixed types. + let typeFound = null; + + // not the default column + if (this.state.SortColumn === -1) { + return false; + } + + // Only checks string or number types, others are considered undefined. + // Break out of this loop once we encounter two mixed types: + // number and string inside the sorted column. + for (const row of this.props.Data) { + // cell value + let val = row[this.state.SortColumn]; + + // if null or undefined, go to the next iteration + if (val == null) { + continue; + } + + // check number + if (!isNaN(val) && typeof val !== 'object') { + // if string is found, mix of types, break + if (typeFound === 'string') { + return true; + } + // register number only if not already in + if (typeFound == null) { + typeFound = 'number'; + } + + // avoid string section + continue; + } + + // check string + if (typeof val === 'string' || val instanceof String) { + // if number is found, mix of types, break + if (typeFound === 'number') { + return true; + } + // register string only if not already in + if (typeFound == null) { + typeFound = 'string'; + } + } + } + return false; + } + /** * Sort the rows according to the sort configuration * @@ -303,6 +360,10 @@ class StaticDataTable extends Component { getSortedRows() { const index = []; + // is the current sorted column with mixed type? + const isMixedType = this.hasMixedTypes(); + + // for (let i = 0; i < this.props.Data.length; i += 1) { let val = this.props.Data[i][this.state.SortColumn] || undefined; // If SortColumn is equal to default No. column, set value to be @@ -316,10 +377,12 @@ class StaticDataTable extends Component { if (val === '.') { // hack to handle non-existent items in DQT val = null; - } else if (isNumber) { + } else if (isNumber && !isMixedType) { // perform type conversion (from string to int/float) val = Number(val); - } else if (isString) { + } else if (isString || isMixedType) { + // in case of mixed types, force values to string. + val = String(val); // if string with text convert to lowercase val = val.toLowerCase(); } else { From 729ce8a5286d1d16933568850e9414f4fb30ff41 Mon Sep 17 00:00:00 2001 From: George M <78069720+GeorgeMurad@users.noreply.github.com> Date: Wed, 27 Mar 2024 08:30:26 -0400 Subject: [PATCH 4/5] [tools] Fix SQL error for duplicate rows (#9007) Update the select query from pselectRow to pselect on line 105 under [tools] detect_duplicated_commentids.php file. pselectRow throws an exception when there are duplicates. --- tools/detect_duplicated_commentids.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/detect_duplicated_commentids.php b/tools/detect_duplicated_commentids.php index f7201aad30..7aa4bbf76e 100755 --- a/tools/detect_duplicated_commentids.php +++ b/tools/detect_duplicated_commentids.php @@ -102,7 +102,7 @@ $candid = $candidate['CandID']; $pscid = $candidate['PSCID']; foreach ($subprojectids as $subprojectid) { - $session_info = $DB->pselectRow( + $session_info = $DB->pselect( "SELECT DISTINCT s.Visit_label,s.ID from session s JOIN candidate c on (c.candid=s.candid) JOIN flag f on (f.sessionid=s.id) @@ -115,8 +115,8 @@ ] ); if (($session_info!=null) && (!empty($session_info))) { - $sessionid = $session_info['ID']; - $visit_label = $session_info['Visit_label']; + $sessionid = $session_info[0]['ID']; + $visit_label = $session_info[0]['Visit_label']; if ($sessionid !=null) { $commentid = getCommentIDs( $instrument, From 958ec4dfd8a99c9f037ccd30b8248668d6bba8a5 Mon Sep 17 00:00:00 2001 From: ridz1208 Date: Thu, 27 Feb 2025 15:43:17 -0500 Subject: [PATCH 5/5] static --- jsx/StaticDataTable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsx/StaticDataTable.js b/jsx/StaticDataTable.js index cc9b1c0a47..07f91c0a57 100644 --- a/jsx/StaticDataTable.js +++ b/jsx/StaticDataTable.js @@ -293,7 +293,7 @@ class StaticDataTable extends Component { /** * Get if the current sorting column has mixed types in its values. * - * @return {bool} true if mixed types, else false. + * @return {boolean} true if mixed types, else false. */ hasMixedTypes() { // TODO: data column type check should probably be done once at init,