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>
|
* @author David Callizaya <davidsantos@colosa.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once ( "classes/model/AppDocumentPeer.php" );
|
require_once ( "classes/model/AppDocumentPeer.php" );
|
||||||
|
|
||||||
$oAppDocument = new AppDocument();
|
$oAppDocument = new AppDocument();
|
||||||
if(!isset($_GET['v'])){//Load last version of the document
|
if(!isset($_GET['v'])){//Load last version of the document
|
||||||
$docVersion=$oAppDocument->getLastAppDocVersion($_GET['a']);
|
$docVersion=$oAppDocument->getLastAppDocVersion($_GET['a']);
|
||||||
}else{
|
}else{
|
||||||
$docVersion=$_GET['v'];
|
$docVersion=$_GET['v'];
|
||||||
}
|
}
|
||||||
$oAppDocument->Fields = $oAppDocument->load($_GET['a'],$docVersion);
|
$oAppDocument->Fields = $oAppDocument->load($_GET['a'],$docVersion);
|
||||||
|
|
||||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
$sAppDocUid = $oAppDocument->getAppDocUid();
|
||||||
$iDocVersion = $oAppDocument->getDocVersion();
|
$iDocVersion = $oAppDocument->getDocVersion();
|
||||||
$info = pathinfo( $oAppDocument->getAppDocFilename() );
|
$info = pathinfo( $oAppDocument->getAppDocFilename() );
|
||||||
$ext = $info['extension'];
|
$ext = $info['extension'];
|
||||||
|
|
||||||
if (isset($_GET['b'])) {
|
if (isset($_GET['b'])) {
|
||||||
if ($_GET['b'] == '0') {
|
if ($_GET['b'] == '0') {
|
||||||
$bDownload = false;
|
$bDownload = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$bDownload = true;
|
$bDownload = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$bDownload = true;
|
$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>
|
* @author David Callizaya <davidsantos@colosa.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once ( "classes/model/AppDocumentPeer.php" );
|
require_once ( "classes/model/AppDocumentPeer.php" );
|
||||||
|
|
||||||
$oAppDocument = new AppDocument();
|
$oAppDocument = new AppDocument();
|
||||||
$oAppDocument->Fields = $oAppDocument->load($_GET['a'],(isset($_GET['v']) )? $_GET['v'] : NULL );
|
$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'] : '';
|
$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 );
|
$realPath = PATH_DOCUMENT . $oAppDocument->Fields['APP_UID'] . '/outdocs/' . $sAppDocUid .$ver. '.' . $ext ;
|
||||||
//G::streamFile ( $realPath, true);
|
$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);
|
||||||
?>
|
?>
|
||||||
@@ -28,6 +28,44 @@ catch(z){rc=/^(true|false|null|\[.*\]|\{.*\}|".*"|\d+|\d+\.\d+)$/;}
|
|||||||
|
|
||||||
var conn = new Ext.data.Connection();
|
var conn = new Ext.data.Connection();
|
||||||
|
|
||||||
|
streamFilefromPM=function(fileStream) {
|
||||||
|
Ext.Ajax.request({
|
||||||
|
url:fileStream,
|
||||||
|
params: {request:true},
|
||||||
|
success: function(response) {
|
||||||
|
results = Ext.decode(response.responseText);
|
||||||
|
if(results.success=='success'){
|
||||||
|
messageText="Downloading file "+results.message;
|
||||||
|
statusBarMessage( messageText, true, true );
|
||||||
|
try {
|
||||||
|
Ext.destroy(Ext.get('downloadIframe'));
|
||||||
|
}
|
||||||
|
catch(e) {}
|
||||||
|
Ext.DomHelper.append(document.body, {
|
||||||
|
tag: 'iframe',
|
||||||
|
id:'downloadIframe',
|
||||||
|
frameBorder: 0,
|
||||||
|
width: 0,
|
||||||
|
height: 0,
|
||||||
|
css: 'display:none;visibility:hidden;height:0px;',
|
||||||
|
src: fileStream
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
|
||||||
|
msgbox = Ext.Msg.alert('Error', results.message);
|
||||||
|
msgbox.setIcon( Ext.MessageBox.ERROR );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
failure: function() {
|
||||||
|
if (results.message) {
|
||||||
|
Ext.Msg.alert('Infomation',results.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
function chDir( directory, loadGridOnly ) {
|
function chDir( directory, loadGridOnly ) {
|
||||||
// console.info("**** Changing Directory: "+directory+" --
|
// console.info("**** Changing Directory: "+directory+" --
|
||||||
// "+loadGridOnly);
|
// "+loadGridOnly);
|
||||||
@@ -319,13 +357,13 @@ function openActionDialog( caller, action ) {
|
|||||||
fileName=ext_itemgrid.getSelectionModel().getSelected().get('name');
|
fileName=ext_itemgrid.getSelectionModel().getSelected().get('name');
|
||||||
//alert(ext_itemgrid.getSelectionModel().getSelected().get('downloadLink'));
|
//alert(ext_itemgrid.getSelectionModel().getSelected().get('downloadLink'));
|
||||||
//alert(ext_itemgrid.getSelectionModel().getSelected().get('downloadLabel'));
|
//alert(ext_itemgrid.getSelectionModel().getSelected().get('downloadLabel'));
|
||||||
|
streamFilefromPM(ext_itemgrid.getSelectionModel().getSelected().get('downloadLink'));
|
||||||
if(document.location = ext_itemgrid.getSelectionModel().getSelected().get('downloadLink')){
|
/*if(document.location = ext_itemgrid.getSelectionModel().getSelected().get('downloadLink')){
|
||||||
messageText="Downloading file "+fileName;
|
messageText="Downloading file "+fileName;
|
||||||
statusBarMessage( messageText, false, true );
|
statusBarMessage( messageText, false, true );
|
||||||
}else{
|
}else{
|
||||||
alert("sadasd");
|
alert("sadasd");
|
||||||
}
|
}*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -486,11 +524,11 @@ function handleCallback(requestParams, node) {
|
|||||||
}
|
}
|
||||||
if( success ) {
|
if( success ) {
|
||||||
statusBar.setStatus({
|
statusBar.setStatus({
|
||||||
text: 'success: ' + msg,
|
text: 'Success: ' + msg,
|
||||||
iconCls: 'success',
|
iconCls: 'success',
|
||||||
clear: true
|
clear: true
|
||||||
});
|
});
|
||||||
Ext.msgBoxSlider.msg('success', msg );
|
Ext.msgBoxSlider.msg('Success', msg );
|
||||||
} else {
|
} else {
|
||||||
statusBar.setStatus({
|
statusBar.setStatus({
|
||||||
text: 'error: ' + msg,
|
text: 'error: ' + msg,
|
||||||
|
|||||||
Reference in New Issue
Block a user