PM-3132 "Designer > BPMN Designer: Al aplicar el..." SOLVED
Issue:
Designer > BPMN Designer: Al aplicar el hotfix 3.0.0.7 los templates de Action By Email no se pueden editar en
los procesos antiguos
Cause:
En algunos procesos los files de action-by-email no tienen su registro en la base de datos
Solution:
Se crea el metodo que registra los files faltantes en la base de datos, esto con las siguientes acciones:
- Al ejecutar el comando "upgrade"
- Al importar un proceso
This commit is contained in:
@@ -111,70 +111,18 @@ class workspaceTools
|
|||||||
$final = $stop - $start;
|
$final = $stop - $start;
|
||||||
CLI::logging("<*> Backup log files Process took $final seconds.\n");
|
CLI::logging("<*> Backup log files Process took $final seconds.\n");
|
||||||
|
|
||||||
CLI::logging("> Updating Files Manager...\n\n");
|
|
||||||
$this->upgradeFilesManager($workSpace);
|
|
||||||
|
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
CLI::logging("> Migrate new lists...\n");
|
CLI::logging("> Migrate new lists...\n");
|
||||||
$this->migrateList($workSpace);
|
$this->migrateList($workSpace);
|
||||||
$stop = microtime(true);
|
$stop = microtime(true);
|
||||||
$final = $stop - $start;
|
$final = $stop - $start;
|
||||||
CLI::logging("<*> Migrate new lists Process took $final seconds.\n");
|
CLI::logging("<*> Migrate new lists Process took $final seconds.\n");
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
$start = microtime(true);
|
||||||
* Function upgradeFilesManager
|
CLI::logging("> Updating Files Manager...\n");
|
||||||
* access public
|
$this->processFilesUpgrade();
|
||||||
*/
|
$stop = microtime(true);
|
||||||
public function upgradeFilesManager($workSpace) {
|
CLI::logging("<*> Updating Files Manager took " . ($stop - $start) . " seconds.\n");
|
||||||
$this->initPropel(true);
|
|
||||||
$con = Propel::getConnection("root");
|
|
||||||
$stmt = $con->createStatement();
|
|
||||||
$sDirectory = glob(PATH_DATA . "sites/" . $workSpace . "/" . "mailTemplates/*");
|
|
||||||
$sDirectoryPublic = glob(PATH_DATA . "sites/" . $workSpace . "/" . "public/*");
|
|
||||||
$files = array();
|
|
||||||
foreach($sDirectory as $mailTemplate) {
|
|
||||||
if (is_dir($mailTemplate)) {
|
|
||||||
$inner_files = listFiles($mailTemplate);
|
|
||||||
if (is_array($inner_files)) $files = array_merge($files, $inner_files);
|
|
||||||
}
|
|
||||||
if (is_file($mailTemplate)) {
|
|
||||||
array_push($files, $mailTemplate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach($sDirectoryPublic as $publicFile) {
|
|
||||||
if (is_dir($publicFile)) {
|
|
||||||
$inner_files = listFiles($publicFile);
|
|
||||||
if (is_array($inner_files)) $files = array_merge($files, $inner_files);
|
|
||||||
}
|
|
||||||
if (is_file($publicFile)) {
|
|
||||||
array_push($files, $publicFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$sDir = PATH_DATA . "sites/" . $workSpace . "/" . "mailTemplates/";
|
|
||||||
$sDirPublic = PATH_DATA . "sites/" . $workSpace . "/" . "public/";
|
|
||||||
foreach ($files as $aFile) {
|
|
||||||
if (strpos($aFile, $sDir) !== false){
|
|
||||||
$processUid = current(explode("/", str_replace($sDir,'',$aFile)));
|
|
||||||
} else {
|
|
||||||
$processUid = current(explode("/", str_replace($sDirPublic,'',$aFile)));
|
|
||||||
}
|
|
||||||
$sql = "SELECT PROCESS_FILES.PRF_PATH FROM PROCESS_FILES WHERE PROCESS_FILES.PRF_PATH='" . $aFile ."'";
|
|
||||||
$appRows = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
|
||||||
$fileUid = '';
|
|
||||||
foreach ($appRows as $row) {
|
|
||||||
$fileUid = $row["PRF_PATH"];
|
|
||||||
}
|
|
||||||
if ($fileUid !== $aFile) {
|
|
||||||
$sPkProcessFiles = G::generateUniqueID();
|
|
||||||
$sDate = date('Y-m-d H:i:s');
|
|
||||||
$sql = "INSERT INTO PROCESS_FILES (PRF_UID, PRO_UID, USR_UID, PRF_UPDATE_USR_UID,
|
|
||||||
PRF_PATH, PRF_TYPE, PRF_EDITABLE, PRF_CREATE_DATE, PRF_UPDATE_DATE)
|
|
||||||
VALUES ('".$sPkProcessFiles."', '".$processUid."', '00000000000000000000000000000001', '',
|
|
||||||
'".$aFile."', 'file', 'true', '".$sDate."', NULL)";
|
|
||||||
$stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1564,10 +1512,10 @@ class workspaceTools
|
|||||||
$version = explode('-', $version);
|
$version = explode('-', $version);
|
||||||
$versionPresent = ( isset($version[0])) ? $version[0] : '';
|
$versionPresent = ( isset($version[0])) ? $version[0] : '';
|
||||||
CLI::logging(CLI::warning("
|
CLI::logging(CLI::warning("
|
||||||
Warning: A workspace from a newer version of ProcessMaker can NOT be restored in an older version of
|
Warning: A workspace from a newer version of ProcessMaker can NOT be restored in an older version of
|
||||||
ProcessMaker. For example, restoring from v.3.0 to v.2.5 will not work. However, it may be possible
|
ProcessMaker. For example, restoring from v.3.0 to v.2.5 will not work. However, it may be possible
|
||||||
to restore a workspace from an older version to an newer version of ProcessMaker, although error
|
to restore a workspace from an older version to an newer version of ProcessMaker, although error
|
||||||
messages may be displayed during the restore process. Make sure to run the \"processmaker cacheview-repair\"
|
messages may be displayed during the restore process. Make sure to run the \"processmaker cacheview-repair\"
|
||||||
and \"processmaker migrate-new-cases-lists\" commands after restoring a workspace.") . "\n");
|
and \"processmaker migrate-new-cases-lists\" commands after restoring a workspace.") . "\n");
|
||||||
|
|
||||||
foreach ($metaFiles as $metaFile) {
|
foreach ($metaFiles as $metaFile) {
|
||||||
@@ -2226,5 +2174,31 @@ class workspaceTools
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process-Files upgrade
|
||||||
|
*
|
||||||
|
* return void
|
||||||
|
*/
|
||||||
|
public function processFilesUpgrade()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (!defined("PATH_DATA_MAILTEMPLATES")) {
|
||||||
|
define("PATH_DATA_MAILTEMPLATES", PATH_DATA_SITE . "mailTemplates" . PATH_SEP);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!defined("PATH_DATA_PUBLIC")) {
|
||||||
|
define("PATH_DATA_PUBLIC", PATH_DATA_SITE . "public" . PATH_SEP);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->initPropel(true);
|
||||||
|
|
||||||
|
$filesManager = new \ProcessMaker\BusinessModel\FilesManager();
|
||||||
|
|
||||||
|
$filesManager->processFilesUpgrade();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ class FilesManager
|
|||||||
$directory = $sMainDirectory. PATH_SEP . $sSubDirectory . $aData['prf_filename'];
|
$directory = $sMainDirectory. PATH_SEP . $sSubDirectory . $aData['prf_filename'];
|
||||||
throw new \Exception(\G::LoadTranslation("ID_EXISTS_FILE", array($directory)));
|
throw new \Exception(\G::LoadTranslation("ID_EXISTS_FILE", array($directory)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($sCheckDirectory)) {
|
if (!file_exists($sCheckDirectory)) {
|
||||||
$sPkProcessFiles = \G::generateUniqueID();
|
$sPkProcessFiles = \G::generateUniqueID();
|
||||||
$oProcessFiles = new \ProcessFiles();
|
$oProcessFiles = new \ProcessFiles();
|
||||||
@@ -242,31 +242,31 @@ class FilesManager
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addProcessFilesManagerInDb($aData)
|
public function addProcessFilesManagerInDb($aData)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$oProcessFiles = new \ProcessFiles();
|
$oProcessFiles = new \ProcessFiles();
|
||||||
$aData = array_change_key_case($aData, CASE_UPPER);
|
$aData = array_change_key_case($aData, CASE_UPPER);
|
||||||
$oProcessFiles->fromArray($aData, \BasePeer::TYPE_FIELDNAME);
|
$oProcessFiles->fromArray($aData, \BasePeer::TYPE_FIELDNAME);
|
||||||
|
|
||||||
if($this->existsProcessFile($aData['PRF_UID'])) {
|
if($this->existsProcessFile($aData['PRF_UID'])) {
|
||||||
$sPkProcessFiles = \G::generateUniqueID();
|
$sPkProcessFiles = \G::generateUniqueID();
|
||||||
$oProcessFiles->setPrfUid($sPkProcessFiles);
|
$oProcessFiles->setPrfUid($sPkProcessFiles);
|
||||||
|
|
||||||
$sDirectory = PATH_DATA_MAILTEMPLATES . $aData['PRO_UID'] . PATH_SEP . basename($aData['PRF_PATH']);
|
$sDirectory = PATH_DATA_MAILTEMPLATES . $aData['PRO_UID'] . PATH_SEP . basename($aData['PRF_PATH']);
|
||||||
$oProcessFiles->setPrfPath($sDirectory);
|
$oProcessFiles->setPrfPath($sDirectory);
|
||||||
|
|
||||||
$emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
|
$emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
|
||||||
$emailEvent->updatePrfUid($aData['PRF_UID'], $sPkProcessFiles, $aData['PRO_UID']);
|
$emailEvent->updatePrfUid($aData['PRF_UID'], $sPkProcessFiles, $aData['PRO_UID']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $oProcessFiles->save();
|
$result = $oProcessFiles->save();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function existsProcessFile($prfUid)
|
public function existsProcessFile($prfUid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -462,10 +462,10 @@ class FilesManager
|
|||||||
if ($path == '') {
|
if ($path == '') {
|
||||||
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('prf_uid')));
|
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('prf_uid')));
|
||||||
}
|
}
|
||||||
|
|
||||||
$sFile = end(explode("/",$path));
|
$sFile = end(explode("/",$path));
|
||||||
$path = PATH_DATA_MAILTEMPLATES.$sProcessUID.DIRECTORY_SEPARATOR.$sFile;
|
$path = PATH_DATA_MAILTEMPLATES.$sProcessUID.DIRECTORY_SEPARATOR.$sFile;
|
||||||
|
|
||||||
if (file_exists($path) && !is_dir($path)) {
|
if (file_exists($path) && !is_dir($path)) {
|
||||||
unlink($path);
|
unlink($path);
|
||||||
}
|
}
|
||||||
@@ -601,4 +601,115 @@ class FilesManager
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process-Files upgrade
|
||||||
|
*
|
||||||
|
* @param string $projectUid Unique id of Project
|
||||||
|
*
|
||||||
|
* return void
|
||||||
|
*/
|
||||||
|
public function processFilesUpgrade($projectUid = "")
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
//Set variables
|
||||||
|
$conf = new \Configuration();
|
||||||
|
|
||||||
|
//Create/Get PROCESS_FILES_CHECKED
|
||||||
|
$arrayProjectUid = array();
|
||||||
|
|
||||||
|
$configuration = \ConfigurationPeer::retrieveByPK("PROCESS_FILES_CHECKED", "", "", "", "");
|
||||||
|
|
||||||
|
if (is_null($configuration)) {
|
||||||
|
$result = $conf->create(array(
|
||||||
|
"CFG_UID" => "PROCESS_FILES_CHECKED",
|
||||||
|
"OBJ_UID" => "",
|
||||||
|
"CFG_VALUE" => serialize($arrayProjectUid),
|
||||||
|
"PRO_UID" => "",
|
||||||
|
"USR_UID" => "",
|
||||||
|
"APP_UID" => ""
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
$arrayProjectUid = unserialize($configuration->getCfgValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
//Set variables
|
||||||
|
$arrayPath = array("templates" => PATH_DATA_MAILTEMPLATES, "public" => PATH_DATA_PUBLIC);
|
||||||
|
$flagProjectUid = false;
|
||||||
|
|
||||||
|
//Query
|
||||||
|
$criteria = new \Criteria("workflow");
|
||||||
|
|
||||||
|
$criteria->addSelectColumn(\BpmnProjectPeer::PRJ_UID);
|
||||||
|
|
||||||
|
if ($projectUid != "") {
|
||||||
|
$criteria->add(
|
||||||
|
$criteria->getNewCriterion(\BpmnProjectPeer::PRJ_UID, $arrayProjectUid, \Criteria::NOT_IN)->addAnd(
|
||||||
|
$criteria->getNewCriterion(\BpmnProjectPeer::PRJ_UID, $projectUid, \Criteria::EQUAL))
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$criteria->add(\BpmnProjectPeer::PRJ_UID, $arrayProjectUid, \Criteria::NOT_IN);
|
||||||
|
}
|
||||||
|
|
||||||
|
$rsCriteria = \BpmnProjectPeer::doSelectRS($criteria);
|
||||||
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
|
while ($rsCriteria->next()) {
|
||||||
|
$row = $rsCriteria->getRow();
|
||||||
|
|
||||||
|
foreach ($arrayPath as $key => $value) {
|
||||||
|
$path = $key;
|
||||||
|
$dir = $value . $row["PRJ_UID"];
|
||||||
|
|
||||||
|
if (is_dir($dir)) {
|
||||||
|
if ($dirh = opendir($dir)) {
|
||||||
|
while (($file = readdir($dirh)) !== false) {
|
||||||
|
if ($file != "" && $file != "." && $file != "..") {
|
||||||
|
$f = $dir . PATH_SEP . $file;
|
||||||
|
|
||||||
|
if (is_file($f)) {
|
||||||
|
$arrayProcessFilesData = $this->getFileManagerUid($f);
|
||||||
|
|
||||||
|
if (is_null($arrayProcessFilesData["PRF_UID"])) {
|
||||||
|
rename($dir . PATH_SEP . $file, $dir . PATH_SEP . $file . ".tmp");
|
||||||
|
|
||||||
|
$arrayData = array(
|
||||||
|
"prf_path" => $path,
|
||||||
|
"prf_filename" => $file,
|
||||||
|
"prf_content" => ""
|
||||||
|
);
|
||||||
|
|
||||||
|
$arrayData = $this->addProcessFilesManager($row["PRJ_UID"], "00000000000000000000000000000001", $arrayData);
|
||||||
|
|
||||||
|
rename($dir . PATH_SEP . $file . ".tmp", $dir . PATH_SEP . $file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir($dirh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrayProjectUid[$row["PRJ_UID"]] = $row["PRJ_UID"];
|
||||||
|
$flagProjectUid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Update PROCESS_FILES_CHECKED
|
||||||
|
if ($flagProjectUid) {
|
||||||
|
$result = $conf->update(array(
|
||||||
|
"CFG_UID" => "PROCESS_FILES_CHECKED",
|
||||||
|
"OBJ_UID" => "",
|
||||||
|
"CFG_VALUE" => serialize($arrayProjectUid),
|
||||||
|
"PRO_UID" => "",
|
||||||
|
"USR_UID" => "",
|
||||||
|
"APP_UID" => ""
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -402,6 +402,11 @@ abstract class Importer
|
|||||||
|
|
||||||
$workflow->update($arrayWorkflowTables["process"]);
|
$workflow->update($arrayWorkflowTables["process"]);
|
||||||
|
|
||||||
|
//Process-Files upgrade
|
||||||
|
$filesManager = new \ProcessMaker\BusinessModel\FilesManager();
|
||||||
|
|
||||||
|
$filesManager->processFilesUpgrade($projectUid);
|
||||||
|
|
||||||
//Return
|
//Return
|
||||||
return $projectUid;
|
return $projectUid;
|
||||||
}
|
}
|
||||||
@@ -559,7 +564,7 @@ abstract class Importer
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveAs($prj_uid, $prj_name, $prj_description, $prj_category)
|
public function saveAs($prj_uid, $prj_name, $prj_description, $prj_category)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -594,3 +599,4 @@ abstract class Importer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -581,6 +581,26 @@ class Workflow extends Handler
|
|||||||
$oCaseTracker = new \CaseTracker();
|
$oCaseTracker = new \CaseTracker();
|
||||||
$oCaseTrackerObject = new \CaseTrackerObject();
|
$oCaseTrackerObject = new \CaseTrackerObject();
|
||||||
|
|
||||||
|
//Update PROCESS_FILES_CHECKED
|
||||||
|
$configuration = \ConfigurationPeer::retrieveByPK("PROCESS_FILES_CHECKED", "", "", "", "");
|
||||||
|
|
||||||
|
if (!is_null($configuration)) {
|
||||||
|
$arrayProjectUid = unserialize($configuration->getCfgValue());
|
||||||
|
|
||||||
|
unset($arrayProjectUid[$sProcessUID]);
|
||||||
|
|
||||||
|
$conf = new \Configuration();
|
||||||
|
|
||||||
|
$result = $conf->update(array(
|
||||||
|
"CFG_UID" => "PROCESS_FILES_CHECKED",
|
||||||
|
"OBJ_UID" => "",
|
||||||
|
"CFG_VALUE" => serialize($arrayProjectUid),
|
||||||
|
"PRO_UID" => "",
|
||||||
|
"USR_UID" => "",
|
||||||
|
"APP_UID" => ""
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
//Delete the applications of process
|
//Delete the applications of process
|
||||||
if ($flagRemoveCases) {
|
if ($flagRemoveCases) {
|
||||||
$case = new \Cases();
|
$case = new \Cases();
|
||||||
|
|||||||
Reference in New Issue
Block a user