BUG-14990 - NEW FEATURE, permitir especificar extensiones para los inputdocs.
Nuevo campo en Input Documents, dicho campo acepta las extensiones de los inputdocs permitidos. Se agregaron validaciones para que funcione correctamente
This commit is contained in:
@@ -5328,6 +5328,177 @@ class G
|
||||
}
|
||||
return $from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the InputDoc extension, cheking the file name extension (.pdf, .ppt) and the file content.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function verifyInputDocExtension($InpDocAllowedFiles, $filesName, $filesTmpName){
|
||||
$allowedTypes = explode(", ", $InpDocAllowedFiles);
|
||||
$flag = 0;
|
||||
|
||||
if (!extension_loaded('fileinfo')) {
|
||||
$dtype = explode(".", $filesName);
|
||||
|
||||
foreach ($allowedTypes as $types => $val) {
|
||||
if((preg_match('/^\*\.?[a-z]{2,8}$/', $val)) || ($val == '*.*')){
|
||||
$allowedDocTypes = substr($val, 2);
|
||||
if(($dtype[count($dtype) -1]) != $allowedDocTypes){
|
||||
$flag = 1;
|
||||
} else {
|
||||
$flag = 0;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$message = G::LoadTranslation('ID_UPLOAD_ERR_WRONG_ALLOWED_EXTENSION_FORMAT' );
|
||||
G::SendMessageText( $message, "ERROR" );
|
||||
|
||||
$backUrlObj = explode( "sys" . SYS_SYS, $_SERVER['HTTP_REFERER'] );
|
||||
G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] );
|
||||
die();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||
$finfo_ = $finfo->file($filesTmpName);
|
||||
$docType = explode("/", $finfo_);
|
||||
|
||||
foreach ($allowedTypes as $types => $val) {
|
||||
if((preg_match('/^\*\.?[a-z]{2,8}$/', $val)) || ($val == '*.*')){
|
||||
$allowedDocTypes = substr($val, 2);
|
||||
|
||||
switch($allowedDocTypes){
|
||||
case '*':
|
||||
$flag = 0;
|
||||
break;
|
||||
case 'xls':
|
||||
if($docType[1] != 'vnd.ms-excel'){
|
||||
$flag = 1;
|
||||
} else {
|
||||
$flag = 0;
|
||||
}
|
||||
break;
|
||||
case 'doc':
|
||||
if($docType[1] != 'msword'){
|
||||
$flag = 1;
|
||||
} else {
|
||||
$flag = 0;
|
||||
}
|
||||
break;
|
||||
case 'ppt':
|
||||
if($docType[1] != 'vnd.ms-office'){
|
||||
$flag = 1;
|
||||
} else {
|
||||
$flag = 0;
|
||||
}
|
||||
break;
|
||||
case 'docx':
|
||||
case 'pptx':
|
||||
case 'xlsx':
|
||||
if($docType[1] != 'zip'){
|
||||
$flag = 1;
|
||||
} else {
|
||||
$flag = 0;
|
||||
}
|
||||
break;
|
||||
case 'exe':
|
||||
case 'wmv':
|
||||
if($docType[1] != 'octet-stream'){
|
||||
$flag = 1;
|
||||
} else {
|
||||
$flag = 0;
|
||||
}
|
||||
break;
|
||||
case 'jpg':
|
||||
if ($docType[1] != 'jpeg'){
|
||||
$flag = 1;
|
||||
} else {
|
||||
$flag = 0;
|
||||
}
|
||||
break;
|
||||
case 'mp3':
|
||||
if ($docType[1] != 'mpeg'){
|
||||
$flag = 1;
|
||||
} else {
|
||||
$flag = 0;
|
||||
}
|
||||
break;
|
||||
case 'rar':
|
||||
if ($docType[1] != 'x-rar'){
|
||||
$flag = 1;
|
||||
} else {
|
||||
$flag = 0;
|
||||
}
|
||||
break;
|
||||
case 'txt':
|
||||
case 'pm':
|
||||
if ($docType[1] != 'plain'){
|
||||
$flag = 1;
|
||||
} else {
|
||||
$flag = 0;
|
||||
}
|
||||
break;
|
||||
case 'htm':
|
||||
case 'html':
|
||||
if ($docType[1] != 'html'){
|
||||
$flag = 1;
|
||||
} else {
|
||||
$flag = 0;
|
||||
}
|
||||
break;
|
||||
case 'po':
|
||||
if ($docType[1] != 'x-po'){
|
||||
$flag = 1;
|
||||
} else {
|
||||
$flag = 0;
|
||||
}
|
||||
break;
|
||||
case 'pdf':
|
||||
case 'png':
|
||||
case 'jpeg':
|
||||
case 'gif':
|
||||
case 'zip':
|
||||
case 'mp4':
|
||||
if ($docType[1] != $allowedDocTypes){
|
||||
$flag = 1;
|
||||
} else {
|
||||
$flag = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$dtype = explode(".", $filesName);
|
||||
if(($dtype[count($dtype) - 1]) != $allowedDocTypes){
|
||||
$flag = 1;
|
||||
} else {
|
||||
$flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if($flag == 0){
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$message = G::LoadTranslation('ID_UPLOAD_ERR_WRONG_ALLOWED_EXTENSION_FORMAT' );
|
||||
G::SendMessageText( $message, "ERROR" );
|
||||
|
||||
$backUrlObj = explode( "sys" . SYS_SYS, $_SERVER['HTTP_REFERER'] );
|
||||
G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] );
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( $flag == 1){
|
||||
$message = G::LoadTranslation( 'ID_UPLOAD_ERR_NOT_ALLOWED_EXTENSION' );
|
||||
G::SendMessageText( $message, "ERROR" );
|
||||
|
||||
$backUrlObj = explode( "sys" . SYS_SYS, $_SERVER['HTTP_REFERER'] );
|
||||
G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] );
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,6 +81,8 @@ class InputDocumentMapBuilder
|
||||
|
||||
$tMap->addColumn('INP_DOC_TAGS', 'InpDocTags', 'string', CreoleTypes::LONGVARCHAR, false, null);
|
||||
|
||||
$tMap->addColumn('INP_DOC_TYPE_FILE', 'InpDocTypeFile', 'string', CreoleTypes::VARCHAR, false, 200);
|
||||
|
||||
$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.');
|
||||
|
||||
@@ -75,6 +75,12 @@ abstract class BaseInputDocument extends BaseObject implements Persistent
|
||||
*/
|
||||
protected $inp_doc_tags;
|
||||
|
||||
/**
|
||||
* The value for the inp_doc_type_file field.
|
||||
* @var string
|
||||
*/
|
||||
protected $inp_doc_type_file = '*.*';
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
@@ -177,6 +183,17 @@ abstract class BaseInputDocument extends BaseObject implements Persistent
|
||||
return $this->inp_doc_tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [inp_doc_type_file] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInpDocTypeFile()
|
||||
{
|
||||
|
||||
return $this->inp_doc_type_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [inp_doc_uid] column.
|
||||
*
|
||||
@@ -353,6 +370,28 @@ abstract class BaseInputDocument extends BaseObject implements Persistent
|
||||
|
||||
} // setInpDocTags()
|
||||
|
||||
/**
|
||||
* Set the value of [inp_doc_type_file] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setInpDocTypeFile($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_type_file !== $v || $v === '*.*') {
|
||||
$this->inp_doc_type_file = $v;
|
||||
$this->modifiedColumns[] = InputDocumentPeer::INP_DOC_TYPE_FILE;
|
||||
}
|
||||
|
||||
} // setInpDocTypeFile()
|
||||
|
||||
/**
|
||||
* Hydrates (populates) the object variables with values from the database resultset.
|
||||
*
|
||||
@@ -386,12 +425,14 @@ abstract class BaseInputDocument extends BaseObject implements Persistent
|
||||
|
||||
$this->inp_doc_tags = $rs->getString($startcol + 7);
|
||||
|
||||
$this->inp_doc_type_file = $rs->getString($startcol + 8);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 8; // 8 = InputDocumentPeer::NUM_COLUMNS - InputDocumentPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
return $startcol + 9; // 9 = InputDocumentPeer::NUM_COLUMNS - InputDocumentPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating InputDocument object", $e);
|
||||
@@ -619,6 +660,9 @@ abstract class BaseInputDocument extends BaseObject implements Persistent
|
||||
case 7:
|
||||
return $this->getInpDocTags();
|
||||
break;
|
||||
case 8:
|
||||
return $this->getInpDocTypeFile();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
@@ -647,6 +691,7 @@ abstract class BaseInputDocument extends BaseObject implements Persistent
|
||||
$keys[5] => $this->getInpDocVersioning(),
|
||||
$keys[6] => $this->getInpDocDestinationPath(),
|
||||
$keys[7] => $this->getInpDocTags(),
|
||||
$keys[8] => $this->getInpDocTypeFile(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
@@ -702,6 +747,9 @@ abstract class BaseInputDocument extends BaseObject implements Persistent
|
||||
case 7:
|
||||
$this->setInpDocTags($value);
|
||||
break;
|
||||
case 8:
|
||||
$this->setInpDocTypeFile($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
@@ -757,6 +805,10 @@ abstract class BaseInputDocument extends BaseObject implements Persistent
|
||||
$this->setInpDocTags($arr[$keys[7]]);
|
||||
}
|
||||
|
||||
if (array_key_exists($keys[8], $arr)) {
|
||||
$this->setInpDocTypeFile($arr[$keys[8]]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -800,6 +852,10 @@ abstract class BaseInputDocument extends BaseObject implements Persistent
|
||||
$criteria->add(InputDocumentPeer::INP_DOC_TAGS, $this->inp_doc_tags);
|
||||
}
|
||||
|
||||
if ($this->isColumnModified(InputDocumentPeer::INP_DOC_TYPE_FILE)) {
|
||||
$criteria->add(InputDocumentPeer::INP_DOC_TYPE_FILE, $this->inp_doc_type_file);
|
||||
}
|
||||
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
@@ -868,6 +924,8 @@ abstract class BaseInputDocument extends BaseObject implements Persistent
|
||||
|
||||
$copyObj->setInpDocTags($this->inp_doc_tags);
|
||||
|
||||
$copyObj->setInpDocTypeFile($this->inp_doc_type_file);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ abstract class BaseInputDocumentPeer
|
||||
const CLASS_DEFAULT = 'classes.model.InputDocument';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 8;
|
||||
const NUM_COLUMNS = 9;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
@@ -55,6 +55,9 @@ abstract class BaseInputDocumentPeer
|
||||
/** the column name for the INP_DOC_TAGS field */
|
||||
const INP_DOC_TAGS = 'INPUT_DOCUMENT.INP_DOC_TAGS';
|
||||
|
||||
/** the column name for the INP_DOC_TYPE_FILE field */
|
||||
const INP_DOC_TYPE_FILE = 'INPUT_DOCUMENT.INP_DOC_TYPE_FILE';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
@@ -66,10 +69,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', ),
|
||||
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, ),
|
||||
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', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
|
||||
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, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -79,10 +82,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, ),
|
||||
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, ),
|
||||
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, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
|
||||
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, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -199,6 +202,8 @@ abstract class BaseInputDocumentPeer
|
||||
|
||||
$criteria->addSelectColumn(InputDocumentPeer::INP_DOC_TAGS);
|
||||
|
||||
$criteria->addSelectColumn(InputDocumentPeer::INP_DOC_TYPE_FILE);
|
||||
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(INPUT_DOCUMENT.INP_DOC_UID)';
|
||||
|
||||
@@ -580,6 +580,7 @@
|
||||
<column name="INP_DOC_VERSIONING" type="TINYINT" required="true" default="0"/>
|
||||
<column name="INP_DOC_DESTINATION_PATH" type="LONGVARCHAR" required="false"/>
|
||||
<column name="INP_DOC_TAGS" type="LONGVARCHAR" required="false"/>
|
||||
<column name="INP_DOC_TYPE_FILE" type="VARCHAR" size="200" required="false" default="*.*"/>
|
||||
<validator column="INP_DOC_UID">
|
||||
<rule name="maxLength" value="32" message="Input Document UID can be no larger than ${value} in size"/>
|
||||
<rule name="required" message="Input Document UID is required."/>
|
||||
|
||||
@@ -267,6 +267,7 @@ CREATE TABLE `INPUT_DOCUMENT`
|
||||
`INP_DOC_VERSIONING` TINYINT default 0 NOT NULL,
|
||||
`INP_DOC_DESTINATION_PATH` MEDIUMTEXT,
|
||||
`INP_DOC_TAGS` MEDIUMTEXT,
|
||||
`INP_DOC_TYPE_FILE` VARCHAR(200) default '*.*',
|
||||
PRIMARY KEY (`INP_DOC_UID`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET='utf8' COMMENT='Documentation required';
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
@@ -908,6 +908,9 @@ 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'] );
|
||||
$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;
|
||||
|
||||
@@ -279,6 +279,9 @@ try {
|
||||
//Get the Custom Folder ID (create if necessary)
|
||||
$oFolder = new AppFolder();
|
||||
|
||||
//***Validating the file allowed extensions***
|
||||
G::verifyInputDocExtension($aID['INP_DOC_TYPE_FILE'], $_FILES["form"]["name"]["input"], $_FILES["form"]["tmp_name"]["input"]);
|
||||
|
||||
$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);
|
||||
|
||||
@@ -93,8 +93,10 @@ if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) {
|
||||
$_SESSION["TRIGGER_DEBUG"]["TRIGGERS_VALUES"] = $arrayTrigger;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//***Validating the file allowed extensions***
|
||||
$oInputDocument = new InputDocument();
|
||||
$InpDocData = $oInputDocument->load( $inputDocumentUid );
|
||||
G::verifyInputDocExtension($InpDocData['INP_DOC_TYPE_FILE'], $_FILES["form"]["name"]["APP_DOC_FILENAME"], $_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"]);
|
||||
|
||||
//Add Input Document
|
||||
if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) {
|
||||
|
||||
@@ -88,6 +88,18 @@ try {
|
||||
$aData = $_POST;
|
||||
}
|
||||
|
||||
//Validating the format of the allowed extentions
|
||||
//Allowed Types has to have this format -> *.pdf, *.docx or *.* to all.
|
||||
$allowedTypes = explode(", ", $aData['INP_DOC_TYPE_FILE']);
|
||||
foreach ($allowedTypes as $types => $val) {
|
||||
if((preg_match('/^\*\.?[a-z]{2,8}$/', $val)) || ($val == '*.*')){
|
||||
}else {
|
||||
$message = G::LoadTranslation( 'ID_UPLOAD_ERR_WRONG_ALLOWED_EXTENSION_FORMAT' );
|
||||
G::SendMessageText( $message, "ERROR" );
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
if ($aData['INP_DOC_UID'] == '') {
|
||||
unset( $aData['INP_DOC_UID'] );
|
||||
$oInputDocument->create( $aData );
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
</tr>
|
||||
<tr style="display: none;">
|
||||
<td colspan="2">{$form.docVersion}</td>
|
||||
</tr>
|
||||
<tr style="display: none;">
|
||||
<td colspan="2">{$form.fileTypes}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="FormLabel" width="{$form_labelWidth}">{$APP_DOC_FILENAME}</td>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<APP_DOC_UID type="hidden"/>
|
||||
<actionType type="hidden"/>
|
||||
<docVersion type="hidden"/>
|
||||
<fileTypes type="hidden"/>
|
||||
<APP_DOC_FILENAME type="file">
|
||||
<en><![CDATA[File]]></en>
|
||||
</APP_DOC_FILENAME>
|
||||
@@ -39,6 +40,27 @@ var verifyInfo = function(oForm)
|
||||
oAux.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
docType = oAux.value.split(".");
|
||||
docType = docType[docType.length - 1];
|
||||
|
||||
allowedTypes = getField('fileTypes').value.split(", ");
|
||||
|
||||
for(i=0; i<allowedTypes.length; i++){
|
||||
allowed = allowedTypes[i].replace('*','').replace('.','');
|
||||
if((allowed != '*') && (docType != allowed)){
|
||||
flag = 1;
|
||||
} else {
|
||||
flag = 0;
|
||||
i = allowedTypes.length;
|
||||
}
|
||||
}
|
||||
if( flag == 1){
|
||||
alert('@G::LoadTranslation(ID_UPLOAD_ERR_NOT_ALLOWED_EXTENSION)');
|
||||
oAux.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
getField('SAVE').disabled = true;
|
||||
getField('BTN_CANCEL').disabled = true;
|
||||
oForm.submit();
|
||||
|
||||
@@ -51,6 +51,11 @@
|
||||
<td class="FormLabel" width="{$form_labelWidth}">{$INP_DOC_TAGS}</td>
|
||||
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.INP_DOC_TAGS} </td> //-->
|
||||
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.INP_DOC_TAGS}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="FormLabel" width="{$form_labelWidth}">{$INP_DOC_TYPE_FILE}</td>
|
||||
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.INP_DOC_TYPE_FILE} </td> //-->
|
||||
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.INP_DOC_TYPE_FILE}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="FormButton" colspan="2" align="center"> <br/> {$form.ACCEPT} {$form.BTN_CANCEL} </td>
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
<INP_DOC_TAGS type="textpm" size="30" maxlength="200" showVars="1" process="@#PRO_UID" symbol="@#" validate="Tag">
|
||||
<en><![CDATA[Tags]]></en>
|
||||
</INP_DOC_TAGS>
|
||||
<INP_DOC_TYPE_FILE type="text" maxlength="200" size="37" colWidth="200" titleAlign="left" align="left" hint="To verify that the content of the file is the correct according to its extension, it is necessary to enable the FILEINFO extension, if this is not enabled only the extension will be verified." dataCompareField="T.CON_VALUE" dataCompareType="contains">
|
||||
<en><![CDATA[Allowed file extensions (use *.* to allow any extension)]]></en>
|
||||
</INP_DOC_TYPE_FILE>
|
||||
<BTN_CANCEL type="button" onclick="cancel();">
|
||||
<en><![CDATA[Cancel]]></en>
|
||||
</BTN_CANCEL>
|
||||
|
||||
@@ -17,9 +17,34 @@ var currentPagedTable = @#PAGED_TABLE_ID;
|
||||
popupWindow('@G::LoadTranslation(ID_EDIT_INPUTDOCS)', '@G::encryptlink(@#inputdocsEdit)?INP_DOC_UID='+ uid , 500, 410);
|
||||
}
|
||||
function validate_form(){
|
||||
var sw = true;
|
||||
sw = sw && (getField('INP_DOC_TITLE').value!='');
|
||||
return sw;
|
||||
if(getField('INP_DOC_TITLE').value == ''){
|
||||
alert('@G::LoadTranslation(ID_INPUT_DOC_TITLE_REQUIRED)');
|
||||
getField('INP_DOC_TITLE').focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
oTypeFile = getField('INP_DOC_TYPE_FILE');
|
||||
if (oTypeFile.value == '' ){
|
||||
alert('@G::LoadTranslation(ID_INPUT_DOC_TYPE_FILE_REQUIRED)');
|
||||
oTypeFile.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
allowedTypes = getField('INP_DOC_TYPE_FILE').value.split(", ");
|
||||
expreg = /^\*\.?[a-z]{2,8}$/;
|
||||
|
||||
for(i=0; i<allowedTypes.length; i++){
|
||||
atype = allowedTypes[i];
|
||||
|
||||
if((atype=='*.*') || (expreg.test(atype)) ){
|
||||
//
|
||||
} else {
|
||||
alert('@G::LoadTranslation(ID_UPLOAD_ERR_WRONG_ALLOWED_EXTENSION_FORMAT)');
|
||||
oTypeFile.focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function inputdocsSave( form ) {
|
||||
var nameInput = getField('INP_DOC_TITLE').value;
|
||||
@@ -34,16 +59,12 @@ var currentPagedTable = @#PAGED_TABLE_ID;
|
||||
}else{
|
||||
alert(G_STRINGS.ID_EXIST_INPUTDOCUMENT);return false;
|
||||
}
|
||||
}else{
|
||||
alert('@G::LoadTranslation(ID_INPUT_DOC_TITLE_REQUIRED)'); return false;
|
||||
}
|
||||
}else{
|
||||
if (validate_form()){
|
||||
ajax_post( form.action, form, 'POST' );
|
||||
currentPopupWindow.remove();
|
||||
@#PAGED_TABLE_ID.refresh();
|
||||
}else{
|
||||
alert('@G::LoadTranslation(ID_INPUT_DOC_TITLE_REQUIRED)'); return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user