PMCORE-4133
This commit is contained in:
@@ -3730,6 +3730,7 @@ class Cases
|
||||
if ($folderitem->filename == $aRow['APP_DOC_UID']) {
|
||||
$aFields['DOWNLOAD_LABEL'] = G::LoadTranslation('ID_GET_EXTERNAL_FILE');
|
||||
$aFields['DOWNLOAD_LINK'] = $folderitem->downloadScript;
|
||||
unset($aFields['NEWVERSION_LABEL'], $aFields['VERSIONHISTORY_LABEL']);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -3997,7 +3998,7 @@ class Cases
|
||||
$uploadReturn = $pluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
|
||||
|
||||
if ($uploadReturn) {
|
||||
$arrayField["APP_DOC_PLUGIN"] = $triggerDetail->sNamespace;
|
||||
$arrayField["APP_DOC_PLUGIN"] = $triggerDetail->getNamespace();
|
||||
|
||||
if (!isset($arrayField["APP_DOC_UID"])) {
|
||||
$arrayField["APP_DOC_UID"] = $appDocUid;
|
||||
|
||||
@@ -6,7 +6,9 @@ use ProcessMaker\Core\System;
|
||||
use ProcessMaker\BusinessModel\DynaForm\SuggestTrait;
|
||||
use ProcessMaker\BusinessModel\Cases;
|
||||
use ProcessMaker\BusinessModel\DynaForm\ValidatorFactory;
|
||||
use ProcessMaker\Model\Documents;
|
||||
use ProcessMaker\Model\Dynaform as ModelDynaform;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
|
||||
/**
|
||||
* Implementing pmDynaform library in the running case.
|
||||
@@ -25,6 +27,7 @@ class PmDynaform
|
||||
private $propertiesToExclude = [];
|
||||
private $sysSys = null;
|
||||
private $fieldsAppData;
|
||||
private $filesFromPlugin = [Documents::DOC_TYPE_ATTACHED => null, Documents::DOC_TYPE_INPUT => null];
|
||||
public $credentials = null;
|
||||
public $displayMode = null;
|
||||
public $fields = null;
|
||||
@@ -567,6 +570,7 @@ class PmDynaform
|
||||
$oCriteriaAppDocument = new Criteria("workflow");
|
||||
$oCriteriaAppDocument->addSelectColumn(AppDocumentPeer::APP_DOC_UID);
|
||||
$oCriteriaAppDocument->addSelectColumn(AppDocumentPeer::DOC_VERSION);
|
||||
$oCriteriaAppDocument->addSelectColumn(AppDocumentPeer::APP_DOC_TYPE);
|
||||
$oCriteriaAppDocument->add(AppDocumentPeer::APP_UID, $this->fields["APP_DATA"]["APPLICATION"]);
|
||||
$oCriteriaAppDocument->add(AppDocumentPeer::APP_DOC_FIELDNAME, $json->name);
|
||||
$oCriteriaAppDocument->add(AppDocumentPeer::APP_DOC_STATUS, 'ACTIVE');
|
||||
@@ -582,8 +586,44 @@ class PmDynaform
|
||||
$oAppDocument = new AppDocument();
|
||||
|
||||
if ($row = $rs->getRow()) {
|
||||
// Only get the information from the plugin once
|
||||
if (is_null($this->filesFromPlugin[$row['APP_DOC_TYPE']])) {
|
||||
// Plugin Hook PM_CASE_DOCUMENT_LIST to get the files uploaded as attachments
|
||||
$pluginRegistry = PluginRegistry::loadSingleton();
|
||||
|
||||
// If the hook exists try to execute
|
||||
if ($pluginRegistry->existsTrigger(PM_CASE_DOCUMENT_LIST) && class_exists('folderData')) {
|
||||
// Build the required object
|
||||
$folderData = new folderData(null, null, $this->fields['APP_DATA']['APPLICATION'], null, null);
|
||||
$folderData->PMType = $row['APP_DOC_TYPE'];
|
||||
$folderData->returnList = true;
|
||||
|
||||
// Get elements
|
||||
$this->filesFromPlugin[$row['APP_DOC_TYPE']] = $pluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData);
|
||||
} else {
|
||||
// If not exist, set an empty array
|
||||
$this->filesFromPlugin[$row['APP_DOC_TYPE']] = [];
|
||||
}
|
||||
}
|
||||
// Load document data
|
||||
$oAppDocument->load($row["APP_DOC_UID"], $row["DOC_VERSION"]);
|
||||
$links[] = "../cases/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"];
|
||||
|
||||
// Build the default link
|
||||
$link = "../cases/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"];
|
||||
|
||||
// If exist related file in the plugin, check if the file is the same
|
||||
if (is_array($this->filesFromPlugin[$row['APP_DOC_TYPE']])) {
|
||||
foreach ($this->filesFromPlugin[$row['APP_DOC_TYPE']] as $file) {
|
||||
// If exists the same file, replace the download link
|
||||
if ($file->filename === $row['APP_DOC_UID']) {
|
||||
$link = $file->downloadScript;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the link and another related information
|
||||
$links[] = $link;
|
||||
$labelsFromDb[] = $oAppDocument->getAppDocFilename();
|
||||
$appDocUids[] = $row["APP_DOC_UID"];
|
||||
}
|
||||
|
||||
@@ -670,25 +670,25 @@ class AppFolder extends BaseAppFolder
|
||||
|
||||
switch ($row4['OUT_DOC_GENERATE']) {
|
||||
case "PDF":
|
||||
$downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand();
|
||||
$downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand() . "&p=1";
|
||||
$downloadLink1 = "";
|
||||
$downloadLabel = ".pdf";
|
||||
$downloadLabel1 = "";
|
||||
break;
|
||||
case "DOC":
|
||||
$downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand();
|
||||
$downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand() . "&p=1";
|
||||
$downloadLink1 = "";
|
||||
$downloadLabel = ".doc";
|
||||
$downloadLabel1 = "";
|
||||
break;
|
||||
case "BOTH":
|
||||
$downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand();
|
||||
$downloadLink1 = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand();
|
||||
$downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand() . "&p=1";
|
||||
$downloadLink1 = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand() . "&p=1";
|
||||
$downloadLabel = ".pdf";
|
||||
$downloadLabel1 = ".doc";
|
||||
break;
|
||||
case "NOFILE":
|
||||
$downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion;
|
||||
$downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion . "&p=1";
|
||||
$downloadLink1 = "";
|
||||
$downloadLabel = G::LoadTranslation("ID_DOWNLOAD");
|
||||
$downloadLabel1 = "";
|
||||
@@ -709,56 +709,23 @@ class AppFolder extends BaseAppFolder
|
||||
$row4 = array ();
|
||||
$versioningEnabled = false;
|
||||
}
|
||||
$downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion;
|
||||
$downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion . "&p=1";
|
||||
$downloadLink1 = "";
|
||||
$downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' );
|
||||
$downloadLabel1 = "";
|
||||
} else {
|
||||
$row4 = array ();
|
||||
$versioningEnabled = false;
|
||||
$downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion;
|
||||
$downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion . "&p=1";
|
||||
$downloadLink1 = "";
|
||||
$downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' );
|
||||
$downloadLabel1 = "";
|
||||
}
|
||||
|
||||
if (! empty( $row1["APP_DOC_PLUGIN"] )) {
|
||||
$pluginRegistry = PluginRegistry::loadSingleton();
|
||||
$pluginName = $row1["APP_DOC_PLUGIN"];
|
||||
$fieldValue = "";
|
||||
|
||||
if (file_exists( PATH_PLUGINS . $pluginName . ".php" )) {
|
||||
$pluginDetail = $pluginRegistry->getPluginDetails( $pluginName . ".php" );
|
||||
|
||||
if ($pluginDetail) {
|
||||
if ($pluginDetail->isEnabled()) {
|
||||
require_once (PATH_PLUGINS . $pluginName . ".php");
|
||||
$pluginNameClass = $pluginName . "Plugin";
|
||||
$objPluginClass = new $pluginNameClass( $pluginName );
|
||||
|
||||
if (isset( $objPluginClass->sMethodGetUrlDownload ) && ! empty( $objPluginClass->sMethodGetUrlDownload )) {
|
||||
if (file_exists( PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php" )) {
|
||||
require_once (PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php");
|
||||
$pluginNameClass = $pluginName . "Class";
|
||||
$objClass = new $pluginNameClass();
|
||||
|
||||
if (method_exists( $objClass, $objPluginClass->sMethodGetUrlDownload )) {
|
||||
eval( "\$url = \$objClass->" . $objPluginClass->sMethodGetUrlDownload . "(\"" . $row1["APP_DOC_UID"] . "\");" );
|
||||
$downloadLink = $url;
|
||||
$fieldValue = $row1["APP_DOC_PLUGIN"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$row1["APP_DOC_PLUGIN"] = $fieldValue;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$row4 = array ();
|
||||
$versioningEnabled = false;
|
||||
$downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion;
|
||||
$downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion . "&p=1";
|
||||
$downloadLink1 = "";
|
||||
$downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' );
|
||||
$downloadLabel1 = "";
|
||||
|
||||
@@ -227,7 +227,7 @@ class AppNotes extends BaseAppNotes
|
||||
|
||||
// Get the files related to the specific case note
|
||||
if ($noteId !== 0) {
|
||||
$attachFileLinks = $this->getAttachedFilesFromTheCaseNote($noteId);
|
||||
$attachFileLinks = $this->getAttachedFilesFromTheCaseNote($noteId, $appUid);
|
||||
}
|
||||
|
||||
if (!empty($attachFileLinks)) {
|
||||
@@ -282,15 +282,16 @@ class AppNotes extends BaseAppNotes
|
||||
/**
|
||||
* Get attached files from a specific case note
|
||||
* @param int $docId
|
||||
* @param string $appUid
|
||||
* @return array
|
||||
*/
|
||||
public function getAttachedFilesFromTheCaseNote(int $docId): array
|
||||
public function getAttachedFilesFromTheCaseNote(int $docId, string $appUid): array
|
||||
{
|
||||
$attachFileLinks = [];
|
||||
$url = System::getServerMainPath();
|
||||
$result = Documents::getFiles($docId);
|
||||
$result = Documents::getFiles($docId, $appUid);
|
||||
foreach ($result as $item) {
|
||||
$href = $url . "/cases/casesShowCaseNotes?a={$item['APP_DOC_UID']}&v={$item['DOC_VERSION']}";
|
||||
$href = $url . str_replace('../', '/', $item['LINK']);
|
||||
$attachFileLinks[] = "<a href='{$href}'>{$item['APP_DOC_FILENAME']}</a>";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user