Bug Id:6205
Backward compatibilty ready and also friendly messages when the file doesn't exist
This commit is contained in:
@@ -28,38 +28,70 @@
|
||||
* @author David Callizaya <davidsantos@colosa.com>
|
||||
*/
|
||||
|
||||
require_once ( "classes/model/AppDocumentPeer.php" );
|
||||
require_once ( "classes/model/AppDocumentPeer.php" );
|
||||
|
||||
$oAppDocument = new AppDocument();
|
||||
if(!isset($_GET['v'])){//Load last version of the document
|
||||
$oAppDocument = new AppDocument();
|
||||
if(!isset($_GET['v'])){//Load last version of the document
|
||||
$docVersion=$oAppDocument->getLastAppDocVersion($_GET['a']);
|
||||
}else{
|
||||
}else{
|
||||
$docVersion=$_GET['v'];
|
||||
}
|
||||
$oAppDocument->Fields = $oAppDocument->load($_GET['a'],$docVersion);
|
||||
}
|
||||
$oAppDocument->Fields = $oAppDocument->load($_GET['a'],$docVersion);
|
||||
|
||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
||||
$iDocVersion = $oAppDocument->getDocVersion();
|
||||
$info = pathinfo( $oAppDocument->getAppDocFilename() );
|
||||
$ext = $info['extension'];
|
||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
||||
$iDocVersion = $oAppDocument->getDocVersion();
|
||||
$info = pathinfo( $oAppDocument->getAppDocFilename() );
|
||||
$ext = $info['extension'];
|
||||
|
||||
if (isset($_GET['b'])) {
|
||||
if (isset($_GET['b'])) {
|
||||
if ($_GET['b'] == '0') {
|
||||
$bDownload = false;
|
||||
$bDownload = false;
|
||||
}
|
||||
else {
|
||||
$bDownload = true;
|
||||
$bDownload = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
$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'] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$realPath = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/' . $sAppDocUid .'_'.$iDocVersion . '.' . $ext ;
|
||||
if(!file_exists ( $realPath )){//For Backward compatibility
|
||||
$realPath = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/' . $sAppDocUid . '.' . $ext ;
|
||||
}
|
||||
|
||||
G::streamFile ( $realPath, $bDownload, $oAppDocument->Fields['APP_DOC_FILENAME'] );
|
||||
|
||||
?>
|
||||
@@ -28,28 +28,62 @@
|
||||
* @author David Callizaya <davidsantos@colosa.com>
|
||||
*/
|
||||
|
||||
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'],(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'] : '';
|
||||
//$var = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $sAppDocUid .$ver. '.' . $ext;
|
||||
|
||||
$realPath = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $sAppDocUid .$ver. '.' . $ext ; G::streamFile ( $realPath, true );
|
||||
G::streamFile ( $realPath, true ,$info['basename'] .$ver. '.' . $ext );
|
||||
//G::streamFile ( $realPath, true);
|
||||
|
||||
$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);
|
||||
?>
|
||||
Reference in New Issue
Block a user