HOR-3790
This commit is contained in:
BIN
storage/framework/cache/data/29/e4/29e4f084ccb51763d469bca5be6c8476527998af
vendored
Normal file
BIN
storage/framework/cache/data/29/e4/29e4f084ccb51763d469bca5be6c8476527998af
vendored
Normal file
Binary file not shown.
BIN
storage/framework/cache/data/2f/6e/2f6e25936f9a73f9e792ef8ffbab40c31a632160
vendored
Normal file
BIN
storage/framework/cache/data/2f/6e/2f6e25936f9a73f9e792ef8ffbab40c31a632160
vendored
Normal file
Binary file not shown.
@@ -1,38 +1,12 @@
|
|||||||
<?php
|
<?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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use ProcessMaker\Plugins\PluginRegistry;
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Updated Dec 14, 2009 by Erik <erik@colosa.com>
|
|
||||||
*
|
|
||||||
* The point of this application is upload the file and create the input document record
|
* 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 the post attached file has error code 0 continue in other case nothing to do.
|
||||||
*/
|
*/
|
||||||
|
if (isset($_FILES) && $_FILES["ATTACH_FILE"]["error"] == 0) {
|
||||||
if (isset( $_FILES ) && $_FILES["ATTACH_FILE"]["error"] == 0) {
|
|
||||||
try {
|
try {
|
||||||
$application = new Application();
|
$application = new Application();
|
||||||
if (!$application->exists($_POST["APPLICATION"])) {
|
if (!$application->exists($_POST["APPLICATION"])) {
|
||||||
@@ -42,23 +16,23 @@ if (isset( $_FILES ) && $_FILES["ATTACH_FILE"]["error"] == 0) {
|
|||||||
$folderId = "";
|
$folderId = "";
|
||||||
$fileTags = "";
|
$fileTags = "";
|
||||||
|
|
||||||
if (isset( $_POST["DOC_UID"] ) && $_POST["DOC_UID"] != - 1) {
|
if (isset($_POST["DOC_UID"]) && $_POST["DOC_UID"] != - 1) {
|
||||||
//The document is of an Specific Input Document. Get path and Tag information
|
//The document is of an Specific Input Document. Get path and Tag information
|
||||||
require_once ("classes/model/AppFolder.php");
|
require_once("classes/model/AppFolder.php");
|
||||||
require_once ("classes/model/InputDocument.php");
|
require_once("classes/model/InputDocument.php");
|
||||||
|
|
||||||
$oInputDocument = new InputDocument();
|
$oInputDocument = new InputDocument();
|
||||||
$aID = $oInputDocument->load( $_POST["DOC_UID"] );
|
$aID = $oInputDocument->load($_POST["DOC_UID"]);
|
||||||
|
|
||||||
//Get the Custom Folder ID (create if necessary)
|
//Get the Custom Folder ID (create if necessary)
|
||||||
$oFolder = new AppFolder();
|
$oFolder = new AppFolder();
|
||||||
$folderId = $oFolder->createFromPath( $aID["INP_DOC_DESTINATION_PATH"], $_POST["APPLICATION"] );
|
$folderId = $oFolder->createFromPath($aID["INP_DOC_DESTINATION_PATH"], $_POST["APPLICATION"]);
|
||||||
|
|
||||||
//Tags
|
//Tags
|
||||||
$fileTags = $oFolder->parseTags( $aID["INP_DOC_TAGS"], $_POST["APPLICATION"] );
|
$fileTags = $oFolder->parseTags($aID["INP_DOC_TAGS"], $_POST["APPLICATION"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$oAppDocument = new AppDocument();
|
$appDocument = new AppDocument();
|
||||||
|
|
||||||
if (isset($_POST["APP_DOC_UID"]) && trim($_POST["APP_DOC_UID"]) != "") {
|
if (isset($_POST["APP_DOC_UID"]) && trim($_POST["APP_DOC_UID"]) != "") {
|
||||||
//Update
|
//Update
|
||||||
@@ -112,70 +86,62 @@ if (isset( $_FILES ) && $_FILES["ATTACH_FILE"]["error"] == 0) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$oAppDocument->create( $aFields );
|
$appDocument->create($aFields);
|
||||||
|
|
||||||
$sAppUid = $oAppDocument->getAppUid();
|
$sAppUid = $appDocument->getAppUid();
|
||||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
$sAppDocUid = $appDocument->getAppDocUid();
|
||||||
$iDocVersion = $oAppDocument->getDocVersion();
|
$iDocVersion = $appDocument->getDocVersion();
|
||||||
$info = pathinfo( $oAppDocument->getAppDocFilename() );
|
$info = pathinfo($appDocument->getAppDocFilename());
|
||||||
$ext = (isset( $info["extension"] )) ? $info["extension"] : "";
|
$ext = (isset($info["extension"])) ? $info["extension"] : "";
|
||||||
|
|
||||||
//Save the file
|
//Save the file
|
||||||
echo $sPathName = PATH_DOCUMENT . G::getPathFromUID($sAppUid) . PATH_SEP;
|
echo $sPathName = PATH_DOCUMENT . G::getPathFromUID($sAppUid) . PATH_SEP;
|
||||||
echo $sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $ext;
|
echo $sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $ext;
|
||||||
print G::uploadFile( $_FILES["ATTACH_FILE"]["tmp_name"], $sPathName, $sFileName );
|
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") ;
|
print("* The file " . $_FILES["ATTACH_FILE"]["name"] . " was uploaded successfully in case " . $sAppUid . " as input document..\n");
|
||||||
|
|
||||||
//set variable for APP_DOC_UID
|
//set variable for APP_DOC_UID
|
||||||
$appUid = $_POST['APPLICATION'];
|
$appUid = $_POST['APPLICATION'];
|
||||||
$oCase = new Cases();
|
$case = new Cases();
|
||||||
$fields = $oCase->loadCase($appUid);
|
$fields = $case->loadCase($appUid);
|
||||||
$fields['APP_DATA'][$oAppDocument->getAppDocFieldname()] = G::json_encode([$oAppDocument->getAppDocUid()]);
|
$fields['APP_DATA'][$appDocument->getAppDocFieldname()] = G::json_encode([$appDocument->getAppDocUid()]);
|
||||||
$fields['APP_DATA'][$oAppDocument->getAppDocFieldname() . '_label'] = G::json_encode([$oAppDocument->getAppDocFilename()]);
|
$fields['APP_DATA'][$appDocument->getAppDocFieldname() . '_label'] = G::json_encode([$appDocument->getAppDocFilename()]);
|
||||||
$oCase->updateCase($appUid, $fields);
|
$case->updateCase($appUid, $fields);
|
||||||
|
|
||||||
//Get current Application Fields
|
|
||||||
$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;
|
|
||||||
|
|
||||||
|
$_SESSION["APPLICATION"] = $fields['APP_DATA']["APPLICATION"];
|
||||||
|
$_SESSION["PROCESS"] = $fields['APP_DATA']["PROCESS"];
|
||||||
|
$_SESSION["TASK"] = $fields['APP_DATA']["TASK"];
|
||||||
|
$_SESSION["INDEX"] = $fields['APP_DATA']["INDEX"];
|
||||||
|
$_SESSION["USER_LOGGED"] = $fields['APP_DATA']["USER_LOGGED"];
|
||||||
|
|
||||||
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
|
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
|
||||||
$oPluginRegistry = PluginRegistry::loadSingleton();
|
$oPluginRegistry = PluginRegistry::loadSingleton();
|
||||||
|
|
||||||
if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( "uploadDocumentData" )) {
|
if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists("uploadDocumentData")) {
|
||||||
$triggerDetail = $oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT );
|
$triggerDetail = $oPluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT);
|
||||||
$documentData = new uploadDocumentData( $_POST["APPLICATION"], $_POST["USR_UID"], $sPathName . $sFileName, $aFields["APP_DOC_FILENAME"], $sAppDocUid, $iDocVersion );
|
$documentData = new uploadDocumentData($_POST["APPLICATION"], $_POST["USR_UID"], $sPathName . $sFileName, $aFields["APP_DOC_FILENAME"], $sAppDocUid, $iDocVersion);
|
||||||
$uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
|
$uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
|
||||||
|
|
||||||
if ($uploadReturn) {
|
if ($uploadReturn) {
|
||||||
$aFields["APP_DOC_PLUGIN"] = $triggerDetail->getNamespace();
|
$aFields["APP_DOC_PLUGIN"] = $triggerDetail->getNamespace();
|
||||||
|
|
||||||
if (! isset( $aFields["APP_DOC_UID"] )) {
|
if (!isset($aFields["APP_DOC_UID"])) {
|
||||||
$aFields["APP_DOC_UID"] = $sAppDocUid;
|
$aFields["APP_DOC_UID"] = $sAppDocUid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset( $aFields["DOC_VERSION"] )) {
|
if (!isset($aFields["DOC_VERSION"])) {
|
||||||
$aFields["DOC_VERSION"] = $iDocVersion;
|
$aFields["DOC_VERSION"] = $iDocVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
$oAppDocument->update( $aFields );
|
$appDocument->update($aFields);
|
||||||
|
|
||||||
unlink( $sPathName . $sFileName );
|
unlink($sPathName . $sFileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//End plugin
|
//End plugin
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$token = strtotime("now");
|
$token = strtotime("now");
|
||||||
PMException::registerErrorLog($e, $token);
|
PMException::registerErrorLog($e, $token);
|
||||||
G::outRes( G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)) );
|
G::outRes(G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user