HOR-1899
This commit is contained in:
@@ -305,151 +305,8 @@ try {
|
|||||||
//require_once ("classes/model/AppDocument.php");
|
//require_once ("classes/model/AppDocument.php");
|
||||||
|
|
||||||
if (isset( $_FILES["form"]["name"] ) && count( $_FILES["form"]["name"] ) > 0) {
|
if (isset( $_FILES["form"]["name"] ) && count( $_FILES["form"]["name"] ) > 0) {
|
||||||
$arrayField = array ();
|
$oInputDocument = new \ProcessMaker\BusinessModel\Cases\InputDocument();
|
||||||
$arrayFileName = array ();
|
$oInputDocument->uploadFileCase($_FILES, $oCase, $_SESSION["USER_LOGGED"], $_SESSION["APPLICATION"], $_SESSION["INDEX"]);
|
||||||
$arrayFileTmpName = array ();
|
|
||||||
$arrayFileError = array ();
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
foreach ($_FILES["form"]["name"] as $fieldIndex => $fieldValue) {
|
|
||||||
if (is_array( $fieldValue )) {
|
|
||||||
foreach ($fieldValue as $index => $value) {
|
|
||||||
if (is_array( $value )) {
|
|
||||||
foreach ($value as $grdFieldIndex => $grdFieldValue) {
|
|
||||||
$arrayField[$i]["grdName"] = $fieldIndex;
|
|
||||||
$arrayField[$i]["grdFieldName"] = $grdFieldIndex;
|
|
||||||
$arrayField[$i]["index"] = $index;
|
|
||||||
|
|
||||||
$arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex][$index][$grdFieldIndex];
|
|
||||||
$arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex][$index][$grdFieldIndex];
|
|
||||||
$arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex][$index][$grdFieldIndex];
|
|
||||||
$i = $i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$arrayField[$i] = $fieldIndex;
|
|
||||||
|
|
||||||
$arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex];
|
|
||||||
$arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex];
|
|
||||||
$arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex];
|
|
||||||
$i = $i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (count( $arrayField ) > 0) {
|
|
||||||
for ($i = 0; $i <= count( $arrayField ) - 1; $i ++) {
|
|
||||||
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"]] )) {
|
|
||||||
$indocUid = $_POST["INPUTS"][$arrayField[$i]["grdName"]][$arrayField[$i]["grdFieldName"]];
|
|
||||||
}
|
|
||||||
|
|
||||||
$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) {
|
|
||||||
//require_once ("classes/model/AppFolder.php");
|
|
||||||
//require_once ("classes/model/InputDocument.php");
|
|
||||||
|
|
||||||
$oInputDocument = new InputDocument();
|
|
||||||
$aID = $oInputDocument->load( $indocUid );
|
|
||||||
|
|
||||||
//Get the Custom Folder ID (create if necessary)
|
|
||||||
$oFolder = new AppFolder();
|
|
||||||
|
|
||||||
//***Validating the file allowed extensions***
|
|
||||||
$res = G::verifyInputDocExtension($aID['INP_DOC_TYPE_FILE'], $arrayFileName[$i], $arrayFileTmpName[$i]);
|
|
||||||
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] );
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
$oAppDocument = new AppDocument();
|
|
||||||
$oAppDocument->create( $aFields );
|
|
||||||
|
|
||||||
$iDocVersion = $oAppDocument->getDocVersion();
|
|
||||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
|
||||||
$aInfo = pathinfo( $oAppDocument->getAppDocFilename() );
|
|
||||||
$sExtension = ((isset( $aInfo["extension"] )) ? $aInfo["extension"] : "");
|
|
||||||
$pathUID = G::getPathFromUID($_SESSION["APPLICATION"]);
|
|
||||||
$sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP;
|
|
||||||
$sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension;
|
|
||||||
|
|
||||||
G::uploadFile( $arrayFileTmpName[$i], $sPathName, $sFileName );
|
|
||||||
|
|
||||||
//set variable for APP_DOC_UID
|
|
||||||
$aData["APP_DATA"][$oAppDocument->getAppDocFieldname()] = G::json_encode([$oAppDocument->getAppDocUid()]);
|
|
||||||
$aData["APP_DATA"][$oAppDocument->getAppDocFieldname() . "_label"] = G::json_encode([$oAppDocument->getAppDocFilename()]);
|
|
||||||
$oCase->updateCase($_SESSION['APPLICATION'], $aData);
|
|
||||||
|
|
||||||
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
|
|
||||||
$oPluginRegistry = &PMPluginRegistry::getSingleton();
|
|
||||||
|
|
||||||
if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( "uploadDocumentData" )) {
|
|
||||||
$triggerDetail = $oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT );
|
|
||||||
$documentData = new uploadDocumentData( $_SESSION["APPLICATION"], $_SESSION["USER_LOGGED"], $sPathName . $sFileName, $aFields["APP_DOC_FILENAME"], $sAppDocUid, $iDocVersion );
|
|
||||||
$uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
|
|
||||||
|
|
||||||
if ($uploadReturn) {
|
|
||||||
$aFields["APP_DOC_PLUGIN"] = $triggerDetail->sNamespace;
|
|
||||||
|
|
||||||
if (! isset( $aFields["APP_DOC_UID"] )) {
|
|
||||||
$aFields["APP_DOC_UID"] = $sAppDocUid;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! isset( $aFields["DOC_VERSION"] )) {
|
|
||||||
$aFields["DOC_VERSION"] = $iDocVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
$oAppDocument->update( $aFields );
|
|
||||||
|
|
||||||
unlink( $sPathName . $sFileName );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Delete MultipleFile
|
//Delete MultipleFile
|
||||||
|
|||||||
@@ -121,61 +121,9 @@ if (PMLicensedFeatures
|
|||||||
$code == 0 ? uploadAbeRequest($dataAbeRequests) : '';
|
$code == 0 ? uploadAbeRequest($dataAbeRequests) : '';
|
||||||
|
|
||||||
if (isset ( $_FILES ['form'] )) {
|
if (isset ( $_FILES ['form'] )) {
|
||||||
foreach ($_FILES ['form'] ['name'] as $fieldName => $value) {
|
if (isset( $_FILES["form"]["name"] ) && count( $_FILES["form"]["name"] ) > 0) {
|
||||||
if ($_FILES ['form'] ['error'] [$fieldName] == 0) {
|
$oInputDocument = new \ProcessMaker\BusinessModel\Cases\InputDocument();
|
||||||
$appDocument = new AppDocument ( );
|
$oInputDocument->uploadFileCase($_FILES, $case, $current_user_uid, $_REQUEST['APP_UID'], $_REQUEST["DEL_INDEX"]);
|
||||||
|
|
||||||
if ( isset ( $_REQUEST['INPUTS'] [$fieldName] ) && $_REQUEST['INPUTS'] [$fieldName] != '' ) {
|
|
||||||
require_once 'classes/model/AppFolder.php';
|
|
||||||
require_once 'classes/model/InputDocument.php';
|
|
||||||
|
|
||||||
$inputDocument = new InputDocument();
|
|
||||||
$id = $inputDocument->load($_REQUEST['INPUTS'] [$fieldName]);
|
|
||||||
|
|
||||||
//Get the Custom Folder ID (create if necessary)
|
|
||||||
$oFolder=new AppFolder();
|
|
||||||
$folderId=$oFolder->createFromPath($id['INP_DOC_DESTINATION_PATH']);
|
|
||||||
|
|
||||||
//Tags
|
|
||||||
$fileTags=$oFolder->parseTags($id['INP_DOC_TAGS']);
|
|
||||||
|
|
||||||
$fields = array (
|
|
||||||
'APP_UID' => $_REQUEST['APP_UID'],
|
|
||||||
'DEL_INDEX' => $_REQUEST ['DEL_INDEX'],
|
|
||||||
'USR_UID' => $casesFields['APP_DATA']['USER_LOGGED'],
|
|
||||||
'DOC_UID' => $_REQUEST['INPUTS'] [$fieldName],
|
|
||||||
'APP_DOC_TYPE' => 'INPUT',
|
|
||||||
'APP_DOC_CREATE_DATE' => date ( 'Y-m-d H:i:s' ),
|
|
||||||
'APP_DOC_COMMENT' => '',
|
|
||||||
'APP_DOC_TITLE' => '',
|
|
||||||
'APP_DOC_FILENAME' => $_FILES ['form'] ['name'] [$fieldName],
|
|
||||||
'FOLDER_UID' => $folderId,
|
|
||||||
'APP_DOC_TAGS' => $fileTags
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$fields = array (
|
|
||||||
'APP_UID' => $_REQUEST['APP_UID'],
|
|
||||||
'DEL_INDEX' => $_REQUEST ['DEL_INDEX'],
|
|
||||||
'USR_UID' => $casesFields['APP_DATA']['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' => $_FILES ['form'] ['name'] [$fieldName]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$appDocument->create($fields);
|
|
||||||
$docVersion = $appDocument->getDocVersion();
|
|
||||||
$appDocUid = $appDocument->getAppDocUid ();
|
|
||||||
$info = pathinfo ( $appDocument->getAppDocFilename () );
|
|
||||||
$extension = (isset ( $info ['extension'] ) ? $info ['extension'] : '');
|
|
||||||
$pathName = PATH_DOCUMENT . $_REQUEST['APP_UID'] . PATH_SEP;
|
|
||||||
$fileName = $appDocUid . '_'.$docVersion.'.' . $extension;
|
|
||||||
|
|
||||||
G::uploadFile ( $_FILES ['form'] ['tmp_name'] [$fieldName], $pathName, $fileName );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -644,4 +644,148 @@ class InputDocument
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $FILES $_FILES request files
|
||||||
|
* @param $Cases \Cases object class.cases
|
||||||
|
* @param $userUid string user id
|
||||||
|
* @param $appUid string application id
|
||||||
|
* @param $delIndex int the index case
|
||||||
|
*/
|
||||||
|
public function uploadFileCase($FILES, $Cases, $userUid, $appUid, $delIndex)
|
||||||
|
{
|
||||||
|
$arrayField = array();
|
||||||
|
$arrayFileName = array();
|
||||||
|
$arrayFileTmpName = array();
|
||||||
|
$arrayFileError = array();
|
||||||
|
$i = 0;
|
||||||
|
foreach ($FILES["form"]["name"] as $fieldIndex => $fieldValue) {
|
||||||
|
if (is_array($fieldValue)) {
|
||||||
|
foreach ($fieldValue as $index => $value) {
|
||||||
|
if (is_array($value)) {
|
||||||
|
foreach ($value as $grdFieldIndex => $grdFieldValue) {
|
||||||
|
$arrayField[$i]["grdName"] = $fieldIndex;
|
||||||
|
$arrayField[$i]["grdFieldName"] = $grdFieldIndex;
|
||||||
|
$arrayField[$i]["index"] = $index;
|
||||||
|
|
||||||
|
$arrayFileName[$i] = $FILES["form"]["name"][$fieldIndex][$index][$grdFieldIndex];
|
||||||
|
$arrayFileTmpName[$i] = $FILES["form"]["tmp_name"][$fieldIndex][$index][$grdFieldIndex];
|
||||||
|
$arrayFileError[$i] = $FILES["form"]["error"][$fieldIndex][$index][$grdFieldIndex];
|
||||||
|
$i = $i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$arrayField[$i] = $fieldIndex;
|
||||||
|
|
||||||
|
$arrayFileName[$i] = $FILES["form"]["name"][$fieldIndex];
|
||||||
|
$arrayFileTmpName[$i] = $FILES["form"]["tmp_name"][$fieldIndex];
|
||||||
|
$arrayFileError[$i] = $FILES["form"]["error"][$fieldIndex];
|
||||||
|
$i = $i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($arrayField) > 0) {
|
||||||
|
foreach ($arrayField as $i => $item) {
|
||||||
|
//for ($i = 0; $i <= count($arrayField) - 1; $i++) {
|
||||||
|
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"]])) {
|
||||||
|
$indocUid = $_POST["INPUTS"][$arrayField[$i]["grdName"]][$arrayField[$i]["grdFieldName"]];
|
||||||
|
}
|
||||||
|
$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) {
|
||||||
|
$oInputDocument = new \InputDocument();
|
||||||
|
$aID = $oInputDocument->load($indocUid);
|
||||||
|
|
||||||
|
//Get the Custom Folder ID (create if necessary)
|
||||||
|
$oFolder = new \AppFolder();
|
||||||
|
|
||||||
|
//***Validating the file allowed extensions***
|
||||||
|
$res = \G::verifyInputDocExtension($aID['INP_DOC_TYPE_FILE'], $arrayFileName[$i], $arrayFileTmpName[$i]);
|
||||||
|
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]);
|
||||||
|
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" => $appUid, "DEL_INDEX" => $delIndex, "USR_UID" => $userUid, "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" => $appUid, "DEL_INDEX" => $delIndex, "USR_UID" => $userUid, "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);
|
||||||
|
}
|
||||||
|
|
||||||
|
$oAppDocument = new \AppDocument();
|
||||||
|
$oAppDocument->create($aFields);
|
||||||
|
|
||||||
|
$iDocVersion = $oAppDocument->getDocVersion();
|
||||||
|
$sAppDocUid = $oAppDocument->getAppDocUid();
|
||||||
|
$aInfo = pathinfo($oAppDocument->getAppDocFilename());
|
||||||
|
$sExtension = ((isset($aInfo["extension"])) ? $aInfo["extension"] : "");
|
||||||
|
$pathUID = \G::getPathFromUID($appUid);
|
||||||
|
$sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP;
|
||||||
|
$sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension;
|
||||||
|
|
||||||
|
\G::uploadFile($arrayFileTmpName[$i], $sPathName, $sFileName);
|
||||||
|
|
||||||
|
//set variable for APP_DOC_UID
|
||||||
|
$aData["APP_DATA"][$oAppDocument->getAppDocFieldname()] = \G::json_encode([$oAppDocument->getAppDocUid()]);
|
||||||
|
$aData["APP_DATA"][$oAppDocument->getAppDocFieldname() . "_label"] = \G::json_encode([$oAppDocument->getAppDocFilename()]);
|
||||||
|
$Cases->updateCase($appUid, $aData);
|
||||||
|
|
||||||
|
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
|
||||||
|
$oPluginRegistry = &\PMPluginRegistry::getSingleton();
|
||||||
|
|
||||||
|
if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists("uploadDocumentData")) {
|
||||||
|
$triggerDetail = $oPluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT);
|
||||||
|
$documentData = new \uploadDocumentData($appUid, $userUid, $sPathName . $sFileName, $aFields["APP_DOC_FILENAME"], $sAppDocUid, $iDocVersion);
|
||||||
|
$uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
|
||||||
|
|
||||||
|
if ($uploadReturn) {
|
||||||
|
$aFields["APP_DOC_PLUGIN"] = $triggerDetail->sNamespace;
|
||||||
|
if (!isset($aFields["APP_DOC_UID"])) {
|
||||||
|
$aFields["APP_DOC_UID"] = $sAppDocUid;
|
||||||
|
}
|
||||||
|
if (!isset($aFields["DOC_VERSION"])) {
|
||||||
|
$aFields["DOC_VERSION"] = $iDocVersion;
|
||||||
|
}
|
||||||
|
$oAppDocument->update($aFields);
|
||||||
|
unlink($sPathName . $sFileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user