Skip to content

Commit

Permalink
bug fix and php8.1 fixes (#5664)
Browse files Browse the repository at this point in the history
* bug fix and php8.1 fixes

* styling
  • Loading branch information
stephenwaite committed Aug 5, 2022
1 parent 8ba0f30 commit c5d9945
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 27 deletions.
30 changes: 15 additions & 15 deletions portal/patient/fwk/libs/verysimple/Phreeze/Criteria.php
Expand Up @@ -223,63 +223,63 @@ final protected function Prepare()
$this->_where .= $this->_where_delim . ' ' . $filter->GetWhere($this);
$this->_where_delim = " and";
}
} elseif (substr($prop, - 7) == "_Equals" && strlen($this->$prop)) {
} elseif (substr($prop, - 7) == "_Equals" && strlen($this->$prop ?? '')) {
$dbfield = $this->GetFieldFromProp(str_replace("_Equals", "", $prop));
$this->_where .= $this->_where_delim . " " . $dbfield . " = " . $this->GetQuotedSql($val) . "";
$this->_where_delim = " and";
} elseif (substr($prop, - 10) == "_NotEquals" && strlen($this->$prop)) {
} elseif (substr($prop, - 10) == "_NotEquals" && strlen($this->$prop ?? '')) {
$dbfield = $this->GetFieldFromProp(str_replace("_NotEquals", "", $prop));
$this->_where .= $this->_where_delim . " " . $dbfield . " != " . $this->GetQuotedSql($val) . "";
$this->_where_delim = " and";
} elseif (substr($prop, - 8) == "_IsEmpty" && $this->$prop) {
} elseif (substr($prop, - 8) == "_IsEmpty" && $this->$prop ?? '') {
$dbfield = $this->GetFieldFromProp(str_replace("_IsEmpty", "", $prop));
$this->_where .= $this->_where_delim . " " . $dbfield . " = ''";
$this->_where_delim = " and";
} elseif (substr($prop, - 11) == "_IsNotEmpty" && $this->$prop) {
} elseif (substr($prop, - 11) == "_IsNotEmpty" && $this->$prop ?? '') {
$dbfield = $this->GetFieldFromProp(str_replace("_IsNotEmpty", "", $prop));
$this->_where .= $this->_where_delim . " " . $dbfield . " != ''";
$this->_where_delim = " and";
} elseif (substr($prop, - 7) == "_IsLike" && strlen($this->$prop)) {
} elseif (substr($prop, - 7) == "_IsLike" && strlen($this->$prop ?? '')) {
$dbfield = $this->GetFieldFromProp(str_replace("_IsLike", "", $prop));
$this->_where .= $this->_where_delim . " " . $dbfield . " like '%" . $this->Escape($val) . "%'";
$this->_where_delim = " and";
} elseif (substr($prop, - 10) == "_IsNotLike" && strlen($this->$prop)) {
} elseif (substr($prop, - 10) == "_IsNotLike" && strlen($this->$prop ?? '')) {
$dbfield = $this->GetFieldFromProp(str_replace("_IsNotLike", "", $prop));
$this->_where .= $this->_where_delim . " " . $dbfield . " not like '%" . $this->Escape($val) . "%'";
$this->_where_delim = " and";
} elseif (substr($prop, - 11) == "_BeginsWith" && strlen($this->$prop)) {
} elseif (substr($prop, - 11) == "_BeginsWith" && strlen($this->$prop ?? '')) {
$dbfield = $this->GetFieldFromProp(str_replace("_BeginsWith", "", $prop));
$this->_where .= $this->_where_delim . " " . $dbfield . " like '" . $this->Escape($val) . "%'";
$this->_where_delim = " and";
} elseif (substr($prop, - 9) == "_EndsWith" && strlen($this->$prop)) {
} elseif (substr($prop, - 9) == "_EndsWith" && strlen($this->$prop ?? '')) {
$dbfield = $this->GetFieldFromProp(str_replace("_EndsWith", "", $prop));
$this->_where .= $this->_where_delim . " " . $dbfield . " like '%" . $this->Escape($val) . "'";
$this->_where_delim = " and";
} elseif (substr($prop, - 12) == "_GreaterThan" && strlen($this->$prop)) {
} elseif (substr($prop, - 12) == "_GreaterThan" && strlen($this->$prop ?? '')) {
$dbfield = $this->GetFieldFromProp(str_replace("_GreaterThan", "", $prop));
$this->_where .= $this->_where_delim . " " . $dbfield . " > " . $this->GetQuotedSql($val) . "";
$this->_where_delim = " and";
} elseif (substr($prop, - 19) == "_GreaterThanOrEqual" && strlen($this->$prop)) {
} elseif (substr($prop, - 19) == "_GreaterThanOrEqual" && strlen($this->$prop ?? '')) {
$dbfield = $this->GetFieldFromProp(str_replace("_GreaterThanOrEqual", "", $prop));
$this->_where .= $this->_where_delim . " " . $dbfield . " >= " . $this->GetQuotedSql($val) . "";
$this->_where_delim = " and";
} elseif (substr($prop, - 9) == "_LessThan" && strlen($this->$prop)) {
} elseif (substr($prop, - 9) == "_LessThan" && strlen($this->$prop ?? '')) {
$dbfield = $this->GetFieldFromProp(str_replace("_LessThan", "", $prop));
$this->_where .= $this->_where_delim . " " . $dbfield . " < " . $this->GetQuotedSql($val) . "";
$this->_where_delim = " and";
} elseif (substr($prop, - 16) == "_LessThanOrEqual" && strlen($this->$prop)) {
} elseif (substr($prop, - 16) == "_LessThanOrEqual" && strlen($this->$prop ?? '')) {
$dbfield = $this->GetFieldFromProp(str_replace("_LessThanOrEqual", "", $prop));
$this->_where .= $this->_where_delim . " " . $dbfield . " <= " . $this->GetQuotedSql($val) . "";
$this->_where_delim = " and";
} elseif (substr($prop, - 10) == "_BitwiseOr" && strlen($this->$prop)) {
} elseif (substr($prop, - 10) == "_BitwiseOr" && strlen($this->$prop ?? '')) {
$dbfield = $this->GetFieldFromProp(str_replace("_BitwiseOr", "", $prop));
$this->_where .= $this->_where_delim . " (" . $dbfield . " | '" . $this->Escape($val) . ")";
$this->_where_delim = " and";
} elseif (substr($prop, - 11) == "_BitwiseAnd" && strlen($this->$prop)) {
} elseif (substr($prop, - 11) == "_BitwiseAnd" && strlen($this->$prop ?? '')) {
$dbfield = $this->GetFieldFromProp(str_replace("_BitwiseAnd", "", $prop));
$this->_where .= $this->_where_delim . " (" . $dbfield . " & " . $this->Escape($val) . ")";
$this->_where_delim = " and";
} elseif (substr($prop, - 16) == "_LiteralFunction" && strlen($this->$prop)) {
} elseif (substr($prop, - 16) == "_LiteralFunction" && strlen($this->$prop ?? '')) {
$dbfield = $this->GetFieldFromProp(str_replace("_LiteralFunction", "", $prop));
$this->_where .= $this->_where_delim . " (" . $dbfield . " " . $val . ")";
$this->_where_delim = " and";
Expand Down
5 changes: 5 additions & 0 deletions portal/patient/fwk/libs/verysimple/Phreeze/DataPage.php
Expand Up @@ -46,10 +46,12 @@ class DataPage implements Iterator
*
* @return Phreezable
*/
#[\ReturnTypeWillChange]
public function Next()
{
return next($this->Rows);
}
#[\ReturnTypeWillChange]
public function rewind()
{
reset($this->Rows);
Expand All @@ -59,14 +61,17 @@ public function rewind()
*
* @return Phreezable
*/
#[\ReturnTypeWillChange]
public function current()
{
return current($this->Rows);
}
#[\ReturnTypeWillChange]
public function key()
{
return key($this->Rows);
}
#[\ReturnTypeWillChange]
public function valid()
{
return $this->current() !== false;
Expand Down
5 changes: 5 additions & 0 deletions portal/patient/fwk/libs/verysimple/Phreeze/DataSet.php
Expand Up @@ -93,6 +93,7 @@ private function _getObject(&$row)
* @access public
* @return Preezable
*/
#[\ReturnTypeWillChange]
function Next()
{
if ($this->UnableToCache) {
Expand Down Expand Up @@ -147,6 +148,7 @@ public function Execute()
{
return $this->_phreezer->DataAdapter->Execute($this->_sql);
}
#[\ReturnTypeWillChange]
public function rewind()
{
$this->_rs = null;
Expand All @@ -156,17 +158,20 @@ public function rewind()
$this->_verifyRs();
$this->Next(); // we have to get the party started for php iteration
}
#[\ReturnTypeWillChange]
public function current()
{
// php iteration calls next then gets the current record. The DataSet
// Next return the current object. so, we have to fudge a little on the
// laster iteration to make it work properly
return ($this->key() == $this->Count()) ? $this->_last : $this->_current;
}
#[\ReturnTypeWillChange]
public function key()
{
return $this->_counter;
}
#[\ReturnTypeWillChange]
public function valid()
{
return $this->key() <= $this->Count();
Expand Down
8 changes: 7 additions & 1 deletion portal/patient/fwk/libs/verysimple/Phreeze/Phreezable.php
Expand Up @@ -431,7 +431,7 @@ private function _DoBaseValidation()
break;
case FM_TYPE_DATE:
case FM_TYPE_DATETIME:
if (strtotime($this->$prop) === '') {
if (strtotime(($this->$prop ?? '')) === '') {
$this->AddValidationError($prop, "$prop is not a valid date/time value.");
}
break;
Expand Down Expand Up @@ -787,4 +787,10 @@ public function __set($key, $val)
{
throw new Exception("Unknown property: $key");
}

function __serialize()
{}

function __unserialize($data)
{}
}
6 changes: 6 additions & 0 deletions portal/patient/fwk/libs/verysimple/Phreeze/Reporter.php
Expand Up @@ -342,4 +342,10 @@ function Load(&$row)
protected function OnLoad()
{
}

function __serialize()
{}

function __unserialize($data)
{}
}
4 changes: 3 additions & 1 deletion portal/patient/libs/Controller/PortalPatientController.php
Expand Up @@ -195,7 +195,9 @@ public function Update()
$patient->Fitness = $this->SafeGetVal($json, 'fitness', $patient->Fitness);
$patient->ReferralSource = $this->SafeGetVal($json, 'referralSource', $patient->ReferralSource);
$patient->Pricelevel = $this->SafeGetVal($json, 'pricelevel', $patient->Pricelevel);*/
$patient->Regdate = date('Y-m-d', strtotime($this->SafeGetVal($json, 'regdate', $patient->Regdate)));
if (!empty($patient->Regdate)) {
$patient->Regdate = date('Y-m-d', strtotime($this->SafeGetVal($json, 'regdate', $patient->Regdate)));
}
/*$patient->Contrastart = date('Y-m-d', strtotime($this->SafeGetVal($json, 'contrastart', $patient->Contrastart)));
$patient->CompletedAd = $this->SafeGetVal($json, 'completedAd', $patient->CompletedAd);
$patient->AdReviewed = date('Y-m-d', strtotime($this->SafeGetVal($json, 'adReviewed', $patient->AdReviewed)));
Expand Down
15 changes: 11 additions & 4 deletions portal/patient/templates/OnsiteActivityViewListView.tpl.php
Expand Up @@ -10,11 +10,18 @@
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/

$this->assign('title', xlt('Portal') . ' | ' . xlt('Activity'));
$this->assign('nav', 'onsiteactivityviews');
$this->assign('title', xlt('Portal') . ' | ' . xlt('Activity'));
$this->assign('nav', 'onsiteactivityviews');

$this->display('_FormsHeader.tpl.php');
echo "<script>var cuser='" . $this->cuser . "';</script>";
use OpenEMR\Common\Acl\AclMain;

if (!AclMain::aclCheckCore('patientportal', 'portal')) {
die(xlt("Unauthorized"));
exit;
}

$this->display('_FormsHeader.tpl.php');
echo "<script>var cuser='" . $this->cuser . "';</script>";
?>
<script>
$LAB.script("<?php echo $GLOBALS['web_root']; ?>/portal/patient/scripts/app/onsiteactivityviews.js?v=<?php echo $GLOBALS['v_js_includes']; ?>").wait(function(){
Expand Down
6 changes: 6 additions & 0 deletions portal/patient/templates/ProviderHome.tpl.php
Expand Up @@ -13,8 +13,14 @@
$this->assign('title', xlt("Portal Dashboard") . " | " . xlt("Home"));
$this->assign('nav', 'home');

use OpenEMR\Common\Acl\AclMain;
use OpenEMR\Core\Header;

if (!AclMain::aclCheckCore('patientportal', 'portal')) {
die(xlt("Unauthorized"));
exit;
}

?>
<!DOCTYPE html>
<!-- Language grabbed by PDF var that has the correct format !-->
Expand Down
2 changes: 1 addition & 1 deletion portal/report/portal_patient_report.php
Expand Up @@ -470,7 +470,7 @@ function show_date_fun(){
if ($result["form_name"] == "New Patient Encounter") {
if ($isfirst == 0) {
foreach ($registry_form_name as $var) {
if ($toprint = $html_strings[$var]) {
if ($toprint = ($html_strings[$var] ?? '')) {
foreach ($toprint as $var) {
print $var;
}
Expand Down
12 changes: 12 additions & 0 deletions portal/sign/lib/save-signature.php
Expand Up @@ -39,6 +39,18 @@
}
require_once("../../../interface/globals.php");

if (!$isPortal) {
$userManipulatedFlag = false;
if ($user != $_SESSION['authUserID']) {
$userManipulatedFlag = true;
}

if ($userManipulatedFlag) {
echo js_escape("error");
exit();
}
}

if ($type === 'witness-signature') {
echo(js_escape('Done'));
exit();
Expand Down
22 changes: 17 additions & 5 deletions portal/sign/lib/show-signature.php
Expand Up @@ -38,6 +38,18 @@
}
require_once("../../../interface/globals.php");

if (!$isPortal) {
$userManipulatedFlag = false;
if ($user != $_SESSION['authUserID']) {
$userManipulatedFlag = true;
}

if ($userManipulatedFlag) {
echo js_escape("error");
exit();
}
}

$created = time();
$lastmod = date('Y-m-d H:i:s');
$status = 'filed';
Expand All @@ -57,7 +69,7 @@
}
}

if ($data['mode'] === 'fetch_info') {
if (($data['mode'] ?? null) === 'fetch_info') {
$stmt = "Select CONCAT(IFNULL(fname,''), ' ',IFNULL(lname,'')) as userName From users Where id = ?";
$user_result = sqlQuery($stmt, array($user)) ?: [];
$stmt = "Select CONCAT(IFNULL(fname,''), ' ',IFNULL(lname,'')) as ptName From patient_data Where pid = ?";
Expand Down Expand Up @@ -87,20 +99,20 @@
$row = sqlQuery("SELECT pid,status,sig_image,type,user FROM onsite_signatures WHERE pid=? And user=?", array($req_pid, $user));
}

if (!$row['pid'] && !$row['user']) {
if (!($row['pid'] ?? null) && !($row['user'] ?? null)) {
$status = 'waiting';
$qstr = "INSERT INTO onsite_signatures (pid,lastmod,status,type,user,signator,created) VALUES (?,?,?,?,?,?,?)";
sqlStatement($qstr, array($req_pid, $lastmod, $status, $type, $user, $signer, $created));
}

if ($row['status'] == 'filed') {
if ($data['mode'] === 'fetch_info') {
if (($row['status'] ?? null) == 'filed') {
if (($data['mode'] ?? null) === 'fetch_info') {
$info_query['signature'] = $row['sig_image'];
echo js_escape($info_query);
exit();
}
echo js_escape($row['sig_image']);
} elseif ($row['status'] == 'waiting' || $status == 'waiting') {
} elseif (($row['status'] ?? null) == 'waiting' || $status == 'waiting') {
$info_query['message'] = 'waiting';
echo js_escape($info_query);
}
Expand Down
3 changes: 3 additions & 0 deletions src/Gacl/Gacl.php
Expand Up @@ -566,6 +566,9 @@ function acl_query($aco_section_value, $aco_value, $aro_section_value, $aro_valu
} else {
if ($return_all) {
// Permission denied.
if(!is_array($retarr)) {
$retarr = [];
}
$retarr[] = array('acl_id' => NULL, 'return_value' => NULL, 'allow' => FALSE);
}
else {
Expand Down

0 comments on commit c5d9945

Please sign in to comment.