bradymiller wrote on Friday, March 20, 2009:
hey,
I think I got it. Had to modify three files and unclear of the repercussions, so will delay committing this to CVS until after the next bug release (3.0.1). Here are manual changes required in case you want earlier:
FILE openemr/controllers/C_Document.class.php :
LINE 201 :
REPLACE :
function retrieve_action($patient_id="",$document_id,$as_file=true) {
WITH :
> function retrieve_action($patient_id="",$document_id,$as_file=true,$original_file=true) {
//controller function ruins booleans, so need to manually re-convert to booleans
if ($as_file == "true") {
$as_file=true;
}
else if ($as_file == "false") {
$as_file=false;
}
if ($original_file == "true") {
$original_file=true;
}
else if ($original_file == "false") {
$original_file=false;
}
LINE 219 :
REPLACE :
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Disposition: " . ($as_file ? "attachment" : "inline") . "; filename="" . basename($d->get_url()) . """);
header("Content-Type: " . $d->get_mimetype());
header("Content-Length: " . $d->get_size());
$f = fopen($url,"r");
fpassthru($f);
exit;
WITH :
if ($original_file) {
//normal case when serving the file referenced in database
header(“Pragma: public”);
header(“Expires: 0”);
header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);
header("Content-Disposition: " . ($as_file ? “attachment” : “inline”) . “; filename="” . basename($d->get_url()) . “"”);
header("Content-Type: " . $d->get_mimetype());
header("Content-Length: " . $d->get_size());
$f = fopen($url,“r”);
fpassthru($f);
exit;
}
else {
//special case when retrieving a document that has been converted to a jpg and not directly referenced in database
$convertedFile = substr(basename($url), 0, strrpos(basename($url), ‘.’)) . ‘_converted.jpg’;
$url = $GLOBALS[“fileroot”].’/documents/’.$_SESSION[“pid”].’/’.$convertedFile;
header(“Pragma: public”);
header(“Expires: 0”);
header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);
header("Content-Disposition: " . ($as_file ? “attachment” : “inline”) . “; filename="” . basename($url) . “"”);
header(“Content-Type: image/jpeg”);
header("Content-Length: " . filesize($url));
$f = fopen($url,“r”);
fpassthru($f);
exit;
}
FILE openemr/interface/patient_file/report/custom_report.php :
LINE 296 :
REPLACE :
echo ‘<img src="’ . $GLOBALS[‘webroot’] . “/controller.php?document&retrieve&patient_id=&document_id=” . $document_id . ‘"><br><br>’;
WITH :
echo “<img src=’” . $GLOBALS[‘webroot’] . “/controller.php?document&retrieve&patient_id=&document_id=” . $document_id . “&as_file=false’><br><br>”;
LINE 305 :
REPLACE :
$to_url = $GLOBALS[‘webroot’] . “/documents/$pid/” . basename($to_file);
echo “<img src=’$to_url’><br><br>\n”;
WITH :
echo “<img src=’” . $GLOBALS[‘webroot’] . “/controller.php?document&retrieve&patient_id=&document_id=” . $document_id . “&as_file=false&original_file=false’><br><br>”;
FILE openemr/templates/documents/general_view.html :
LINE 77 :
REPLACE :
<iframe frameborder="0" type="{$file->get_mimetype()}" src="{$web_path}{$file->get_url_web()}&as_file=false"></iframe>
WITH :
<iframe frameborder="0" type="{$file->get_mimetype()}" src="{$web_path}as_file=false"></iframe>
ALL DONE