Skip to content

Commit

Permalink
bug fix (#5207)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradymiller committed Apr 20, 2022
1 parent b11a160 commit 8f8a977
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
4 changes: 3 additions & 1 deletion interface/patient_file/summary/demographics.php
Expand Up @@ -1111,6 +1111,8 @@ function setMyPatient() {
endif; //end if prw is activated

if (AclMain::aclCheckCore('patients', 'disclosure')) :
$authWriteDisclosure = AclMain::aclCheckCore('patients', 'disclosure', '', 'write');
$authAddonlyDisclosure = AclMain::aclCheckCore('patients', 'disclosure', '', 'addonly');
$dispatchResult = $ed->dispatch(CardRenderEvent::EVENT_HANDLE, new CardRenderEvent('disclosure'));
// disclosures expand collapse widget
$id = "disclosures_ps_expand";
Expand All @@ -1122,7 +1124,7 @@ function setMyPatient() {
'btnLink' => 'disclosure_full.php',
'linkMethod' => 'html',
'bodyClass' => 'notab collapse show',
'auth' => AclMain::aclCheckCore('patients', 'disclosure', '', 'write'),
'auth' => ($authWriteDisclosure || $authAddonlyDisclosure),
'prependedInjection' => $dispatchResult->getPrependedInjection(),
'appendedInjection' => $dispatchResult->getAppendedInjection(),
];
Expand Down
32 changes: 29 additions & 3 deletions interface/patient_file/summary/disclosure_full.php
Expand Up @@ -15,10 +15,19 @@
require_once("../../globals.php");
require_once("$srcdir/options.inc.php");

use OpenEMR\Common\Acl\AclMain;
use OpenEMR\Common\Csrf\CsrfUtils;
use OpenEMR\Common\Logging\EventAuditLogger;
use OpenEMR\Core\Header;

// Control access
if (!AclMain::aclCheckCore('patients', 'disclosure')) {
echo xlt('Not Authorized');
exit;
}
$authWrite = AclMain::aclCheckCore('patients', 'disclosure', '', 'write');
$authAddonly = AclMain::aclCheckCore('patients', 'disclosure', '', 'addonly');

//retrieve the user name
$res = sqlQuery("select username from users where username=?", array($_SESSION["authUser"]));
$uname = $res["username"];
Expand All @@ -34,9 +43,17 @@
$disclosure_desc = trim($_POST['desc_disc']);
$disclosure_id = trim($_POST['disclosure_id'] ?? '');
if (isset($_POST["updatemode"]) and $_POST["updatemode"] == "disclosure_update") {
if (!$authWrite) {
echo xlt('Not Authorized');
exit;
}
//update the recorded disclosure in the extended_log table.
EventAuditLogger::instance()->updateRecordedDisclosure($dates, $event, $recipient_name, $disclosure_desc, $disclosure_id);
} else {
if (!$authWrite && !$authAddonly) {
echo xlt('Not Authorized');
exit;
}
//insert the disclosure records in the extended_log table.
EventAuditLogger::instance()->recordDisclosure($dates, $event, $pid, $recipient_name, $disclosure_desc, $uname);
}
Expand All @@ -49,6 +66,11 @@
CsrfUtils::csrfNotVerified();
}

if (!$authWrite) {
echo xlt('Not Authorized');
exit;
}

$deletelid = $_GET['deletelid'];
//function to delete the recorded disclosures
EventAuditLogger::instance()->deleteDisclosure($deletelid);
Expand All @@ -75,7 +97,9 @@
</h2>
</div>
<div class="col-12">
<a href="record_disclosure.php" class="btn btn-primary iframe" onclick="top.restoreSession()"><?php echo xlt('Record'); ?></a>
<?php if ($authWrite || $authAddonly) { ?>
<a href="record_disclosure.php" class="btn btn-primary iframe" onclick="top.restoreSession()"><?php echo xlt('Record'); ?></a>
<?php } ?>
<a href="demographics.php" class="btn btn-primary" onclick="top.restoreSession()"> <?php echo xlt('View Patient') ?></a>
</div>
<div class="col-12 jumbotron mt-3 p-4">
Expand Down Expand Up @@ -125,8 +149,10 @@
<tr class="noterow" height='25'>
<!--buttons for edit and delete.-->
<td class="align-top text-nowrap">
<a href='record_disclosure.php?editlid=<?php echo attr_url($iter['id']); ?>' class='btn btn-primary btn-sm btn-edit iframe' onclick='top.restoreSession()'><?php echo xlt('Edit');?></a>
<a href='#' class='deletenote btn btn-danger btn-delete btn-sm' id='<?php echo attr($iter['id']); ?>' onclick='top.restoreSession()'><?php echo xlt('Delete');?></a>
<?php if ($authWrite) { ?>
<a href='record_disclosure.php?editlid=<?php echo attr_url($iter['id']); ?>' class='btn btn-primary btn-sm btn-edit iframe' onclick='top.restoreSession()'><?php echo xlt('Edit');?></a>
<a href='#' class='deletenote btn btn-danger btn-delete btn-sm' id='<?php echo attr($iter['id']); ?>' onclick='top.restoreSession()'><?php echo xlt('Delete');?></a>
<?php } ?>
</td>
<td class="align-top" valign='top'><?php echo text($iter['recipient']);?>&nbsp;</td>
<td class='align-top' valign='top'><?php echo text(getListItemTitle('disclosure_type', $iter['event'])); ?>&nbsp;</td>
Expand Down
13 changes: 13 additions & 0 deletions interface/patient_file/summary/record_disclosure.php
Expand Up @@ -15,11 +15,24 @@
require_once("../../globals.php");
require_once("$srcdir/options.inc.php");

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

// Control access
$authWrite = AclMain::aclCheckCore('patients', 'disclosure', '', 'write');
$authAddonly = AclMain::aclCheckCore('patients', 'disclosure', '', 'addonly');
if (!$authWrite && !$authAddonly) {
echo xlt('Not Authorized');
exit;
}

//if the edit button for editing disclosure is set.
if (isset($_GET['editlid'])) {
if (!$authWrite) {
echo xlt('Not Authorized');
exit;
}
$editlid = $_GET['editlid'];
}
?>
Expand Down

0 comments on commit 8f8a977

Please sign in to comment.