Import pmtable>Falta una validacion cuando queremos importar otro archivo que no sea un .pmt
This commit is contained in:
dheeyi william
2016-07-18 12:34:33 -04:00
parent 7e9ba14445
commit ff4543b217
2 changed files with 78 additions and 66 deletions

View File

@@ -770,7 +770,10 @@ class pmTablesProxy extends HttpProxyController
$fileContent = file_get_contents( $PUBLIC_ROOT_PATH . $filename ); $fileContent = file_get_contents( $PUBLIC_ROOT_PATH . $filename );
if (strpos( $fileContent, '-----== ProcessMaker Open Source Private Tables ==-----' ) === false) { if (strpos( $fileContent, '-----== ProcessMaker Open Source Private Tables ==-----' ) === false) {
throw new Exception( G::loadTranslation( 'ID_PMTABLE_INVALID_FILE' ) ); $result->success = false;
$result->errorType = 'notice';
$result->message = G::loadTranslation( 'ID_PMTABLE_INVALID_FILE', array ($filename));
return $result;
} }
$currentProUid = ''; $currentProUid = '';

View File

@@ -17,6 +17,7 @@ var importOption;
var externalOption; var externalOption;
var externalPermissions; var externalPermissions;
var currentSelectedRow = -1; var currentSelectedRow = -1;
var extensionPmt = 'pmt';
Ext.onReady(function(){ Ext.onReady(function(){
///Keyboard Events ///Keyboard Events
@@ -565,15 +566,15 @@ ImportPMTable = function(){
buttons: [{ buttons: [{
id: 'importPMTableButtonUpload', id: 'importPMTableButtonUpload',
text: _('ID_UPLOAD'), text: _('ID_UPLOAD'),
handler: function(){ handler: function () {
var uploader = Ext.getCmp('uploader'); var uploader = Ext.getCmp('uploader');
if ((eval("/^.+\.(" + extensionPmt + ")$/i").exec(Ext.getCmp('uploader').items.items[0].value))) {
if(uploader.getForm().isValid()){ if (uploader.getForm().isValid()) {
uploader.getForm().submit({ uploader.getForm().submit({
url: 'pmTablesProxy/import', url: 'pmTablesProxy/import',
waitMsg: _('ID_UPLOADING_FILE'), waitMsg: _('ID_UPLOADING_FILE'),
waitTitle : " ", waitTitle: " ",
success: function(o, resp){ success: function (o, resp) {
var result = Ext.util.JSON.decode(resp.response.responseText); var result = Ext.util.JSON.decode(resp.response.responseText);
if (result.success) { if (result.success) {
@@ -582,18 +583,18 @@ ImportPMTable = function(){
else { else {
win = new Ext.Window({ win = new Ext.Window({
id: 'windowImportingError', id: 'windowImportingError',
applyTo:'hello-win', applyTo: 'hello-win',
layout:'fit', layout: 'fit',
width:500, width: 500,
height:300, height: 300,
closeAction:'hide', closeAction: 'hide',
plain: true, plain: true,
html: '<h3>' + _('ID_IMPORTING_ERROR') + '</h3>' + result.message, html: '<h3>' + _('ID_IMPORTING_ERROR') + '</h3>' + result.message,
items: [], items: [],
buttons: [{ buttons: [{
text: 'Close', text: 'Close',
handler: function(){ handler: function () {
win.hide(); win.hide();
} }
}] }]
@@ -604,7 +605,7 @@ ImportPMTable = function(){
w.close(); w.close();
infoGrid.store.reload(); infoGrid.store.reload();
}, },
failure: function(o, resp){ failure: function (o, resp) {
w.close(); w.close();
infoGrid.store.reload(); infoGrid.store.reload();
@@ -614,28 +615,36 @@ ImportPMTable = function(){
title: _('ID_WARNING_PMTABLES'), title: _('ID_WARNING_PMTABLES'),
width: 510, width: 510,
height: 300, height: 300,
msg: "<div style=\"overflow: auto; width: 439px; height: 200px;\">" + result.message.replace(/\n/g,' <br>') + "</div>", msg: "<div style=\"overflow: auto; width: 439px; height: 200px;\">" + result.message.replace(/\n/g, ' <br>') + "</div>",
buttons: Ext.MessageBox.OK, buttons: Ext.MessageBox.OK,
animEl: 'mb9', animEl: 'mb9',
fn: function(){}, fn: function () {
},
icon: Ext.MessageBox.INFO icon: Ext.MessageBox.INFO
}); });
} else { } else {
if(result.fromAdmin) { /* from admin tab */ if (result.errorType == 'notice') {
Ext.MessageBox.alert(_("ID_ERROR"), result.message);
} else {
if (result.fromAdmin) { /* from admin tab */
aOverwrite = result.arrayOverwrite; aOverwrite = result.arrayOverwrite;
aRelated = result.arrayRelated; aRelated = result.arrayRelated;
aMessage = result.arrayMessage; aMessage = result.arrayMessage;
pmtablesErrors(aOverwrite,aRelated,aMessage); pmtablesErrors(aOverwrite, aRelated, aMessage);
} else { /* from designer tab */ } else { /* from designer tab */
aOverwrite = result.arrayOverwrite; aOverwrite = result.arrayOverwrite;
aRelated = result.arrayRelated; aRelated = result.arrayRelated;
aMessage = result.arrayMessage; aMessage = result.arrayMessage;
pmtablesErrors(aOverwrite,aRelated,aMessage); pmtablesErrors(aOverwrite, aRelated, aMessage);
}
} }
} }
} }
}); });
} }
} else {
Ext.MessageBox.alert(_("ID_ERROR"), _("ID_FILE_UPLOAD_INCORRECT_EXTENSION"));
}
} }
},{ },{
id: 'importPMTableButtonCancel', id: 'importPMTableButtonCancel',