BUG 8333 "File field for each grid line" SOLVED
- New feature
- File field for each grid line
- Added "file" element in grids
- The QA team should test with:
* Grids in mode edit/view
* INPUT property (http://wiki.processmaker.com/index.php/2.0/Files)
* KnowledgeTree plugin
* And other cases
* Available from version 2.0.45
This commit is contained in:
@@ -30,18 +30,19 @@ try {
|
||||
throw new Exception(G::LoadTranslation('ID_INVALID_APPLICATION_ID_MSG', array('<a href=\''.$_SERVER['HTTP_REFERER'].'\'>{1}</a>', G::LoadTranslation('ID_REOPEN'))));
|
||||
}
|
||||
|
||||
$oForm = new Form ( $_SESSION ['PROCESS'] . '/' . $_GET ['UID'], PATH_DYNAFORM );
|
||||
$oForm->validatePost ();
|
||||
$oForm = new Form($_SESSION["PROCESS"] . "/" . $_GET["UID"], PATH_DYNAFORM);
|
||||
$oForm->validatePost();
|
||||
|
||||
/* Includes */
|
||||
G::LoadClass ( 'case' );
|
||||
//Includes
|
||||
G::LoadClass("case");
|
||||
|
||||
//load the variables
|
||||
$oCase = new Cases ( );
|
||||
$oCase->thisIsTheCurrentUser ( $_SESSION ['APPLICATION'], $_SESSION ['INDEX'], $_SESSION ['USER_LOGGED'], 'REDIRECT', 'cases_List' );
|
||||
$Fields = $oCase->loadCase ( $_SESSION ['APPLICATION'] );
|
||||
$Fields ['APP_DATA'] = array_merge ( $Fields ['APP_DATA'], G::getSystemConstants () );
|
||||
$Fields ['APP_DATA'] = array_merge ( $Fields ['APP_DATA'], ( array ) $_POST ['form'] );
|
||||
//Load the variables
|
||||
$oCase = new Cases();
|
||||
$oCase->thisIsTheCurrentUser($_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "cases_List");
|
||||
$Fields = $oCase->loadCase($_SESSION["APPLICATION"]);
|
||||
|
||||
$Fields["APP_DATA"] = array_merge($Fields["APP_DATA"], G::getSystemConstants());
|
||||
$Fields["APP_DATA"] = array_merge($Fields["APP_DATA"], $_POST["form"]);
|
||||
|
||||
#here we must verify if is a debug session
|
||||
$trigger_debug_session = $_SESSION ['TRIGGER_DEBUG'] ['ISSET']; #here we must verify if is a debugg session
|
||||
@@ -115,13 +116,13 @@ try {
|
||||
} catch ( Exception $oError ) {
|
||||
//Nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
// assembling the field list in order to save the data ina new record of a pm table
|
||||
if (empty($newValues)){
|
||||
$newValues = $aValues;
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($aValues as $aValueKey=>$aValueCont) {
|
||||
if (trim($newValues[$aValueKey])==''){
|
||||
@@ -138,7 +139,7 @@ try {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//save data
|
||||
$aData = array ();
|
||||
$aData ['APP_NUMBER'] = $Fields ['APP_NUMBER'];
|
||||
@@ -160,92 +161,148 @@ try {
|
||||
$oAdditionalTables->saveDataInTable( $oForm->fields [$oForm->fields[$id]->pmconnection]->pmtable, $newValues);
|
||||
}
|
||||
}
|
||||
|
||||
//save files
|
||||
require_once 'classes/model/AppDocument.php';
|
||||
if (isset ( $_FILES ['form'] )) {
|
||||
foreach ( $_FILES ['form'] ['name'] as $sFieldName => $vValue ) {
|
||||
if ($_FILES ['form'] ['error'] [$sFieldName] == 0) {
|
||||
$oAppDocument = new AppDocument();
|
||||
|
||||
if ( isset ( $_POST ['INPUTS'] [$sFieldName] ) && $_POST ['INPUTS'] [$sFieldName] != '' ) {
|
||||
require_once ('classes/model/AppFolder.php');
|
||||
require_once ('classes/model/InputDocument.php');
|
||||
|
||||
$oInputDocument = new InputDocument();
|
||||
$aID = $oInputDocument->load($_POST ['INPUTS'] [$sFieldName]);
|
||||
|
||||
//Get the Custom Folder ID (create if necessary)
|
||||
$oFolder=new AppFolder();
|
||||
$folderId=$oFolder->createFromPath($aID['INP_DOC_DESTINATION_PATH']);
|
||||
|
||||
//Tags
|
||||
$fileTags=$oFolder->parseTags($aID['INP_DOC_TAGS']);
|
||||
|
||||
$aFields = array (
|
||||
'APP_UID' => $_SESSION ['APPLICATION'],
|
||||
'DEL_INDEX' => $_SESSION ['INDEX'],
|
||||
'USR_UID' => $_SESSION ['USER_LOGGED'],
|
||||
'DOC_UID' => $_POST ['INPUTS'] [$sFieldName],
|
||||
'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'] [$sFieldName],
|
||||
'FOLDER_UID' => $folderId,
|
||||
'APP_DOC_TAGS' => $fileTags
|
||||
);
|
||||
}
|
||||
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' => $_FILES ['form'] ['name'] [$sFieldName]
|
||||
);
|
||||
}
|
||||
|
||||
$oAppDocument->create($aFields);
|
||||
|
||||
$iDocVersion = $oAppDocument->getDocVersion();
|
||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
||||
$aInfo = pathinfo($oAppDocument->getAppDocFilename());
|
||||
$sExtension = (isset ( $aInfo ['extension'] ) ? $aInfo ['extension'] : '');
|
||||
$sPathName = PATH_DOCUMENT . $_SESSION ['APPLICATION'] . PATH_SEP;
|
||||
$sFileName = $sAppDocUid . '_'.$iDocVersion.'.' . $sExtension;
|
||||
G::uploadFile ( $_FILES ['form'] ['tmp_name'] [$sFieldName], $sPathName, $sFileName );
|
||||
|
||||
//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;
|
||||
|
||||
//Save files
|
||||
require_once ("classes/model/AppDocument.php");
|
||||
|
||||
if (isset($_FILES["form"]["name"]) && count($_FILES["form"]["name"]) > 0) {
|
||||
$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) {
|
||||
for ($i = 0; $i <= count($arrayField) - 1; $i++) {
|
||||
if ($arrayFileError[$i] == 0) {
|
||||
$indocUid = null;
|
||||
$fieldName = null;
|
||||
|
||||
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"];
|
||||
} else {
|
||||
if (isset($_POST["INPUTS"][$arrayField[$i]]) &&
|
||||
!empty($_POST["INPUTS"][$arrayField[$i]])
|
||||
) {
|
||||
$indocUid = $_POST["INPUTS"][$arrayField[$i]];
|
||||
}
|
||||
|
||||
$fieldName = $arrayField[$i];
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
$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"] : "");
|
||||
$sPathName = PATH_DOCUMENT . $_SESSION ["APPLICATION"] . PATH_SEP;
|
||||
$sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension;
|
||||
|
||||
G::uploadFile($arrayFileTmpName[$i], $sPathName, $sFileName);
|
||||
|
||||
//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);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($aFields["DOC_VERSION"])) {
|
||||
$aFields["DOC_VERSION"] = $iDocVersion;
|
||||
}
|
||||
|
||||
$oAppDocument->update($aFields);
|
||||
|
||||
unlink($sPathName . $sFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//go to the next step
|
||||
|
||||
//Go to the next step
|
||||
$aNextStep = $oCase->getNextStep ( $_SESSION ['PROCESS'], $_SESSION ['APPLICATION'], $_SESSION ['INDEX'], $_SESSION ['STEP_POSITION'] );
|
||||
if (isset ( $_GET ['_REFRESH_'] )) {
|
||||
G::header ( 'location: ' . $_SERVER ['HTTP_REFERER'] );
|
||||
|
||||
@@ -1,156 +1,167 @@
|
||||
<?php
|
||||
/**
|
||||
* class.wsBase.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @Updated Dec 14, 2009 by Erik <erik@colosa.com>
|
||||
*
|
||||
* The point of this application is upload the file and create the input document record
|
||||
*
|
||||
* if the post attached file has error code 0 continue in other case nothing to do. */
|
||||
|
||||
if (isset($_FILES) && $_FILES['ATTACH_FILE']['error'] == 0) {
|
||||
try{
|
||||
G::LoadClass('case');
|
||||
|
||||
$folderId = '';
|
||||
$fileTags = '';
|
||||
|
||||
if (isset($_POST['DOC_UID']) && $_POST['DOC_UID'] != -1) {
|
||||
//The document is of an Specific Input Document. Get path and Tag information
|
||||
require_once ('classes/model/AppFolder.php');
|
||||
require_once ('classes/model/InputDocument.php');
|
||||
|
||||
$oInputDocument = new InputDocument();
|
||||
$aID = $oInputDocument->load($_POST['DOC_UID']);
|
||||
|
||||
//Get the Custom Folder ID (create if necessary)
|
||||
$oFolder = new AppFolder();
|
||||
$folderId = $oFolder->createFromPath($aID['INP_DOC_DESTINATION_PATH'], $_POST['APPLICATION']);
|
||||
|
||||
//Tags
|
||||
$fileTags = $oFolder->parseTags($aID['INP_DOC_TAGS'], $_POST['APPLICATION']);
|
||||
}
|
||||
|
||||
$oAppDocument = new AppDocument();
|
||||
|
||||
if (isset($_POST['APP_DOC_UID']) && trim($_POST['APP_DOC_UID']) != '') {
|
||||
//Update
|
||||
echo '[update]';
|
||||
$aFields['APP_DOC_UID'] = $_POST['APP_DOC_UID'];
|
||||
$aFields['DOC_VERSION'] = $_POST['DOC_VERSION'];
|
||||
$aFields['APP_DOC_FILENAME'] = $_FILES['ATTACH_FILE']['name'];
|
||||
|
||||
if (isset($_POST['APPLICATION']))
|
||||
$aFields['APP_UID'] = $_POST['APPLICATION'];
|
||||
if (isset($_POST['INDEX']))
|
||||
$aFields['DEL_INDEX'] = $_POST['INDEX'];
|
||||
if (isset($_POST['USR_UID']))
|
||||
$aFields['USR_UID'] = $_POST['USR_UID'];
|
||||
if (isset($_POST['DOC_UID']))
|
||||
$aFields['DOC_UID'] = $_POST['DOC_UID'];
|
||||
if (isset($_POST['APP_DOC_TYPE']))
|
||||
$aFields['APP_DOC_TYPE']= $_POST['APP_DOC_TYPE'];
|
||||
|
||||
$aFields['APP_DOC_CREATE_DATE'] = date('Y-m-d H:i:s');
|
||||
$aFields['APP_DOC_COMMENT'] = isset($_POST['COMMENT'])? $_POST['COMMENT'] : '';
|
||||
$aFields['APP_DOC_TITLE'] = isset($_POST['TITLE'])? $_POST['TITLE'] : '';
|
||||
|
||||
//$aFields['FOLDER_UID'] = $folderId,
|
||||
//$aFields['APP_DOC_TAGS']= $fileTags
|
||||
}
|
||||
else {
|
||||
//New record
|
||||
$aFields = array(
|
||||
'APP_UID' => $_POST['APPLICATION'],
|
||||
'DEL_INDEX' => $_POST['INDEX'],
|
||||
'USR_UID' => $_POST['USR_UID'],
|
||||
'DOC_UID' => $_POST['DOC_UID'],
|
||||
'APP_DOC_TYPE' => $_POST['APP_DOC_TYPE'],
|
||||
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
|
||||
'APP_DOC_COMMENT' => isset($_POST['COMMENT'])? $_POST['COMMENT'] : '',
|
||||
'APP_DOC_TITLE' => isset($_POST['TITLE'])? $_POST['TITLE'] : '',
|
||||
'APP_DOC_FILENAME' => isset($_FILES['ATTACH_FILE']['name'])? $_FILES['ATTACH_FILE']['name'] : '',
|
||||
'FOLDER_UID' => $folderId,
|
||||
'APP_DOC_TAGS' => $fileTags
|
||||
);
|
||||
}
|
||||
|
||||
$oAppDocument->create($aFields);
|
||||
|
||||
$sAppUid = $oAppDocument->getAppUid();
|
||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
||||
$iDocVersion = $oAppDocument->getDocVersion();
|
||||
$info = pathinfo($oAppDocument->getAppDocFilename());
|
||||
$ext = isset($info['extension'])? $info['extension'] : '';
|
||||
|
||||
//Save the file
|
||||
echo $sPathName = PATH_DOCUMENT . $sAppUid . PATH_SEP;
|
||||
echo $sFileName = $sAppDocUid . '_' . $iDocVersion . '.' . $ext;
|
||||
print G::uploadFile($_FILES['ATTACH_FILE']['tmp_name'], $sPathName, $sFileName);
|
||||
print("* The file {$_FILES['ATTACH_FILE']['name']} was uploaded successfully in case {$sAppUid} as input document..\n");
|
||||
|
||||
//Get current Application Fields
|
||||
$application = new Application();
|
||||
$appFields = $application->Load($_POST['APPLICATION']);
|
||||
$appFields = unserialize($appFields['APP_DATA']);
|
||||
|
||||
$_SESSION['APPLICATION'] = $appFields['APPLICATION'];
|
||||
$_SESSION['PROCESS'] = $appFields['PROCESS'];
|
||||
$_SESSION['TASK'] = $appFields['TASK'];
|
||||
$_SESSION['INDEX'] = $appFields['INDEX'];
|
||||
$_SESSION['USER_LOGGED'] = $appFields['USER_LOGGED']; //$_POST['USR_UID']
|
||||
//$_SESSION['USR_USERNAME'] = $appFields['USR_USERNAME'];
|
||||
//$_SESSION['STEP_POSITION'] = 0;
|
||||
|
||||
//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($_POST["APPLICATION"], $_POST["USR_UID"], $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);
|
||||
}
|
||||
}
|
||||
//End plugin
|
||||
}
|
||||
catch (Exception $e) {
|
||||
print($e->getMessage());
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* class.wsBase.php
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2008 Colosa Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @Updated Dec 14, 2009 by Erik <erik@colosa.com>
|
||||
*
|
||||
* The point of this application is upload the file and create the input document record
|
||||
*
|
||||
* if the post attached file has error code 0 continue in other case nothing to do.
|
||||
*/
|
||||
|
||||
if (isset($_FILES) && $_FILES["ATTACH_FILE"]["error"] == 0) {
|
||||
try{
|
||||
G::LoadClass("case");
|
||||
|
||||
$folderId = "";
|
||||
$fileTags = "";
|
||||
|
||||
if (isset($_POST["DOC_UID"]) && $_POST["DOC_UID"] != -1) {
|
||||
//The document is of an Specific Input Document. Get path and Tag information
|
||||
require_once ("classes/model/AppFolder.php");
|
||||
require_once ("classes/model/InputDocument.php");
|
||||
|
||||
$oInputDocument = new InputDocument();
|
||||
$aID = $oInputDocument->load($_POST["DOC_UID"]);
|
||||
|
||||
//Get the Custom Folder ID (create if necessary)
|
||||
$oFolder = new AppFolder();
|
||||
$folderId = $oFolder->createFromPath($aID["INP_DOC_DESTINATION_PATH"], $_POST["APPLICATION"]);
|
||||
|
||||
//Tags
|
||||
$fileTags = $oFolder->parseTags($aID["INP_DOC_TAGS"], $_POST["APPLICATION"]);
|
||||
}
|
||||
|
||||
$oAppDocument = new AppDocument();
|
||||
|
||||
if (isset($_POST["APP_DOC_UID"]) && trim($_POST["APP_DOC_UID"]) != "") {
|
||||
//Update
|
||||
echo "[update]";
|
||||
$aFields["APP_DOC_UID"] = $_POST["APP_DOC_UID"];
|
||||
$aFields["DOC_VERSION"] = $_POST["DOC_VERSION"];
|
||||
$aFields["APP_DOC_FILENAME"] = $_FILES["ATTACH_FILE"]["name"];
|
||||
|
||||
if (isset($_POST["APPLICATION"])) {
|
||||
$aFields["APP_UID"] = $_POST["APPLICATION"];
|
||||
}
|
||||
|
||||
if (isset($_POST["INDEX"])) {
|
||||
$aFields["DEL_INDEX"] = $_POST["INDEX"];
|
||||
}
|
||||
|
||||
if (isset($_POST["USR_UID"])) {
|
||||
$aFields["USR_UID"] = $_POST["USR_UID"];
|
||||
}
|
||||
|
||||
if (isset($_POST["DOC_UID"])) {
|
||||
$aFields["DOC_UID"] = $_POST["DOC_UID"];
|
||||
}
|
||||
|
||||
if (isset($_POST["APP_DOC_TYPE"])) {
|
||||
$aFields["APP_DOC_TYPE"] = $_POST["APP_DOC_TYPE"];
|
||||
}
|
||||
|
||||
$aFields["APP_DOC_CREATE_DATE"] = date("Y-m-d H:i:s");
|
||||
$aFields["APP_DOC_COMMENT"] = (isset($_POST["COMMENT"]))? $_POST["COMMENT"] : "";
|
||||
$aFields["APP_DOC_TITLE"] = (isset($_POST["TITLE"]))? $_POST["TITLE"] : "";
|
||||
|
||||
//$aFields["FOLDER_UID"] = $folderId,
|
||||
//$aFields["APP_DOC_TAGS"] = $fileTags
|
||||
|
||||
$aFields["APP_DOC_FIELDNAME"] = $_POST["APP_DOC_FIELDNAME"];
|
||||
} else {
|
||||
//New record
|
||||
$aFields = array(
|
||||
"APP_UID" => $_POST["APPLICATION"],
|
||||
"DEL_INDEX" => $_POST["INDEX"],
|
||||
"USR_UID" => $_POST["USR_UID"],
|
||||
"DOC_UID" => $_POST["DOC_UID"],
|
||||
"APP_DOC_TYPE" => $_POST["APP_DOC_TYPE"],
|
||||
"APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"),
|
||||
"APP_DOC_COMMENT" => (isset($_POST["COMMENT"]))? $_POST["COMMENT"] : "",
|
||||
"APP_DOC_TITLE" => (isset($_POST["TITLE"]))? $_POST["TITLE"] : "",
|
||||
"APP_DOC_FILENAME" => (isset($_FILES["ATTACH_FILE"]["name"]))? $_FILES["ATTACH_FILE"]["name"] : "",
|
||||
"FOLDER_UID" => $folderId,
|
||||
"APP_DOC_TAGS" => $fileTags,
|
||||
"APP_DOC_FIELDNAME" => $_POST["APP_DOC_FIELDNAME"]
|
||||
);
|
||||
}
|
||||
|
||||
$oAppDocument->create($aFields);
|
||||
|
||||
$sAppUid = $oAppDocument->getAppUid();
|
||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
||||
$iDocVersion = $oAppDocument->getDocVersion();
|
||||
$info = pathinfo($oAppDocument->getAppDocFilename());
|
||||
$ext = (isset($info["extension"]))? $info["extension"] : "";
|
||||
|
||||
//Save the file
|
||||
echo $sPathName = PATH_DOCUMENT . $sAppUid . PATH_SEP;
|
||||
echo $sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $ext;
|
||||
print G::uploadFile($_FILES["ATTACH_FILE"]["tmp_name"], $sPathName, $sFileName);
|
||||
print("* The file " . $_FILES["ATTACH_FILE"]["name"] . " was uploaded successfully in case " . $sAppUid . " as input document..\n");
|
||||
|
||||
//Get current Application Fields
|
||||
$application = new Application();
|
||||
$appFields = $application->Load($_POST["APPLICATION"]);
|
||||
$appFields = unserialize($appFields["APP_DATA"]);
|
||||
|
||||
$_SESSION["APPLICATION"] = $appFields["APPLICATION"];
|
||||
$_SESSION["PROCESS"] = $appFields["PROCESS"];
|
||||
$_SESSION["TASK"] = $appFields["TASK"];
|
||||
$_SESSION["INDEX"] = $appFields["INDEX"];
|
||||
$_SESSION["USER_LOGGED"] = $appFields["USER_LOGGED"]; //$_POST["USR_UID"]
|
||||
//$_SESSION["USR_USERNAME"] = $appFields["USR_USERNAME"];
|
||||
//$_SESSION["STEP_POSITION"] = 0;
|
||||
|
||||
//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($_POST["APPLICATION"], $_POST["USR_UID"], $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);
|
||||
}
|
||||
}
|
||||
//End plugin
|
||||
} catch (Exception $e) {
|
||||
print($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user