From 4aa4c6c7418e5e06a26baa7d51521fafc20df467 Mon Sep 17 00:00:00 2001 From: regisoc Date: Sun, 18 Dec 2022 18:56:17 -0500 Subject: [PATCH 1/4] Fix incorrect message/error for instrument access --- php/libraries/NDB_BVL_Instrument.class.inc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/php/libraries/NDB_BVL_Instrument.class.inc b/php/libraries/NDB_BVL_Instrument.class.inc index 25aed6f03ff..1cc14f67eee 100644 --- a/php/libraries/NDB_BVL_Instrument.class.inc +++ b/php/libraries/NDB_BVL_Instrument.class.inc @@ -362,10 +362,20 @@ abstract class NDB_BVL_Instrument extends NDB_Page } else { //check if user has instrument's permissions //is the instrument listed at all in instrumentPermissions? $instrumentListed = false; - foreach ($instrumentPermissions["instrument"] as $instrument) { - if ($instrument["Test_name"] == $this->testName) { + $instrumentList = $instrumentPermissions["instrument"]; + if (array_key_exists("Test_name", $instrumentList)) { + // if only one instrument is listed in config.xml file + if ($instrumentList["Test_name"] == $this->testName) { $instrumentListed = true; - $instrumentPerms = Utility::asArray($instrument["permission"]); + $instrumentPerms = Utility::asArray($instrumentList["permission"]); + } + } else { + // multiple instruments listed + foreach ($instrumentList as $instrument) { + if ($instrument["Test_name"] == $this->testName) { + $instrumentListed = true; + $instrumentPerms = Utility::asArray($instrument["permission"]); + } } } From 0470195994c1cc3c91abdeb203ba888aab932872 Mon Sep 17 00:00:00 2001 From: regisoc Date: Mon, 19 Dec 2022 08:41:51 -0500 Subject: [PATCH 2/4] check --- php/libraries/NDB_BVL_Instrument.class.inc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/php/libraries/NDB_BVL_Instrument.class.inc b/php/libraries/NDB_BVL_Instrument.class.inc index 1cc14f67eee..139eacf584c 100644 --- a/php/libraries/NDB_BVL_Instrument.class.inc +++ b/php/libraries/NDB_BVL_Instrument.class.inc @@ -362,19 +362,23 @@ abstract class NDB_BVL_Instrument extends NDB_Page } else { //check if user has instrument's permissions //is the instrument listed at all in instrumentPermissions? $instrumentListed = false; - $instrumentList = $instrumentPermissions["instrument"]; + $instrumentList = $instrumentPermissions["instrument"]; if (array_key_exists("Test_name", $instrumentList)) { // if only one instrument is listed in config.xml file if ($instrumentList["Test_name"] == $this->testName) { $instrumentListed = true; - $instrumentPerms = Utility::asArray($instrumentList["permission"]); + $instrumentPerms = Utility::asArray( + $instrumentList["permission"] + ); } } else { // multiple instruments listed foreach ($instrumentList as $instrument) { if ($instrument["Test_name"] == $this->testName) { $instrumentListed = true; - $instrumentPerms = Utility::asArray($instrument["permission"]); + $instrumentPerms = Utility::asArray( + $instrument["permission"] + ); } } } From decf5ae4e6ecce3eeed453ed5db79e834832f146 Mon Sep 17 00:00:00 2001 From: regisoc Date: Tue, 20 Dec 2022 17:08:08 -0500 Subject: [PATCH 3/4] wrap into asArray --- php/libraries/NDB_BVL_Instrument.class.inc | 24 ++++++++-------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/php/libraries/NDB_BVL_Instrument.class.inc b/php/libraries/NDB_BVL_Instrument.class.inc index 139eacf584c..9ac934882b8 100644 --- a/php/libraries/NDB_BVL_Instrument.class.inc +++ b/php/libraries/NDB_BVL_Instrument.class.inc @@ -362,25 +362,19 @@ abstract class NDB_BVL_Instrument extends NDB_Page } else { //check if user has instrument's permissions //is the instrument listed at all in instrumentPermissions? $instrumentListed = false; - $instrumentList = $instrumentPermissions["instrument"]; - if (array_key_exists("Test_name", $instrumentList)) { - // if only one instrument is listed in config.xml file - if ($instrumentList["Test_name"] == $this->testName) { + // get an array of instruments + // if one instrument, get it into an array + $instrumentList = Utility::asArray( + $instrumentPermissions["instrument"] + ); + // iterate through instruments + foreach ($instrumentList as $instrument) { + if ($instrument["Test_name"] == $this->testName) { $instrumentListed = true; $instrumentPerms = Utility::asArray( - $instrumentList["permission"] + $instrument["permission"] ); } - } else { - // multiple instruments listed - foreach ($instrumentList as $instrument) { - if ($instrument["Test_name"] == $this->testName) { - $instrumentListed = true; - $instrumentPerms = Utility::asArray( - $instrument["permission"] - ); - } - } } //no permissions defined From 39a39d8a98c6abf978b61a92421050d0f899247e Mon Sep 17 00:00:00 2001 From: regisoc Date: Tue, 20 Dec 2022 17:12:46 -0500 Subject: [PATCH 4/4] check --- php/libraries/NDB_BVL_Instrument.class.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/libraries/NDB_BVL_Instrument.class.inc b/php/libraries/NDB_BVL_Instrument.class.inc index 9ac934882b8..e9f546c7bda 100644 --- a/php/libraries/NDB_BVL_Instrument.class.inc +++ b/php/libraries/NDB_BVL_Instrument.class.inc @@ -364,7 +364,7 @@ abstract class NDB_BVL_Instrument extends NDB_Page $instrumentListed = false; // get an array of instruments // if one instrument, get it into an array - $instrumentList = Utility::asArray( + $instrumentList = Utility::asArray( $instrumentPermissions["instrument"] ); // iterate through instruments