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:
@@ -87,7 +87,7 @@ try {
|
||||
require_once 'classes/model/Users.php';
|
||||
$oAppDocument = new AppDocument();
|
||||
$oAppDocument->Fields = $oAppDocument->load($_POST['APP_DOC_UID']);
|
||||
|
||||
|
||||
$oInputDocument = new InputDocument();
|
||||
if ($oAppDocument->Fields['DOC_UID'] != -1) {
|
||||
$Fields = $oInputDocument->load($oAppDocument->Fields['DOC_UID']);
|
||||
@@ -124,20 +124,20 @@ try {
|
||||
}
|
||||
$oAppDocument->Fields['VIEW'] = G::LoadTranslation('ID_OPEN');
|
||||
$oAppDocument->Fields['FILE'] = 'tracker_ShowDocument?a=' . $_POST['APP_DOC_UID'] . '&r=' . rand();
|
||||
|
||||
|
||||
//If plugin and trigger are defined for listing
|
||||
if ( $oPluginRegistry->existsTrigger ( PM_CASE_DOCUMENT_LIST_ARR ) ) {
|
||||
if ( $oPluginRegistry->existsTrigger ( PM_CASE_DOCUMENT_LIST_ARR ) ) {
|
||||
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
||||
$filesPluginArray=$oPluginRegistry->executeTriggers ( PM_CASE_DOCUMENT_LIST_ARR , $_SESSION['APPLICATION'] );
|
||||
$filesPluginArray=$oPluginRegistry->executeTriggers ( PM_CASE_DOCUMENT_LIST_ARR , $_SESSION['APPLICATION'] );
|
||||
//Now search for the file, if exists the change the download URL
|
||||
foreach($filesPluginArray as $file){
|
||||
if($file->filename==$_POST['APP_DOC_UID']){
|
||||
$oAppDocument->Fields['FILE'] = $file->downloadScript;
|
||||
foreach($filesPluginArray as $file){
|
||||
if($file->filename==$_POST['APP_DOC_UID']){
|
||||
$oAppDocument->Fields['FILE'] = $file->downloadScript;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$G_PUBLISH = new Publisher;
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', $sXmlForm, '', G::array_merges($Fields, $oAppDocument->Fields), '');
|
||||
G::RenderPage('publish', 'raw');
|
||||
@@ -150,8 +150,9 @@ try {
|
||||
require_once 'classes/model/OutputDocument.php';
|
||||
$oOutputDocument = new OutputDocument();
|
||||
$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);
|
||||
@@ -167,22 +168,22 @@ try {
|
||||
$aFields['VIEW'] = G::LoadTranslation('ID_OPEN');
|
||||
$aFields['FILE1'] = 'tracker_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&ext=doc&random=' . rand();
|
||||
$aFields['FILE2'] = 'tracker_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&ext=pdf&random=' . rand();
|
||||
|
||||
|
||||
|
||||
|
||||
//If plugin and trigger are defined for listing
|
||||
if ( $oPluginRegistry->existsTrigger ( PM_CASE_DOCUMENT_LIST_ARR ) ) {
|
||||
if ( $oPluginRegistry->existsTrigger ( PM_CASE_DOCUMENT_LIST_ARR ) ) {
|
||||
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
||||
$filesPluginArray=$oPluginRegistry->executeTriggers ( PM_CASE_DOCUMENT_LIST_ARR , $aFields['APP_UID'] );
|
||||
//Now search for the file, if exists the change the download URL
|
||||
foreach($filesPluginArray as $file){
|
||||
if($file->filename==$_POST['APP_DOC_UID']){
|
||||
$filesPluginArray=$oPluginRegistry->executeTriggers ( PM_CASE_DOCUMENT_LIST_ARR , $aFields['APP_UID'] );
|
||||
//Now search for the file, if exists the change the download URL
|
||||
foreach($filesPluginArray as $file){
|
||||
if($file->filename==$_POST['APP_DOC_UID']){
|
||||
$aFields['FILE2'] = $file->downloadScript;// The PDF is the only one uploaded to KT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'tracker/tracker_ViewAnyOutputDocument', '', G::array_merges($aOD, $aFields), '');
|
||||
G::RenderPage('publish', 'raw');
|
||||
@@ -311,10 +312,10 @@ try {
|
||||
}
|
||||
$oStage = new Stage();
|
||||
$oNewStage->label = G::LoadTranslation('ID_STAGE') . ' ' . $iStageNumber;
|
||||
|
||||
|
||||
if($oData->position->x < 0) $oData->position->x *= -1;
|
||||
if($oData->position->y < 0) $oData->position->y *= -1;
|
||||
|
||||
|
||||
$oNewStage->uid = $oStage->create(array('PRO_UID' => $oData->uid, 'STG_TITLE' => $oNewStage->label, 'STG_POSX' => $oData->position->x, 'STG_POSY' => $oData->position->y, 'STG_INDEX' => $iIndex));
|
||||
$oJSON = new Services_JSON();
|
||||
echo $oJSON->encode($oNewStage);
|
||||
@@ -420,7 +421,7 @@ try {
|
||||
$oCriteria2->add(TaskPeer::STG_UID, '');
|
||||
BasePeer::doUpdate($oCriteria1, $oCriteria2, Propel::getConnection('workflow'));
|
||||
break;
|
||||
|
||||
|
||||
case "processMapLegend":
|
||||
$arrayField = array();
|
||||
$arrayField["sLabel1"] = G::LoadTranslation("ID_TASK_IN_PROGRESS");
|
||||
@@ -428,7 +429,7 @@ try {
|
||||
$arrayField["sLabel3"] = G::LoadTranslation("ID_PENDING_TASK");
|
||||
$arrayField["sLabel4"] = G::LoadTranslation("ID_PARALLEL_TASK");
|
||||
$arrayField["tracker"] = 1;
|
||||
|
||||
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent("smarty", "cases/cases_Leyends", "", "", $arrayField);
|
||||
G::RenderPage("publish", "raw");
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* cases_ShowOutputDocument.php
|
||||
*
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
@@ -14,44 +14,76 @@
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* 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']))
|
||||
{
|
||||
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']);
|
||||
$oAppDocument = new AppDocument();
|
||||
$oAppDocument->Fields = $oAppDocument->load($_GET['a'],(isset($_GET['v']) )? $_GET['v'] : NULL );
|
||||
|
||||
$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 {
|
||||
if ($_GET['ext'] != '') {
|
||||
$ext = $_GET['ext'];
|
||||
}
|
||||
else {
|
||||
$ext = $info['extension'];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($_GET['ext'] != '') {
|
||||
$ext = $_GET['ext'];
|
||||
}
|
||||
else {
|
||||
$ext = $info['extension'];
|
||||
}
|
||||
}
|
||||
$ver= (isset($_GET['v']) && $_GET['v']!='') ? '_'.$_GET['v'] : '';
|
||||
|
||||
$realPath = PATH_DOCUMENT . $_SESSION['APPLICATION'] . '/outdocs/' . $info['basename'] . '.' . $ext ;
|
||||
G::streamFile ( $realPath, true );
|
||||
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;
|
||||
}
|
||||
|
||||
}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);
|
||||
?>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<en>Output document</en>
|
||||
</OUT_DOC_TITLE>
|
||||
|
||||
|
||||
|
||||
|
||||
<APP_DOC_CREATE_DATE type="caption">
|
||||
<en>Create Date</en>
|
||||
|
||||
Reference in New Issue
Block a user