From 42f06bce9f2a7ace04d44ba3f32f00b7d1f668ff Mon Sep 17 00:00:00 2001 From: Luis Fernando Saisa Lopez Date: Mon, 15 Sep 2014 12:09:31 -0400 Subject: [PATCH] BUG 10957 "Feature request - Limit input document..." SOLVED MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Feature request - Limit input document maximum size - Problema resuelto, al crear un nuevo Input Document se ha adicionado un nuevo campo "Maximum file size" y un dropdown que determina la unidad de medida en "KB y MB", esto permite definir el limite del tamaƱel archivo a anexar. Cuando se ejectua el caso al hacer click en "Attach", se muestra el tamaƱaximo que se puede adjuntar el archivo si es mayor al limite se mostrara un mensaje; asi tambien si se tiene un file asocioado a un input document al igual que lo anterior se mostrara un mensaje. --- gulliver/js/common/core/common.js | 11 +- gulliver/js/form/core/form.js | 32 +++++ gulliver/js/maborak/core/maborak.js | 4 +- gulliver/system/class.xmlform.php | 34 +++-- workflow/engine/classes/class.case.php | 13 +- .../model/map/InputDocumentMapBuilder.php | 4 + .../classes/model/om/BaseInputDocument.php | 118 +++++++++++++++++- .../model/om/BaseInputDocumentPeer.php | 28 +++-- workflow/engine/config/schema.xml | 4 +- workflow/engine/data/mssql/schema.sql | 2 + workflow/engine/data/mysql/schema.sql | 2 + workflow/engine/data/oracle/schema.sql | 2 + workflow/engine/methods/cases/cases_Ajax.php | 22 ++-- .../engine/methods/cases/cases_SaveData.php | 30 ++++- .../methods/cases/cases_SaveDocument.php | 53 ++++---- .../methods/inputdocs/inputdocs_Edit.php | 13 ++ .../cases_AttachInputDocumentGeneral.html | 21 +++- .../cases_AttachInputDocumentGeneral.xml | 17 +++ .../xmlform/inputdocs/inputdocs_Edit.html | 32 +++-- .../xmlform/inputdocs/inputdocs_Edit.xml | 17 +++ .../xmlform/inputdocs/inputdocs_Options.xml | 26 ++++ 21 files changed, 414 insertions(+), 71 deletions(-) diff --git a/gulliver/js/common/core/common.js b/gulliver/js/common/core/common.js index 7a8e15424..feb495c99 100755 --- a/gulliver/js/common/core/common.js +++ b/gulliver/js/common/core/common.js @@ -2232,4 +2232,13 @@ var stripNonNumeric = function (str) { } } return out; -}; \ No newline at end of file +}; + +function inputDocumentVerifySize(inpDocMaxFileSize, file) +{ + try { + return (file.files[0].size <= inpDocMaxFileSize)? 1 : 0; + } catch (e) { + return 1; + } +} diff --git a/gulliver/js/form/core/form.js b/gulliver/js/form/core/form.js index fe1319b0f..0de601c8b 100755 --- a/gulliver/js/form/core/form.js +++ b/gulliver/js/form/core/form.js @@ -3308,6 +3308,38 @@ var validateForm = function(sRequiredFields) { } } + var arrayForm = document.getElementsByTagName("form"); + var i1 = 0; + var i2 = 0; + + for (i1 = 0; i1 <= arrayForm.length - 1; i1++) { + var frm = arrayForm[i1]; + + var arrayInput = frm.getElementsByTagName("input"); + + for (i2 = 0; i2 <= arrayInput.length - 1; i2++) { + var input = arrayInput[i2]; + + if (input.type == "file") { + if (input.value != "") { + var pmindocmaxfilesize = input.getAttribute("pmindocmaxfilesize"); + + if (pmindocmaxfilesize != null && pmindocmaxfilesize != "") { + var flagFilesize = inputDocumentVerifySize(parseInt(pmindocmaxfilesize), input); + + if (flagFilesize == 0) { + new leimnud.module.app.alert().make({label: _("ID_SIZE_VERY_LARGE_PERMITTED")}); + + swSubmitValidateForm = 1; + + return false; + } + } + } + } + } + } + return true; } } else { diff --git a/gulliver/js/maborak/core/maborak.js b/gulliver/js/maborak/core/maborak.js index 6fe8842e8..afebb1177 100644 --- a/gulliver/js/maborak/core/maborak.js +++ b/gulliver/js/maborak/core/maborak.js @@ -803,7 +803,8 @@ function stringReplace(strSearch,strReplace,str) {var expression=eval("/"+strSearch+"/g");return str.replace(expression,strReplace);} var mb_strlen=function(str){str=str||'';var len=0;for(var i=0;i255?2:1;} return len;};var stripNonNumeric=function(str){str+='';var rgx=/^\d|\.|-$/;var out='';for(var i=0;i0){systemMessaggeInvalid+="\n \n"+G_STRINGS.ID_VALIDA alert(systemMessaggeInvalid);swSubmitValidateForm=1;return false;} else{var arrayForm=document.getElementsByTagName("form");var inputAux;var id="";var i1=0;var i2=0;for(i1=0;i1<=arrayForm.length-1;i1++){var frm=arrayForm[i1];for(i2=0;i2<=frm.elements.length-1;i2++){var elem=frm.elements[i2];if(elem.type=="checkbox"&&elem.disabled&&elem.checked){id=elem.id+"_";if(!document.getElementById(id)){inputAux=document.createElement("input");inputAux.type="hidden";inputAux.id=id;inputAux.name=elem.name;inputAux.value=elem.value;frm.appendChild(inputAux);}}} var arrayLink=frm.getElementsByTagName("a");for(i2=0;i2<=arrayLink.length-1;i2++){var link=arrayLink[i2];if(typeof link.id!="undefined"&&link.id!=""&&link.id!="form[DYN_BACKWARD]"&&link.id!="form[DYN_FORWARD]"){var strHtml=link.parentNode.innerHTML;strHtml=stringReplace("\\x0A","",strHtml);strHtml=stringReplace("\\x0D","",strHtml);strHtml=stringReplace("\\x09","",strHtml);if(/^.*pm:field.*$/.test(strHtml)){id=link.id+"_";if(!document.getElementById(id)){var strAux=link.id.replace("form[","");strAux=strAux.substring(0,strAux.length-1);inputAux=document.createElement("input");inputAux.type="hidden";inputAux.id=id;inputAux.name=link.id;inputAux.value=link.href;frm.appendChild(inputAux);inputAux=document.createElement("input");inputAux.type="hidden";inputAux.id=id+"label";inputAux.name="form["+strAux+"_label]";inputAux.value=link.innerHTML;frm.appendChild(inputAux);}}}}} +var arrayForm=document.getElementsByTagName("form");var i1=0;var i2=0;for(i1=0;i1<=arrayForm.length-1;i1++){var frm=arrayForm[i1];var arrayInput=frm.getElementsByTagName("input");for(i2=0;i2<=arrayInput.length-1;i2++){var input=arrayInput[i2];if(input.type=="file"){if(input.value!=""){var pmindocmaxfilesize=input.getAttribute("pmindocmaxfilesize");if(pmindocmaxfilesize!=null&&pmindocmaxfilesize!=""){var flagFilesize=inputDocumentVerifySize(parseInt(pmindocmaxfilesize),input);if(flagFilesize==0){new leimnud.module.app.alert().make({label:_("ID_SIZE_VERY_LARGE_PERMITTED")});swSubmitValidateForm=1;return false;}}}}}} return true;}}else{return false;}};var getObject=function(sObject){var i;var oAux=null;var iLength=__aObjects__.length;for(i=0;i0){oAux[0].action+='&_REFRESH_=1';oAux[0].submit();}}};var sessionPersits=function(){var rpc=new leimnud.module.rpc.xmlhttp({url:'../services/sessionPersists',args:'dynaformRestoreValues='+(typeof(__dynaformSVal__)!='undefined'?__dynaformSVal__:''),async:false});rpc.make();var response=rpc.xmlhttp.responseText.parseJSON();return response.status;};var showPromptLogin=function(lastAction){lastActionPerformed=lastAction;promptPanel=new leimnud.module.panel();promptPanel.options={statusBarButtons:[{value:_('LOGIN')}],position:{center:true},size:{w:300,h:130},control:{close:false,resize:false},fx:{modal:true}};promptPanel.setStyle={content:{padding:10,paddingBottom:2,textAlign:'left',paddingLeft:50,backgroundRepeat:'no-repeat',backgroundPosition:'10 50%',backgroundColor:'transparent',borderWidth:0}};promptPanel.make();promptPanel.addContent(_('ID_DYNAFORM_EDITOR_LOGIN_AGAIN'));promptPanel.addContent('
');var thePassword=$dce('input');thePassword.type='password';thePassword.id='thePassword';leimnud.dom.setStyle(thePassword,{font:'normal 8pt Tahoma,MiscFixed',color:'#000',width:'100%',marginTop:3,backgroundColor:'white',border:'1px solid #919B9C'});promptPanel.addContent(thePassword);thePassword.focus();thePassword.onkeyup=function(evt) diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index a15f864b5..a2c893b35 100755 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -3007,18 +3007,36 @@ class XmlForm_Field_File extends XmlForm_Field $styleDisplay = "display: none;"; } - $html = $html1 . "name . "]\" name=\"form" . $rowId . "[" . $this->name . "]\" value=\"" . $value . "\" class=\"module_app_input___gray_file\" style=\"" . $styleDisplay . "\"" . $mode . " " . $this->NSRequiredValue() . " />" . $html2; - if (isset( $this->input ) && $this->input != null) { - require_once ("classes/model/InputDocument.php"); + $arrayInputDocumentData = array(); + $inpDocMaxFilesize = ""; + + if (isset($this->input) && $this->input != null) { + require_once ("classes" . PATH_SEP . "model" . PATH_SEP . "InputDocument.php"); try { - $indoc = new InputDocument(); - $aDoc = $indoc->load( $this->input ); - $aDoc["INP_DOC_TITLE"] = (isset( $aDoc["INP_DOC_TITLE"] )) ? $aDoc["INP_DOC_TITLE"] : null; - $html = $html . ""; + $inputDocument = new InputDocument(); + $arrayInputDocumentData = $inputDocument->load($this->input); } catch (Exception $e) { //Then the input document doesn"t exits, id referencial broken - $html = $html . " \"\"(" . G::loadTranslation( "ID_INPUT_DOC_DOESNT_EXIST" ) . ")"; + } + } + + if (count($arrayInputDocumentData) > 0) { + $inpDocMaxFilesize = $arrayInputDocumentData["INP_DOC_MAX_FILESIZE"] * (($arrayInputDocumentData["INP_DOC_MAX_FILESIZE_UNIT"] == "MB")? 1024 *1024 : 1024); //Bytes + } + + $pmInputDocument = "pmindocmaxfilesize=\"" . $inpDocMaxFilesize . "\""; //Bytes + + $html = $html1 . "name . "]\" name=\"form" . $rowId . "[" . $this->name . "]\" value=\"" . $value . "\" class=\"module_app_input___gray_file\" style=\"" . $styleDisplay . "\"" . $mode . " " . $this->NSRequiredValue() . " />" . $html2; + + if (isset($this->input) && $this->input != null) { + if (count($arrayInputDocumentData) > 0) { + $maxUploadFilesizeLabel = ($arrayInputDocumentData["INP_DOC_MAX_FILESIZE"] . "" != "0" && $arrayInputDocumentData["INP_DOC_MAX_FILESIZE"] != "")? "Max upload file size [" . $arrayInputDocumentData["INP_DOC_MAX_FILESIZE"] . " " . $arrayInputDocumentData["INP_DOC_MAX_FILESIZE_UNIT"] . "]" : ""; + + $arrayInputDocumentData["INP_DOC_TITLE"] = (isset($arrayInputDocumentData["INP_DOC_TITLE"]))? $arrayInputDocumentData["INP_DOC_TITLE"] : null; + $html = $html . "
"; + } else { + $html = $html . " \"\"(" . G::loadTranslation("ID_INPUT_DOC_DOESNT_EXIST") . ")"; } } diff --git a/workflow/engine/classes/class.case.php b/workflow/engine/classes/class.case.php index af84d2221..e1ed55cc1 100755 --- a/workflow/engine/classes/class.case.php +++ b/workflow/engine/classes/class.case.php @@ -3517,9 +3517,10 @@ class Cases * @param string $file File ($_FILES["form"]["name"]["APP_DOC_FILENAME"] or path to file) * @param int $fileError File error ($_FILES["form"]["error"]["APP_DOC_FILENAME"] or 0) * @param string $fileTmpName File temporal name ($_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"] or null) + * @param string $fileSize File size ($_FILES["form"]["size"]["APP_DOC_FILENAME"] or 0) * @return string Return application document ID */ - public function addInputDocument($inputDocumentUid, $appDocUid, $docVersion, $appDocType, $appDocComment, $inputDocumentAction, $applicationUid, $delIndex, $taskUid, $userUid, $option, $file, $fileError = 0, $fileTmpName = null) + public function addInputDocument($inputDocumentUid, $appDocUid, $docVersion, $appDocType, $appDocComment, $inputDocumentAction, $applicationUid, $delIndex, $taskUid, $userUid, $option, $file, $fileError = 0, $fileTmpName = null, $fileSize = 0) { $appDocFileName = null; $sw = 0; @@ -3549,6 +3550,16 @@ class Cases $inputDocument = new InputDocument(); $arrayInputDocumentData = $inputDocument->load($inputDocumentUid); + //--- + $inpDocMaxFilesize = $arrayInputDocumentData["INP_DOC_MAX_FILESIZE"]; + $inpDocMaxFilesizeUnit = $arrayInputDocumentData["INP_DOC_MAX_FILESIZE_UNIT"]; + + $inpDocMaxFilesize = $inpDocMaxFilesize * (($inpDocMaxFilesizeUnit == "MB")? 1024 *1024 : 1024); //Bytes + + if ($fileSize > $inpDocMaxFilesize) { + throw new Exception(G::LoadTranslation("ID_SIZE_VERY_LARGE_PERMITTED")); + } + //Get the Custom Folder ID (create if necessary) $appFolder = new AppFolder(); $folderId = $appFolder->createFromPath($arrayInputDocumentData["INP_DOC_DESTINATION_PATH"], $applicationUid); diff --git a/workflow/engine/classes/model/map/InputDocumentMapBuilder.php b/workflow/engine/classes/model/map/InputDocumentMapBuilder.php index 505409dea..a1c7f24d0 100755 --- a/workflow/engine/classes/model/map/InputDocumentMapBuilder.php +++ b/workflow/engine/classes/model/map/InputDocumentMapBuilder.php @@ -83,6 +83,10 @@ class InputDocumentMapBuilder $tMap->addColumn('INP_DOC_TYPE_FILE', 'InpDocTypeFile', 'string', CreoleTypes::VARCHAR, false, 200); + $tMap->addColumn('INP_DOC_MAX_FILESIZE', 'InpDocMaxFilesize', 'int', CreoleTypes::INTEGER, true, null); + + $tMap->addColumn('INP_DOC_MAX_FILESIZE_UNIT', 'InpDocMaxFilesizeUnit', 'string', CreoleTypes::VARCHAR, true, 2); + $tMap->addValidator('INP_DOC_UID', 'maxLength', 'propel.validator.MaxLengthValidator', '32', 'Input Document UID can be no larger than 32 in size'); $tMap->addValidator('INP_DOC_UID', 'required', 'propel.validator.RequiredValidator', '', 'Input Document UID is required.'); diff --git a/workflow/engine/classes/model/om/BaseInputDocument.php b/workflow/engine/classes/model/om/BaseInputDocument.php index b41fbd720..eeb198bd5 100755 --- a/workflow/engine/classes/model/om/BaseInputDocument.php +++ b/workflow/engine/classes/model/om/BaseInputDocument.php @@ -81,6 +81,18 @@ abstract class BaseInputDocument extends BaseObject implements Persistent */ protected $inp_doc_type_file = '*.*'; + /** + * The value for the inp_doc_max_filesize field. + * @var int + */ + protected $inp_doc_max_filesize = 0; + + /** + * The value for the inp_doc_max_filesize_unit field. + * @var string + */ + protected $inp_doc_max_filesize_unit = 'KB'; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -194,6 +206,28 @@ abstract class BaseInputDocument extends BaseObject implements Persistent return $this->inp_doc_type_file; } + /** + * Get the [inp_doc_max_filesize] column value. + * + * @return int + */ + public function getInpDocMaxFilesize() + { + + return $this->inp_doc_max_filesize; + } + + /** + * Get the [inp_doc_max_filesize_unit] column value. + * + * @return string + */ + public function getInpDocMaxFilesizeUnit() + { + + return $this->inp_doc_max_filesize_unit; + } + /** * Set the value of [inp_doc_uid] column. * @@ -392,6 +426,50 @@ abstract class BaseInputDocument extends BaseObject implements Persistent } // setInpDocTypeFile() + /** + * Set the value of [inp_doc_max_filesize] column. + * + * @param int $v new value + * @return void + */ + public function setInpDocMaxFilesize($v) + { + + // Since the native PHP type for this column is integer, + // we will cast the input value to an int (if it is not). + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->inp_doc_max_filesize !== $v || $v === 0) { + $this->inp_doc_max_filesize = $v; + $this->modifiedColumns[] = InputDocumentPeer::INP_DOC_MAX_FILESIZE; + } + + } // setInpDocMaxFilesize() + + /** + * Set the value of [inp_doc_max_filesize_unit] column. + * + * @param string $v new value + * @return void + */ + public function setInpDocMaxFilesizeUnit($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->inp_doc_max_filesize_unit !== $v || $v === 'KB') { + $this->inp_doc_max_filesize_unit = $v; + $this->modifiedColumns[] = InputDocumentPeer::INP_DOC_MAX_FILESIZE_UNIT; + } + + } // setInpDocMaxFilesizeUnit() + /** * Hydrates (populates) the object variables with values from the database resultset. * @@ -427,12 +505,16 @@ abstract class BaseInputDocument extends BaseObject implements Persistent $this->inp_doc_type_file = $rs->getString($startcol + 8); + $this->inp_doc_max_filesize = $rs->getInt($startcol + 9); + + $this->inp_doc_max_filesize_unit = $rs->getString($startcol + 10); + $this->resetModified(); $this->setNew(false); // FIXME - using NUM_COLUMNS may be clearer. - return $startcol + 9; // 9 = InputDocumentPeer::NUM_COLUMNS - InputDocumentPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 11; // 11 = InputDocumentPeer::NUM_COLUMNS - InputDocumentPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating InputDocument object", $e); @@ -663,6 +745,12 @@ abstract class BaseInputDocument extends BaseObject implements Persistent case 8: return $this->getInpDocTypeFile(); break; + case 9: + return $this->getInpDocMaxFilesize(); + break; + case 10: + return $this->getInpDocMaxFilesizeUnit(); + break; default: return null; break; @@ -692,6 +780,8 @@ abstract class BaseInputDocument extends BaseObject implements Persistent $keys[6] => $this->getInpDocDestinationPath(), $keys[7] => $this->getInpDocTags(), $keys[8] => $this->getInpDocTypeFile(), + $keys[9] => $this->getInpDocMaxFilesize(), + $keys[10] => $this->getInpDocMaxFilesizeUnit(), ); return $result; } @@ -750,6 +840,12 @@ abstract class BaseInputDocument extends BaseObject implements Persistent case 8: $this->setInpDocTypeFile($value); break; + case 9: + $this->setInpDocMaxFilesize($value); + break; + case 10: + $this->setInpDocMaxFilesizeUnit($value); + break; } // switch() } @@ -809,6 +905,14 @@ abstract class BaseInputDocument extends BaseObject implements Persistent $this->setInpDocTypeFile($arr[$keys[8]]); } + if (array_key_exists($keys[9], $arr)) { + $this->setInpDocMaxFilesize($arr[$keys[9]]); + } + + if (array_key_exists($keys[10], $arr)) { + $this->setInpDocMaxFilesizeUnit($arr[$keys[10]]); + } + } /** @@ -856,6 +960,14 @@ abstract class BaseInputDocument extends BaseObject implements Persistent $criteria->add(InputDocumentPeer::INP_DOC_TYPE_FILE, $this->inp_doc_type_file); } + if ($this->isColumnModified(InputDocumentPeer::INP_DOC_MAX_FILESIZE)) { + $criteria->add(InputDocumentPeer::INP_DOC_MAX_FILESIZE, $this->inp_doc_max_filesize); + } + + if ($this->isColumnModified(InputDocumentPeer::INP_DOC_MAX_FILESIZE_UNIT)) { + $criteria->add(InputDocumentPeer::INP_DOC_MAX_FILESIZE_UNIT, $this->inp_doc_max_filesize_unit); + } + return $criteria; } @@ -926,6 +1038,10 @@ abstract class BaseInputDocument extends BaseObject implements Persistent $copyObj->setInpDocTypeFile($this->inp_doc_type_file); + $copyObj->setInpDocMaxFilesize($this->inp_doc_max_filesize); + + $copyObj->setInpDocMaxFilesizeUnit($this->inp_doc_max_filesize_unit); + $copyObj->setNew(true); diff --git a/workflow/engine/classes/model/om/BaseInputDocumentPeer.php b/workflow/engine/classes/model/om/BaseInputDocumentPeer.php index aaf25196e..525675f1a 100755 --- a/workflow/engine/classes/model/om/BaseInputDocumentPeer.php +++ b/workflow/engine/classes/model/om/BaseInputDocumentPeer.php @@ -25,7 +25,7 @@ abstract class BaseInputDocumentPeer const CLASS_DEFAULT = 'classes.model.InputDocument'; /** The total number of columns. */ - const NUM_COLUMNS = 9; + const NUM_COLUMNS = 11; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -58,6 +58,12 @@ abstract class BaseInputDocumentPeer /** the column name for the INP_DOC_TYPE_FILE field */ const INP_DOC_TYPE_FILE = 'INPUT_DOCUMENT.INP_DOC_TYPE_FILE'; + /** the column name for the INP_DOC_MAX_FILESIZE field */ + const INP_DOC_MAX_FILESIZE = 'INPUT_DOCUMENT.INP_DOC_MAX_FILESIZE'; + + /** the column name for the INP_DOC_MAX_FILESIZE_UNIT field */ + const INP_DOC_MAX_FILESIZE_UNIT = 'INPUT_DOCUMENT.INP_DOC_MAX_FILESIZE_UNIT'; + /** The PHP to DB Name Mapping */ private static $phpNameMap = null; @@ -69,10 +75,10 @@ abstract class BaseInputDocumentPeer * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('InpDocUid', 'ProUid', 'InpDocFormNeeded', 'InpDocOriginal', 'InpDocPublished', 'InpDocVersioning', 'InpDocDestinationPath', 'InpDocTags', 'InpDocTypeFile', ), - BasePeer::TYPE_COLNAME => array (InputDocumentPeer::INP_DOC_UID, InputDocumentPeer::PRO_UID, InputDocumentPeer::INP_DOC_FORM_NEEDED, InputDocumentPeer::INP_DOC_ORIGINAL, InputDocumentPeer::INP_DOC_PUBLISHED, InputDocumentPeer::INP_DOC_VERSIONING, InputDocumentPeer::INP_DOC_DESTINATION_PATH, InputDocumentPeer::INP_DOC_TAGS, InputDocumentPeer::INP_DOC_TYPE_FILE, ), - BasePeer::TYPE_FIELDNAME => array ('INP_DOC_UID', 'PRO_UID', 'INP_DOC_FORM_NEEDED', 'INP_DOC_ORIGINAL', 'INP_DOC_PUBLISHED', 'INP_DOC_VERSIONING', 'INP_DOC_DESTINATION_PATH', 'INP_DOC_TAGS', 'INP_DOC_TYPE_FILE', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) + BasePeer::TYPE_PHPNAME => array ('InpDocUid', 'ProUid', 'InpDocFormNeeded', 'InpDocOriginal', 'InpDocPublished', 'InpDocVersioning', 'InpDocDestinationPath', 'InpDocTags', 'InpDocTypeFile', 'InpDocMaxFilesize', 'InpDocMaxFilesizeUnit', ), + BasePeer::TYPE_COLNAME => array (InputDocumentPeer::INP_DOC_UID, InputDocumentPeer::PRO_UID, InputDocumentPeer::INP_DOC_FORM_NEEDED, InputDocumentPeer::INP_DOC_ORIGINAL, InputDocumentPeer::INP_DOC_PUBLISHED, InputDocumentPeer::INP_DOC_VERSIONING, InputDocumentPeer::INP_DOC_DESTINATION_PATH, InputDocumentPeer::INP_DOC_TAGS, InputDocumentPeer::INP_DOC_TYPE_FILE, InputDocumentPeer::INP_DOC_MAX_FILESIZE, InputDocumentPeer::INP_DOC_MAX_FILESIZE_UNIT, ), + BasePeer::TYPE_FIELDNAME => array ('INP_DOC_UID', 'PRO_UID', 'INP_DOC_FORM_NEEDED', 'INP_DOC_ORIGINAL', 'INP_DOC_PUBLISHED', 'INP_DOC_VERSIONING', 'INP_DOC_DESTINATION_PATH', 'INP_DOC_TAGS', 'INP_DOC_TYPE_FILE', 'INP_DOC_MAX_FILESIZE', 'INP_DOC_MAX_FILESIZE_UNIT', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -82,10 +88,10 @@ abstract class BaseInputDocumentPeer * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('InpDocUid' => 0, 'ProUid' => 1, 'InpDocFormNeeded' => 2, 'InpDocOriginal' => 3, 'InpDocPublished' => 4, 'InpDocVersioning' => 5, 'InpDocDestinationPath' => 6, 'InpDocTags' => 7, 'InpDocTypeFile' => 8, ), - BasePeer::TYPE_COLNAME => array (InputDocumentPeer::INP_DOC_UID => 0, InputDocumentPeer::PRO_UID => 1, InputDocumentPeer::INP_DOC_FORM_NEEDED => 2, InputDocumentPeer::INP_DOC_ORIGINAL => 3, InputDocumentPeer::INP_DOC_PUBLISHED => 4, InputDocumentPeer::INP_DOC_VERSIONING => 5, InputDocumentPeer::INP_DOC_DESTINATION_PATH => 6, InputDocumentPeer::INP_DOC_TAGS => 7, InputDocumentPeer::INP_DOC_TYPE_FILE => 8, ), - BasePeer::TYPE_FIELDNAME => array ('INP_DOC_UID' => 0, 'PRO_UID' => 1, 'INP_DOC_FORM_NEEDED' => 2, 'INP_DOC_ORIGINAL' => 3, 'INP_DOC_PUBLISHED' => 4, 'INP_DOC_VERSIONING' => 5, 'INP_DOC_DESTINATION_PATH' => 6, 'INP_DOC_TAGS' => 7, 'INP_DOC_TYPE_FILE' => 8, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) + BasePeer::TYPE_PHPNAME => array ('InpDocUid' => 0, 'ProUid' => 1, 'InpDocFormNeeded' => 2, 'InpDocOriginal' => 3, 'InpDocPublished' => 4, 'InpDocVersioning' => 5, 'InpDocDestinationPath' => 6, 'InpDocTags' => 7, 'InpDocTypeFile' => 8, 'InpDocMaxFilesize' => 9, 'InpDocMaxFilesizeUnit' => 10, ), + BasePeer::TYPE_COLNAME => array (InputDocumentPeer::INP_DOC_UID => 0, InputDocumentPeer::PRO_UID => 1, InputDocumentPeer::INP_DOC_FORM_NEEDED => 2, InputDocumentPeer::INP_DOC_ORIGINAL => 3, InputDocumentPeer::INP_DOC_PUBLISHED => 4, InputDocumentPeer::INP_DOC_VERSIONING => 5, InputDocumentPeer::INP_DOC_DESTINATION_PATH => 6, InputDocumentPeer::INP_DOC_TAGS => 7, InputDocumentPeer::INP_DOC_TYPE_FILE => 8, InputDocumentPeer::INP_DOC_MAX_FILESIZE => 9, InputDocumentPeer::INP_DOC_MAX_FILESIZE_UNIT => 10, ), + BasePeer::TYPE_FIELDNAME => array ('INP_DOC_UID' => 0, 'PRO_UID' => 1, 'INP_DOC_FORM_NEEDED' => 2, 'INP_DOC_ORIGINAL' => 3, 'INP_DOC_PUBLISHED' => 4, 'INP_DOC_VERSIONING' => 5, 'INP_DOC_DESTINATION_PATH' => 6, 'INP_DOC_TAGS' => 7, 'INP_DOC_TYPE_FILE' => 8, 'INP_DOC_MAX_FILESIZE' => 9, 'INP_DOC_MAX_FILESIZE_UNIT' => 10, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -204,6 +210,10 @@ abstract class BaseInputDocumentPeer $criteria->addSelectColumn(InputDocumentPeer::INP_DOC_TYPE_FILE); + $criteria->addSelectColumn(InputDocumentPeer::INP_DOC_MAX_FILESIZE); + + $criteria->addSelectColumn(InputDocumentPeer::INP_DOC_MAX_FILESIZE_UNIT); + } const COUNT = 'COUNT(INPUT_DOCUMENT.INP_DOC_UID)'; diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml index 30ba10fb1..089a2f549 100755 --- a/workflow/engine/config/schema.xml +++ b/workflow/engine/config/schema.xml @@ -581,6 +581,8 @@ + + @@ -836,7 +838,7 @@ - + diff --git a/workflow/engine/data/mssql/schema.sql b/workflow/engine/data/mssql/schema.sql index 71edc2fef..c44b23e36 100755 --- a/workflow/engine/data/mssql/schema.sql +++ b/workflow/engine/data/mssql/schema.sql @@ -593,6 +593,8 @@ CREATE TABLE [INPUT_DOCUMENT] [INP_DOC_VERSIONING] TINYINT default 0 NOT NULL, [INP_DOC_DESTINATION_PATH] NVARCHAR(MAX) NULL, [INP_DOC_TAGS] NVARCHAR(MAX) NULL, + [INP_DOC_MAX_FILESIZE] INT default 0 NOT NULL, + [INP_DOC_MAX_FILESIZE_UNIT] VARCHAR(2) default 'KB' NOT NULL, CONSTRAINT INPUT_DOCUMENT_PK PRIMARY KEY ([INP_DOC_UID]) ); diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql index 824c2e99c..2db7e9375 100755 --- a/workflow/engine/data/mysql/schema.sql +++ b/workflow/engine/data/mysql/schema.sql @@ -268,6 +268,8 @@ CREATE TABLE `INPUT_DOCUMENT` `INP_DOC_DESTINATION_PATH` MEDIUMTEXT, `INP_DOC_TAGS` MEDIUMTEXT, `INP_DOC_TYPE_FILE` VARCHAR(200) default '*.*', + `INP_DOC_MAX_FILESIZE` INTEGER default 0 NOT NULL, + `INP_DOC_MAX_FILESIZE_UNIT` VARCHAR(2) default 'KB' NOT NULL, PRIMARY KEY (`INP_DOC_UID`) )ENGINE=InnoDB DEFAULT CHARSET='utf8' COMMENT='Documentation required'; #----------------------------------------------------------------------------- diff --git a/workflow/engine/data/oracle/schema.sql b/workflow/engine/data/oracle/schema.sql index 923b8d47d..35729091e 100755 --- a/workflow/engine/data/oracle/schema.sql +++ b/workflow/engine/data/oracle/schema.sql @@ -333,6 +333,8 @@ CREATE TABLE "INPUT_DOCUMENT" "INP_DOC_VERSIONING" NUMBER(3,0) default 0 NOT NULL, "INP_DOC_DESTINATION_PATH" VARCHAR2(2000), "INP_DOC_TAGS" VARCHAR2(2000) + "INP_DOC_MAX_FILESIZE" NUMBER default 0 NOT NULL, + "INP_DOC_MAX_FILESIZE_UNIT" VARCHAR2(2) default 'KB' NOT NULL, ); ALTER TABLE "INPUT_DOCUMENT" diff --git a/workflow/engine/methods/cases/cases_Ajax.php b/workflow/engine/methods/cases/cases_Ajax.php index 775c5828f..3f8aa3bc3 100755 --- a/workflow/engine/methods/cases/cases_Ajax.php +++ b/workflow/engine/methods/cases/cases_Ajax.php @@ -1,9 +1,9 @@ message = G::LoadTranslation('ID_LOGIN_AGAIN'); - $response->lostSession = true; - print G::json_encode( $response ); +if (!isset($_SESSION['USER_LOGGED'])) { + $response = new stdclass(); + $response->message = G::LoadTranslation('ID_LOGIN_AGAIN'); + $response->lostSession = true; + print G::json_encode( $response ); die(); } /** @@ -908,9 +908,17 @@ switch (($_POST['action']) ? $_POST['action'] : $_REQUEST['action']) { $Fields['APP_DOC_UID'] = $_POST['appDocId']; $Fields['actionType'] = $_POST['actionType']; $Fields['docVersion'] = $_POST['docVersion']; - $oInputDocument = new InputDocument(); - $InpDocData = $oInputDocument->load( $Fields['DOC_UID'] ); + $oInputDocument = new InputDocument(); + $InpDocData = $oInputDocument->load( $Fields['DOC_UID'] ); + + $inpDocMaxFilesize = $InpDocData["INP_DOC_MAX_FILESIZE"]; + $inpDocMaxFilesizeUnit = $InpDocData["INP_DOC_MAX_FILESIZE_UNIT"]; + $inpDocMaxFilesize = $inpDocMaxFilesize * (($inpDocMaxFilesizeUnit == "MB")? 1024 *1024 : 1024); //Bytes + + $Fields["INP_DOC_MAX_FILESIZE"] = $inpDocMaxFilesize; + $Fields["INP_DOC_MAX_FILESIZE_LABEL"] = ($inpDocMaxFilesize > 0)? "[" . $InpDocData["INP_DOC_MAX_FILESIZE"] . " " . $InpDocData["INP_DOC_MAX_FILESIZE_UNIT"] . "]" : ""; $Fields['fileTypes'] = $InpDocData['INP_DOC_TYPE_FILE']; + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', '', $Fields, 'cases_SaveDocument?UID=' . $_POST['docID'] ); G::RenderPage( 'publish', 'raw' ); break; diff --git a/workflow/engine/methods/cases/cases_SaveData.php b/workflow/engine/methods/cases/cases_SaveData.php index cceccf10c..f78848398 100644 --- a/workflow/engine/methods/cases/cases_SaveData.php +++ b/workflow/engine/methods/cases/cases_SaveData.php @@ -40,10 +40,10 @@ try { if ($_GET['APP_UID'] !== $_SESSION['APPLICATION']) { throw new Exception( G::LoadTranslation( 'ID_INVALID_APPLICATION_ID_MSG', array ('{1}',G::LoadTranslation( 'ID_REOPEN' ) ) ) ); } - + /* * PMDynaform - * DYN_VERSION is 1: classic Dynaform, + * DYN_VERSION is 1: classic Dynaform, * DYN_VERSION is 2: responsive form, Pmdynaform. */ $a = new Criteria("workflow"); @@ -183,7 +183,7 @@ try { $aData['USER_UID'] = $_SESSION['USER_LOGGED']; //$aData['APP_STATUS'] = $Fields['APP_STATUS']; $aData['PRO_UID'] = $_SESSION['PROCESS']; - + if ($swpmdynaform) { $aData['APP_DATA'] = array_merge($aData['APP_DATA'], $pmdynaform); $_POST["DynaformRequiredFields"] = '[]'; @@ -255,6 +255,7 @@ try { if ($arrayFileError[$i] == 0) { $indocUid = null; $fieldName = null; + $fileSizeByField = 0; if (is_array( $arrayField[$i] )) { if (isset( $_POST["INPUTS"][$arrayField[$i]["grdName"]][$arrayField[$i]["grdFieldName"]] ) && ! empty( $_POST["INPUTS"][$arrayField[$i]["grdName"]][$arrayField[$i]["grdFieldName"]] )) { @@ -262,12 +263,20 @@ try { } $fieldName = $arrayField[$i]["grdName"] . "_" . $arrayField[$i]["index"] . "_" . $arrayField[$i]["grdFieldName"]; + + if (isset($_FILES["form"]["size"][$arrayField[$i]["grdName"]][$arrayField[$i]["index"]][$arrayField[$i]["grdFieldName"]])) { + $fileSizeByField = $_FILES["form"]["size"][$arrayField[$i]["grdName"]][$arrayField[$i]["index"]][$arrayField[$i]["grdFieldName"]]; + } } else { if (isset( $_POST["INPUTS"][$arrayField[$i]] ) && ! empty( $_POST["INPUTS"][$arrayField[$i]] )) { $indocUid = $_POST["INPUTS"][$arrayField[$i]]; } $fieldName = $arrayField[$i]; + + if (isset($_FILES["form"]["size"][$fieldName])) { + $fileSizeByField = $_FILES["form"]["size"][$fieldName]; + } } if ($indocUid != null) { @@ -290,6 +299,21 @@ try { die(); } + //Validate Filesize of $_FILE + $inpDocMaxFilesize = $aID["INP_DOC_MAX_FILESIZE"]; + $inpDocMaxFilesizeUnit = $aID["INP_DOC_MAX_FILESIZE_UNIT"]; + + $inpDocMaxFilesize = $inpDocMaxFilesize * (($inpDocMaxFilesizeUnit == "MB")? 1024 *1024 : 1024); //Bytes + + if ($inpDocMaxFilesize > 0 && $fileSizeByField > 0) { + if ($fileSizeByField > $inpDocMaxFilesize) { + G::SendMessageText(G::LoadTranslation("ID_SIZE_VERY_LARGE_PERMITTED"), "ERROR"); + $arrayAux1 = explode("sys" . SYS_SYS, $_SERVER["HTTP_REFERER"]); + G::header("location: /sys" . SYS_SYS . $arrayAux1[1]); + exit(0); + } + } + $aFields = array ("APP_UID" => $_SESSION["APPLICATION"],"DEL_INDEX" => $_SESSION["INDEX"],"USR_UID" => $_SESSION["USER_LOGGED"],"DOC_UID" => $indocUid,"APP_DOC_TYPE" => "INPUT","APP_DOC_CREATE_DATE" => date( "Y-m-d H:i:s" ),"APP_DOC_COMMENT" => "","APP_DOC_TITLE" => "","APP_DOC_FILENAME" => $arrayFileName[$i],"FOLDER_UID" => $oFolder->createFromPath( $aID["INP_DOC_DESTINATION_PATH"] ),"APP_DOC_TAGS" => $oFolder->parseTags( $aID["INP_DOC_TAGS"] ),"APP_DOC_FIELDNAME" => $fieldName); } else { $aFields = array ("APP_UID" => $_SESSION["APPLICATION"],"DEL_INDEX" => $_SESSION["INDEX"],"USR_UID" => $_SESSION["USER_LOGGED"],"DOC_UID" => - 1,"APP_DOC_TYPE" => "ATTACHED","APP_DOC_CREATE_DATE" => date( "Y-m-d H:i:s" ),"APP_DOC_COMMENT" => "","APP_DOC_TITLE" => "","APP_DOC_FILENAME" => $arrayFileName[$i],"APP_DOC_FIELDNAME" => $fieldName); diff --git a/workflow/engine/methods/cases/cases_SaveDocument.php b/workflow/engine/methods/cases/cases_SaveDocument.php index 22c5014b3..954440b16 100755 --- a/workflow/engine/methods/cases/cases_SaveDocument.php +++ b/workflow/engine/methods/cases/cases_SaveDocument.php @@ -93,36 +93,45 @@ if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) { $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_VALUES"] = $arrayTrigger; } -//***Validating the file allowed extensions*** -$oInputDocument = new InputDocument(); +//***Validating the file allowed extensions*** +$oInputDocument = new InputDocument(); $InpDocData = $oInputDocument->load( $inputDocumentUid ); $res = G::verifyInputDocExtension($InpDocData['INP_DOC_TYPE_FILE'], $_FILES["form"]["name"]["APP_DOC_FILENAME"], $_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"]); if($res->status == 0){ - $message = $res->message; - G::SendMessageText( $message, "ERROR" ); - $backUrlObj = explode( "sys" . SYS_SYS, $_SERVER['HTTP_REFERER'] ); - G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] ); + $message = $res->message; + G::SendMessageText( $message, "ERROR" ); + $backUrlObj = explode( "sys" . SYS_SYS, $_SERVER['HTTP_REFERER'] ); + G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] ); die(); } //Add Input Document if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) { - $appDocUid = $case->addInputDocument( - $inputDocumentUid, - $appDocUid, - $docVersion, - $appDocType, - $appDocComment, - $actionType, - $_SESSION["APPLICATION"], - $_SESSION["INDEX"], - $_SESSION["TASK"], - $_SESSION["USER_LOGGED"], - "xmlform", - $_FILES["form"]["name"]["APP_DOC_FILENAME"], - $_FILES["form"]["error"]["APP_DOC_FILENAME"], - $_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"] - ); + try { + $appDocUid = $case->addInputDocument( + $inputDocumentUid, + $appDocUid, + $docVersion, + $appDocType, + $appDocComment, + $actionType, + $_SESSION["APPLICATION"], + $_SESSION["INDEX"], + $_SESSION["TASK"], + $_SESSION["USER_LOGGED"], + "xmlform", + $_FILES["form"]["name"]["APP_DOC_FILENAME"], + $_FILES["form"]["error"]["APP_DOC_FILENAME"], + $_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"], + $_FILES["form"]["size"]["APP_DOC_FILENAME"] + ); + } catch (Exception $e) { + G::SendMessageText($e->getMessage(), "ERROR"); + + $arrayAux = explode("sys" . SYS_SYS, $_SERVER["HTTP_REFERER"]); + G::header("location: /sys" . SYS_SYS . $arrayAux[1]); + exit(0); + } } if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) { diff --git a/workflow/engine/methods/inputdocs/inputdocs_Edit.php b/workflow/engine/methods/inputdocs/inputdocs_Edit.php index 0b7e36ed0..f2d1c2728 100755 --- a/workflow/engine/methods/inputdocs/inputdocs_Edit.php +++ b/workflow/engine/methods/inputdocs/inputdocs_Edit.php @@ -45,6 +45,19 @@ try { } $aFields['INP_DOC_TAGS'] = isset( $aFields['INP_DOC_TAGS'] ) ? $aFields['INP_DOC_TAGS'] : 'INPUT'; $aFields['INP_DOC_VERSIONING'] = strval( isset( $aFields['INP_DOC_VERSIONING'] ) ? $aFields['INP_DOC_VERSIONING'] : '' ); + + $uploadMaxFilesize = 0; + $uploadMaxFilesizeUnit = "KB"; + + if (preg_match("/^(\d+)(.*)$/", ini_get("upload_max_filesize"), $arrayMatch)) { + $uploadMaxFilesize = (int)($arrayMatch[1]); + $uploadMaxFilesizeUnit = (strlen(strtoupper($arrayMatch[2])) > 1)? $arrayMatch[2] : $arrayMatch[2] . "B"; + $uploadMaxFilesize = $uploadMaxFilesize * (($uploadMaxFilesizeUnit == "MB")? 1024 * 1024 : 1024); //Bytes + } + + $aFields["INP_DOC_UPLOAD_MAX_FILESIZE"] = $uploadMaxFilesize; + $aFields["INP_DOC_UPLOAD_MAX_FILESIZE_LABEL"] = "(" . $arrayMatch[1] . " " . $uploadMaxFilesizeUnit . ")"; + G::LoadClass( 'xmlfield_InputPM' ); $G_PUBLISH = new Publisher(); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'inputdocs/inputdocs_Edit', '', $aFields, '../inputdocs/inputdocs_Save' ); diff --git a/workflow/engine/xmlform/cases/cases_AttachInputDocumentGeneral.html b/workflow/engine/xmlform/cases/cases_AttachInputDocumentGeneral.html index 549832ced..ef37f4f20 100755 --- a/workflow/engine/xmlform/cases/cases_AttachInputDocumentGeneral.html +++ b/workflow/engine/xmlform/cases/cases_AttachInputDocumentGeneral.html @@ -1,4 +1,4 @@ -
+
@@ -11,8 +11,11 @@ {$form.APP_DOC_TYPE} - - {$form.DOC_UID} + + + {$form.DOC_UID} + {$form.INP_DOC_MAX_FILESIZE} + {$form.APP_DOC_UID} @@ -26,20 +29,26 @@ {$form.fileTypes} + + + {$INP_DOC_MAX_FILESIZE_LABEL} + {$form.INP_DOC_MAX_FILESIZE_LABEL} + + {$APP_DOC_FILENAME} - {$form.APP_DOC_FILENAME} + {$form.APP_DOC_FILENAME} {$APP_DOC_COMMENT} - {$form.APP_DOC_COMMENT} + {$form.APP_DOC_COMMENT} {$form.MORE} - +
{$form.SAVE}   {$form.BTN_CANCEL} diff --git a/workflow/engine/xmlform/cases/cases_AttachInputDocumentGeneral.xml b/workflow/engine/xmlform/cases/cases_AttachInputDocumentGeneral.xml index eb293584a..cca858f55 100755 --- a/workflow/engine/xmlform/cases/cases_AttachInputDocumentGeneral.xml +++ b/workflow/engine/xmlform/cases/cases_AttachInputDocumentGeneral.xml @@ -7,6 +7,12 @@ + + + + Max size accepted + + @@ -31,6 +37,10 @@ leimnud.event.add(window, 'load', function() { } }); +if (getField("INP_DOC_MAX_FILESIZE").value == 0 || getField("INP_DOC_MAX_FILESIZE").value == "") { + hideRow("INP_DOC_MAX_FILESIZE_LABEL"); +} + var verifyInfo = function(oForm) { oAux = getField('APP_DOC_FILENAME'); @@ -41,6 +51,13 @@ var verifyInfo = function(oForm) return; } + var flagFilesize = inputDocumentVerifySize(parseInt(getField("INP_DOC_MAX_FILESIZE").value), getField("APP_DOC_FILENAME")); + + if (flagFilesize == 0) { + new leimnud.module.app.alert().make({label: _("ID_SIZE_VERY_LARGE_PERMITTED")}); + return; + } + docType = oAux.value.split("."); docType = docType[docType.length - 1]; diff --git a/workflow/engine/xmlform/inputdocs/inputdocs_Edit.html b/workflow/engine/xmlform/inputdocs/inputdocs_Edit.html index d1fa19ea4..b59ddc088 100755 --- a/workflow/engine/xmlform/inputdocs/inputdocs_Edit.html +++ b/workflow/engine/xmlform/inputdocs/inputdocs_Edit.html @@ -1,4 +1,4 @@ - +
@@ -8,8 +8,12 @@ - - + + + @@ -20,43 +24,49 @@ - + - + - + - + - + - + - + + + + + + + @@ -70,4 +80,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/workflow/engine/xmlform/inputdocs/inputdocs_Edit.xml b/workflow/engine/xmlform/inputdocs/inputdocs_Edit.xml index 1b48505a6..4363d6570 100755 --- a/workflow/engine/xmlform/inputdocs/inputdocs_Edit.xml +++ b/workflow/engine/xmlform/inputdocs/inputdocs_Edit.xml @@ -2,6 +2,7 @@ + <en><![CDATA[Input Document Information]]></en> @@ -29,6 +30,22 @@ + + + Maximum file size + + + + + + + + + + + Max upload file size + + diff --git a/workflow/engine/xmlform/inputdocs/inputdocs_Options.xml b/workflow/engine/xmlform/inputdocs/inputdocs_Options.xml index 5ae097fbe..e7bfe1c46 100755 --- a/workflow/engine/xmlform/inputdocs/inputdocs_Options.xml +++ b/workflow/engine/xmlform/inputdocs/inputdocs_Options.xml @@ -44,6 +44,32 @@ var currentPagedTable = @#PAGED_TABLE_ID; return false; } } + + if (getField("INP_DOC_MAX_FILESIZE").value.trim() != "") { + var maxFilesize = parseInt(getField("INP_DOC_MAX_FILESIZE").value.trim()); + var maxFilesizeUnit = getField("INP_DOC_MAX_FILESIZE_UNIT").value; + + var uploadMaxFilesize = parseInt(getField("INP_DOC_UPLOAD_MAX_FILESIZE").value); + + maxFilesize = maxFilesize * ((maxFilesizeUnit == "MB")? 1024 * 1024 : 1024); + + if(maxFilesize > 0) { + if(maxFilesize > uploadMaxFilesize) { + new leimnud.module.app.alert().make({label: _("ID_SIZE_VERY_LARGE_PERMITTED")}); + getField("INP_DOC_MAX_FILESIZE").focus(); + return false; + } + } else { + new leimnud.module.app.alert().make({label: _("ID_MAXIMUM_SIZE_FILE_GREATER_THAN_ZERO")}); + getField("INP_DOC_MAX_FILESIZE").focus(); + return false; + } + } else { + new leimnud.module.app.alert().make({label: _("ID_MAXIMUM_SIZE_FILE_REQUIRED")}); + getField("INP_DOC_MAX_FILESIZE").focus(); + return false; + } + return true; } function inputdocsSave( form ) {
{$form.PRO_UID}
+ {$form.PRO_UID} + {$form.INP_DOC_UPLOAD_MAX_FILESIZE} +
{$form.INP_DOC_UID}
{$INP_DOC_TITLE} {$form.INP_DOC_TITLE}{$form.INP_DOC_TITLE}
{$INP_DOC_FORM_NEEDED} {$form.INP_DOC_FORM_NEEDED}{$form.INP_DOC_FORM_NEEDED}
{$INP_DOC_ORIGINAL} {$form.INP_DOC_ORIGINAL}{$form.INP_DOC_ORIGINAL}
{$INP_DOC_DESCRIPTION} {$form.INP_DOC_DESCRIPTION}{$form.INP_DOC_DESCRIPTION}
{$INP_DOC_VERSIONING} {$form.INP_DOC_VERSIONING}{$form.INP_DOC_VERSIONING}
{$INP_DOC_DESTINATION_PATH} {$form.INP_DOC_DESTINATION_PATH}{$form.INP_DOC_DESTINATION_PATH}
{$INP_DOC_TAGS} {$form.INP_DOC_TAGS}{$form.INP_DOC_TAGS}
{$INP_DOC_TYPE_FILE} {$form.INP_DOC_TYPE_FILE}
{$INP_DOC_MAX_FILESIZE}{$form.INP_DOC_MAX_FILESIZE} {$form.INP_DOC_MAX_FILESIZE_UNIT} {$INP_DOC_UPLOAD_MAX_FILESIZE_LABEL} {$form.INP_DOC_UPLOAD_MAX_FILESIZE_LABEL}

{$form.ACCEPT}   {$form.BTN_CANCEL}