BUG 7306 Case Tracker download documents doesnt work, shows 404 Not Found page.

The file workflow/engine/methods/tracker/tracker_ShowOutputDocument.php was incomplete, there were not some validations like versioning, and there were not taking into account the extension of the file to download. I add those validations, taking like example the file /workflow/engine/methods/cases/cases_ShowOutputDocument.php
This commit is contained in:
jennylee
2012-09-28 14:35:39 -04:00
parent eb0879ce91
commit 7a23d26106
3 changed files with 87 additions and 54 deletions

View File

@@ -152,6 +152,7 @@ try {
$aOD = $oOutputDocument->load($aFields['DOC_UID']);
$oCriteria = new Criteria('workflow');
$oCriteria->add(AppDelegationPeer::APP_UID, $aFields['APP_UID']);
$oCriteria->add(AppDelegationPeer::DEL_INDEX, $aFields['DEL_INDEX']);
$oDataset = AppDelegationPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);

View File

@@ -27,31 +27,63 @@
*
* @author David Callizaya <davidsantos@colosa.com>
*/
if (!isset($_SESSION['PROCESS']))
{
G::header('location: login');
}
require_once ( "classes/model/AppDocumentPeer.php" );
require_once ( "classes/model/AppDocumentPeer.php" );
$oAppDocument = new AppDocument();
$oAppDocument->Fields = $oAppDocument->load($_GET['a'],(isset($_GET['v']) )? $_GET['v'] : NULL );
$oAppDocument = new AppDocument();
$oAppDocument->Fields = $oAppDocument->load($_GET['a']);
$sAppDocUid = $oAppDocument->getAppDocUid();
$info = pathinfo( $oAppDocument->getAppDocFilename() );
if (!isset($_GET['ext'])) {
$sAppDocUid = $oAppDocument->getAppDocUid();
$info = pathinfo( $oAppDocument->getAppDocFilename() );
if (!isset($_GET['ext'])) {
$ext = $info['extension'];
}
else {
}
else {
if ($_GET['ext'] != '') {
$ext = $_GET['ext'];
}
else {
$ext = $info['extension'];
}
}
$ver= (isset($_GET['v']) && $_GET['v']!='') ? '_'.$_GET['v'] : '';
if(!$ver) //This code is in the case the outputdocument won't be versioned
$ver='_1';
$realPath = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $sAppDocUid .$ver. '.' . $ext ;
$realPath1 = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $info['basename'] .$ver. '.' . $ext ;
$realPath2 = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $info['basename']. '.' . $ext ;
$sw_file_exists=false;
if(file_exists($realPath)){
$sw_file_exists=true;
}elseif(file_exists($realPath1)){
$sw_file_exists=true;
$realPath=$realPath1;
}elseif(file_exists($realPath2)){
$sw_file_exists=true;
$realPath=$realPath2;
}
if(!$sw_file_exists){
$error_message="'".$info['basename'] .$ver. '.' . $ext."' ".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;
}
$realPath = PATH_DOCUMENT . $_SESSION['APPLICATION'] . '/outdocs/' . $info['basename'] . '.' . $ext ;
G::streamFile ( $realPath, true );
}else{
if((isset($_POST['request']))&&($_POST['request']==true)){
$res ['success'] = 'success';
$res ['message'] = $info['basename'] .$ver. '.' . $ext;
print G::json_encode ( $res );
}else{
G::streamFile ( $realPath, true ,$info['basename'] .$ver. '.' . $ext );
}
}
//G::streamFile ( $realPath, true);
?>