BUG 6216 Impossible to get input document in tracker SOLVED
- Incorrect business logic to get the file to download - Fix the business logic to get the file
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* cases_ShowDocument.php
|
* tracker_ShowDocument.php
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||||
@@ -22,33 +22,64 @@
|
|||||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
* Created on 13-02-2008
|
|
||||||
*
|
|
||||||
* @author David Callizaya <davidsantos@colosa.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!isset($_SESSION['PROCESS'])) {
|
require_once ( "classes/model/AppDocumentPeer.php" );
|
||||||
G::header('location: login');
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once 'classes/model/AppDocumentPeer.php';
|
|
||||||
|
|
||||||
$oAppDocument = new AppDocument();
|
$oAppDocument = new AppDocument();
|
||||||
$oAppDocument->Fields = $oAppDocument->load($_GET['a']);
|
if(!isset($_GET['v'])){//Load last version of the document
|
||||||
|
$docVersion=$oAppDocument->getLastAppDocVersion($_GET['a']);
|
||||||
|
}else{
|
||||||
|
$docVersion=$_GET['v'];
|
||||||
|
}
|
||||||
|
$oAppDocument->Fields = $oAppDocument->load($_GET['a'],$docVersion);
|
||||||
|
|
||||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
$sAppDocUid = $oAppDocument->getAppDocUid();
|
||||||
$info = pathinfo($oAppDocument->getAppDocFilename());
|
|
||||||
$iDocVersion = $oAppDocument->getDocVersion();
|
$iDocVersion = $oAppDocument->getDocVersion();
|
||||||
|
$info = pathinfo( $oAppDocument->getAppDocFilename() );
|
||||||
$ext = $info['extension'];
|
$ext = $info['extension'];
|
||||||
|
|
||||||
$realPath = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/' . $sAppDocUid .'_'.$iDocVersion . '.' . $ext;
|
if (isset($_GET['b'])) {
|
||||||
if (!file_exists($realPath)) {
|
if ($_GET['b'] == '0') {
|
||||||
$realPath = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/' . $sAppDocUid . '.' . $ext;
|
$bDownload = false;
|
||||||
}
|
}
|
||||||
if (!file_exists($realPath)) {
|
else {
|
||||||
G::streamFile($realPath, true, $oAppDocument->Fields['APP_DOC_FILENAME']);
|
$bDownload = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
die("'" . $oAppDocument->Fields['APP_DOC_FILENAME'] . "' " . G::LoadTranslation('ID_ERROR_STREAMING_FILE'));
|
$bDownload = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$realPath = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/' . $sAppDocUid .'_'.$iDocVersion . '.' . $ext ;
|
||||||
|
$realPath1 = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/' . $sAppDocUid . '.' . $ext ;
|
||||||
|
$sw_file_exists=false;
|
||||||
|
if(file_exists($realPath)){
|
||||||
|
$sw_file_exists=true;
|
||||||
|
}elseif(file_exists($realPath1)){
|
||||||
|
$sw_file_exists=true;
|
||||||
|
$realPath=$realPath1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$sw_file_exists){
|
||||||
|
$error_message="'".$oAppDocument->Fields['APP_DOC_FILENAME']. "' ".G::LoadTranslation('ID_ERROR_STREAMING_FILE');
|
||||||
|
if((isset($_POST['request']))&&($_POST['request']==true)){
|
||||||
|
$res ['success'] = 'failure';
|
||||||
|
$res ['message'] = $error_message;
|
||||||
|
print G::json_encode ( $res );
|
||||||
|
}else{
|
||||||
|
G::SendMessageText($error_message, "ERROR");
|
||||||
|
$backUrlObj=explode("sys".SYS_SYS,$_SERVER['HTTP_REFERER']);
|
||||||
|
G::header("location: "."/sys".SYS_SYS.$backUrlObj[1]);
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
if((isset($_POST['request']))&&($_POST['request']==true)){
|
||||||
|
$res ['success'] = 'success';
|
||||||
|
$res ['message'] = $oAppDocument->Fields['APP_DOC_FILENAME'];
|
||||||
|
print G::json_encode ( $res );
|
||||||
|
}else{
|
||||||
|
G::streamFile ( $realPath, $bDownload, $oAppDocument->Fields['APP_DOC_FILENAME'] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user