@@ -3962,6 +3962,35 @@ class Cases
|
|||||||
];
|
];
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
|
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
|
||||||
|
$pluginRegistry = PluginRegistry::loadSingleton();
|
||||||
|
|
||||||
|
// If the hook exists try to execute
|
||||||
|
if ($pluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) {
|
||||||
|
// Get hook details
|
||||||
|
$triggerDetail = $pluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT);
|
||||||
|
|
||||||
|
// Build path file
|
||||||
|
$info = pathinfo($arrayFileName['name']);
|
||||||
|
$extension = (isset($info['extension'])) ? $info['extension'] : '';
|
||||||
|
$pathCase = G::getPathFromUID($appUid);
|
||||||
|
$pathFile = PATH_DOCUMENT . $pathCase . PATH_SEP . $objCreated->getAppDocUid() . '_1.' . $extension;
|
||||||
|
|
||||||
|
// Instance object used by the hook
|
||||||
|
$documentData = new uploadDocumentData($appUid, $userUid, $pathFile, $objCreated->getAppDocFilename(), $objCreated->getAppDocUid(), 1);
|
||||||
|
|
||||||
|
// Execute hook
|
||||||
|
$uploadReturn = $pluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
|
||||||
|
|
||||||
|
// If the executions is correct, update the record related to the document
|
||||||
|
if ($uploadReturn) {
|
||||||
|
Documents::where('APP_DOC_UID', $objCreated->getAppDocUid())->update(['APP_DOC_PLUGIN' => $triggerDetail->getNamespace()]);
|
||||||
|
|
||||||
|
// Remove the file from the server
|
||||||
|
unlink($pathFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new UploadException($arrayFileName['error']);
|
throw new UploadException($arrayFileName['error']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,9 @@ use ProcessMaker\ChangeLog\ChangeLog;
|
|||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
use ProcessMaker\Core\RoutingScreen;
|
use ProcessMaker\Core\RoutingScreen;
|
||||||
use ProcessMaker\Core\System;
|
use ProcessMaker\Core\System;
|
||||||
|
use ProcessMaker\Model\Documents;
|
||||||
use ProcessMaker\Model\Process as ProcessEloquent;
|
use ProcessMaker\Model\Process as ProcessEloquent;
|
||||||
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
use ProcessMaker\Services\Api\Project\Activity\Step as ActivityStep;
|
use ProcessMaker\Services\Api\Project\Activity\Step as ActivityStep;
|
||||||
use ProcessMaker\Util\DateTime;
|
use ProcessMaker\Util\DateTime;
|
||||||
use ProcessMaker\Validation\ExceptionRestApi;
|
use ProcessMaker\Validation\ExceptionRestApi;
|
||||||
@@ -42,6 +44,7 @@ use RBAC;
|
|||||||
use ResultSet;
|
use ResultSet;
|
||||||
use StepPeer;
|
use StepPeer;
|
||||||
use TaskPeer;
|
use TaskPeer;
|
||||||
|
use uploadDocumentData;
|
||||||
use Users;
|
use Users;
|
||||||
use UsersPeer;
|
use UsersPeer;
|
||||||
|
|
||||||
@@ -1186,8 +1189,32 @@ class Light
|
|||||||
$pathUID = G::getPathFromUID($app_uid);
|
$pathUID = G::getPathFromUID($app_uid);
|
||||||
$sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP;
|
$sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP;
|
||||||
$sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension;
|
$sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension;
|
||||||
|
$pathFile = $sPathName . $sFileName;
|
||||||
G::uploadFile($arrayFileTmpName[$i], $sPathName, $sFileName);
|
G::uploadFile($arrayFileTmpName[$i], $sPathName, $sFileName);
|
||||||
$response = array("status" => "ok");
|
$response = array("status" => "ok");
|
||||||
|
|
||||||
|
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
|
||||||
|
$pluginRegistry = PluginRegistry::loadSingleton();
|
||||||
|
|
||||||
|
// If the hook exists try to execute
|
||||||
|
if ($pluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) {
|
||||||
|
// Get hook details
|
||||||
|
$triggerDetail = $pluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT);
|
||||||
|
|
||||||
|
// Instance object used by the hook
|
||||||
|
$documentData = new uploadDocumentData($app_uid, $userUid, $pathFile, $oAppDocument->getAppDocFilename(), $app_doc_uid, $iDocVersion);
|
||||||
|
|
||||||
|
// Execute hook
|
||||||
|
$uploadReturn = $pluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
|
||||||
|
|
||||||
|
// If the executions is correct, update the record related to the document
|
||||||
|
if ($uploadReturn) {
|
||||||
|
Documents::where('APP_DOC_UID', $app_doc_uid)->update(['APP_DOC_PLUGIN' => $triggerDetail->getNamespace()]);
|
||||||
|
|
||||||
|
// Remove the file from the server
|
||||||
|
unlink($pathFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user