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';
|
require_once 'classes/model/Users.php';
|
||||||
$oAppDocument = new AppDocument();
|
$oAppDocument = new AppDocument();
|
||||||
$oAppDocument->Fields = $oAppDocument->load($_POST['APP_DOC_UID']);
|
$oAppDocument->Fields = $oAppDocument->load($_POST['APP_DOC_UID']);
|
||||||
|
|
||||||
$oInputDocument = new InputDocument();
|
$oInputDocument = new InputDocument();
|
||||||
if ($oAppDocument->Fields['DOC_UID'] != -1) {
|
if ($oAppDocument->Fields['DOC_UID'] != -1) {
|
||||||
$Fields = $oInputDocument->load($oAppDocument->Fields['DOC_UID']);
|
$Fields = $oInputDocument->load($oAppDocument->Fields['DOC_UID']);
|
||||||
@@ -124,20 +124,20 @@ try {
|
|||||||
}
|
}
|
||||||
$oAppDocument->Fields['VIEW'] = G::LoadTranslation('ID_OPEN');
|
$oAppDocument->Fields['VIEW'] = G::LoadTranslation('ID_OPEN');
|
||||||
$oAppDocument->Fields['FILE'] = 'tracker_ShowDocument?a=' . $_POST['APP_DOC_UID'] . '&r=' . rand();
|
$oAppDocument->Fields['FILE'] = 'tracker_ShowDocument?a=' . $_POST['APP_DOC_UID'] . '&r=' . rand();
|
||||||
|
|
||||||
//If plugin and trigger are defined for listing
|
//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();
|
$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
|
//Now search for the file, if exists the change the download URL
|
||||||
foreach($filesPluginArray as $file){
|
foreach($filesPluginArray as $file){
|
||||||
if($file->filename==$_POST['APP_DOC_UID']){
|
if($file->filename==$_POST['APP_DOC_UID']){
|
||||||
$oAppDocument->Fields['FILE'] = $file->downloadScript;
|
$oAppDocument->Fields['FILE'] = $file->downloadScript;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$G_PUBLISH = new Publisher;
|
$G_PUBLISH = new Publisher;
|
||||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', $sXmlForm, '', G::array_merges($Fields, $oAppDocument->Fields), '');
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', $sXmlForm, '', G::array_merges($Fields, $oAppDocument->Fields), '');
|
||||||
G::RenderPage('publish', 'raw');
|
G::RenderPage('publish', 'raw');
|
||||||
@@ -150,8 +150,9 @@ try {
|
|||||||
require_once 'classes/model/OutputDocument.php';
|
require_once 'classes/model/OutputDocument.php';
|
||||||
$oOutputDocument = new OutputDocument();
|
$oOutputDocument = new OutputDocument();
|
||||||
$aOD = $oOutputDocument->load($aFields['DOC_UID']);
|
$aOD = $oOutputDocument->load($aFields['DOC_UID']);
|
||||||
|
|
||||||
$oCriteria = new Criteria('workflow');
|
$oCriteria = new Criteria('workflow');
|
||||||
|
$oCriteria->add(AppDelegationPeer::APP_UID, $aFields['APP_UID']);
|
||||||
$oCriteria->add(AppDelegationPeer::DEL_INDEX, $aFields['DEL_INDEX']);
|
$oCriteria->add(AppDelegationPeer::DEL_INDEX, $aFields['DEL_INDEX']);
|
||||||
$oDataset = AppDelegationPeer::doSelectRS($oCriteria);
|
$oDataset = AppDelegationPeer::doSelectRS($oCriteria);
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
@@ -167,22 +168,22 @@ try {
|
|||||||
$aFields['VIEW'] = G::LoadTranslation('ID_OPEN');
|
$aFields['VIEW'] = G::LoadTranslation('ID_OPEN');
|
||||||
$aFields['FILE1'] = 'tracker_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&ext=doc&random=' . rand();
|
$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();
|
$aFields['FILE2'] = 'tracker_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&ext=pdf&random=' . rand();
|
||||||
|
|
||||||
|
|
||||||
//If plugin and trigger are defined for listing
|
//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();
|
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
||||||
$filesPluginArray=$oPluginRegistry->executeTriggers ( PM_CASE_DOCUMENT_LIST_ARR , $aFields['APP_UID'] );
|
$filesPluginArray=$oPluginRegistry->executeTriggers ( PM_CASE_DOCUMENT_LIST_ARR , $aFields['APP_UID'] );
|
||||||
//Now search for the file, if exists the change the download URL
|
//Now search for the file, if exists the change the download URL
|
||||||
foreach($filesPluginArray as $file){
|
foreach($filesPluginArray as $file){
|
||||||
if($file->filename==$_POST['APP_DOC_UID']){
|
if($file->filename==$_POST['APP_DOC_UID']){
|
||||||
$aFields['FILE2'] = $file->downloadScript;// The PDF is the only one uploaded to KT
|
$aFields['FILE2'] = $file->downloadScript;// The PDF is the only one uploaded to KT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$G_PUBLISH = new Publisher();
|
$G_PUBLISH = new Publisher();
|
||||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'tracker/tracker_ViewAnyOutputDocument', '', G::array_merges($aOD, $aFields), '');
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'tracker/tracker_ViewAnyOutputDocument', '', G::array_merges($aOD, $aFields), '');
|
||||||
G::RenderPage('publish', 'raw');
|
G::RenderPage('publish', 'raw');
|
||||||
@@ -311,10 +312,10 @@ try {
|
|||||||
}
|
}
|
||||||
$oStage = new Stage();
|
$oStage = new Stage();
|
||||||
$oNewStage->label = G::LoadTranslation('ID_STAGE') . ' ' . $iStageNumber;
|
$oNewStage->label = G::LoadTranslation('ID_STAGE') . ' ' . $iStageNumber;
|
||||||
|
|
||||||
if($oData->position->x < 0) $oData->position->x *= -1;
|
if($oData->position->x < 0) $oData->position->x *= -1;
|
||||||
if($oData->position->y < 0) $oData->position->y *= -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));
|
$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();
|
$oJSON = new Services_JSON();
|
||||||
echo $oJSON->encode($oNewStage);
|
echo $oJSON->encode($oNewStage);
|
||||||
@@ -420,7 +421,7 @@ try {
|
|||||||
$oCriteria2->add(TaskPeer::STG_UID, '');
|
$oCriteria2->add(TaskPeer::STG_UID, '');
|
||||||
BasePeer::doUpdate($oCriteria1, $oCriteria2, Propel::getConnection('workflow'));
|
BasePeer::doUpdate($oCriteria1, $oCriteria2, Propel::getConnection('workflow'));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "processMapLegend":
|
case "processMapLegend":
|
||||||
$arrayField = array();
|
$arrayField = array();
|
||||||
$arrayField["sLabel1"] = G::LoadTranslation("ID_TASK_IN_PROGRESS");
|
$arrayField["sLabel1"] = G::LoadTranslation("ID_TASK_IN_PROGRESS");
|
||||||
@@ -428,7 +429,7 @@ try {
|
|||||||
$arrayField["sLabel3"] = G::LoadTranslation("ID_PENDING_TASK");
|
$arrayField["sLabel3"] = G::LoadTranslation("ID_PENDING_TASK");
|
||||||
$arrayField["sLabel4"] = G::LoadTranslation("ID_PARALLEL_TASK");
|
$arrayField["sLabel4"] = G::LoadTranslation("ID_PARALLEL_TASK");
|
||||||
$arrayField["tracker"] = 1;
|
$arrayField["tracker"] = 1;
|
||||||
|
|
||||||
$G_PUBLISH = new Publisher();
|
$G_PUBLISH = new Publisher();
|
||||||
$G_PUBLISH->AddContent("smarty", "cases/cases_Leyends", "", "", $arrayField);
|
$G_PUBLISH->AddContent("smarty", "cases/cases_Leyends", "", "", $arrayField);
|
||||||
G::RenderPage("publish", "raw");
|
G::RenderPage("publish", "raw");
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* cases_ShowOutputDocument.php
|
* cases_ShowOutputDocument.php
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* 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
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* 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.
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Created on 13-02-2008
|
* Created on 13-02-2008
|
||||||
*
|
*
|
||||||
* @author David Callizaya <davidsantos@colosa.com>
|
* @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']);
|
$oAppDocument->Fields = $oAppDocument->load($_GET['a'],(isset($_GET['v']) )? $_GET['v'] : NULL );
|
||||||
|
|
||||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
$sAppDocUid = $oAppDocument->getAppDocUid();
|
||||||
$info = pathinfo( $oAppDocument->getAppDocFilename() );
|
$info = pathinfo( $oAppDocument->getAppDocFilename() );
|
||||||
if (!isset($_GET['ext'])) {
|
if (!isset($_GET['ext'])) {
|
||||||
$ext = $info['extension'];
|
$ext = $info['extension'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($_GET['ext'] != '') {
|
if ($_GET['ext'] != '') {
|
||||||
$ext = $_GET['ext'];
|
$ext = $_GET['ext'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$ext = $info['extension'];
|
$ext = $info['extension'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$ver= (isset($_GET['v']) && $_GET['v']!='') ? '_'.$_GET['v'] : '';
|
||||||
|
|
||||||
$realPath = PATH_DOCUMENT . $_SESSION['APPLICATION'] . '/outdocs/' . $info['basename'] . '.' . $ext ;
|
if(!$ver) //This code is in the case the outputdocument won't be versioned
|
||||||
G::streamFile ( $realPath, true );
|
$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>
|
<en>Output document</en>
|
||||||
</OUT_DOC_TITLE>
|
</OUT_DOC_TITLE>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<APP_DOC_CREATE_DATE type="caption">
|
<APP_DOC_CREATE_DATE type="caption">
|
||||||
<en>Create Date</en>
|
<en>Create Date</en>
|
||||||
|
|||||||
Reference in New Issue
Block a user