Merged in bugfix/PMCORE-545 (pull request #7231)
PMCORE-545 Public files in a process cannot be deleted (in Windows Server) when the process is imported Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use EmailEventPeer;
|
||||
use Exception;
|
||||
use G;
|
||||
use Criteria;
|
||||
use ProcessFiles;
|
||||
use ProcessFilesPeer;
|
||||
use ProcessPeer;
|
||||
use ResultSet;
|
||||
use TaskPeer;
|
||||
|
||||
class FilesManager
|
||||
@@ -671,62 +673,60 @@ class FilesManager
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $sProcessUID {@min 32} {@max 32}
|
||||
* Deletes the physical file and its corresponding record in the database.
|
||||
* @param string $proUid {@min 32} {@max 32}
|
||||
* @param string $prfUid {@min 32} {@max 32}
|
||||
*
|
||||
*
|
||||
* @param bool $verifyingRelationship
|
||||
* @access public
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteProcessFilesManager($sProcessUID, $prfUid, $verifyingRelationship = false)
|
||||
public function deleteProcessFilesManager($proUid, $prfUid, $verifyingRelationship = false)
|
||||
{
|
||||
try {
|
||||
$path = '';
|
||||
$criteriaPf = new \Criteria("workflow");
|
||||
$criteriaPf->addSelectColumn(\ProcessFilesPeer::PRF_PATH);
|
||||
$criteriaPf->add(\ProcessFilesPeer::PRF_UID, $prfUid, \Criteria::EQUAL);
|
||||
$rsCriteria = \ProcessFilesPeer::doSelectRS($criteriaPf);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria->next();
|
||||
while ($aRow = $rsCriteria->getRow()) {
|
||||
$path = $aRow['PRF_PATH'];
|
||||
$rsCriteria->next();
|
||||
$criteriaProcessFiles = new Criteria("workflow");
|
||||
$criteriaProcessFiles->addSelectColumn(ProcessFilesPeer::PRF_PATH);
|
||||
$criteriaProcessFiles->add(ProcessFilesPeer::PRF_UID, $prfUid, Criteria::EQUAL);
|
||||
$resultSet1 = ProcessFilesPeer::doSelectRS($criteriaProcessFiles);
|
||||
$resultSet1->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$resultSet1->next();
|
||||
while ($row = $resultSet1->getRow()) {
|
||||
$path = $row['PRF_PATH'];
|
||||
$resultSet1->next();
|
||||
}
|
||||
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')));
|
||||
}
|
||||
|
||||
$relationshipEmailEvent = false;
|
||||
$criteria = new \Criteria("workflow");
|
||||
$criteria->addSelectColumn(\EmailEventPeer::PRF_UID);
|
||||
$criteria->add(\EmailEventPeer::PRF_UID, $prfUid, \Criteria::EQUAL);
|
||||
$rsCriteria = \EmailEventPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria->next();
|
||||
while ($aRow = $rsCriteria->getRow()) {
|
||||
$criteria = new Criteria("workflow");
|
||||
$criteria->addSelectColumn(EmailEventPeer::PRF_UID);
|
||||
$criteria->add(EmailEventPeer::PRF_UID, $prfUid, Criteria::EQUAL);
|
||||
$resultSet2 = EmailEventPeer::doSelectRS($criteria);
|
||||
$resultSet2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$resultSet2->next();
|
||||
while ($row = $resultSet2->getRow()) {
|
||||
$relationshipEmailEvent = true;
|
||||
$rsCriteria->next();
|
||||
$resultSet2->next();
|
||||
}
|
||||
$explodePath = explode(DIRECTORY_SEPARATOR,$path);
|
||||
|
||||
$path = str_replace("\\", "/", $path);
|
||||
$fileName = basename($path);
|
||||
if ($relationshipEmailEvent && !$verifyingRelationship) {
|
||||
throw new \Exception(\G::LoadTranslation(G::LoadTranslation('ID_CANNOT_REMOVE_TEMPLATE_EMAIL_EVENT',
|
||||
[end($explodePath)])));
|
||||
throw new Exception(G::LoadTranslation(G::LoadTranslation('ID_CANNOT_REMOVE_TEMPLATE_EMAIL_EVENT', [$fileName])));
|
||||
}
|
||||
|
||||
$sFile = end($explodePath);
|
||||
$path = PATH_DATA_MAILTEMPLATES.$sProcessUID.DIRECTORY_SEPARATOR.$sFile;
|
||||
|
||||
$path = PATH_DATA_MAILTEMPLATES . $proUid . "/" . $fileName;
|
||||
if (file_exists($path) && !is_dir($path)) {
|
||||
unlink($path);
|
||||
} else {
|
||||
$path = PATH_DATA_PUBLIC.$sProcessUID.DIRECTORY_SEPARATOR.$sFile;
|
||||
|
||||
if (file_exists($path) && !is_dir($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
$path = PATH_DATA_PUBLIC . $proUid . "/" . $fileName;
|
||||
if (file_exists($path) && !is_dir($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
}
|
||||
|
||||
$rs = \ProcessFilesPeer::doDelete($criteriaPf);
|
||||
ProcessFilesPeer::doDelete($criteriaProcessFiles);
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
13
workflow/engine/src/ProcessMaker/Model/BpmnDiagram.php
Normal file
13
workflow/engine/src/ProcessMaker/Model/BpmnDiagram.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class BpmnDiagram extends Model
|
||||
{
|
||||
protected $table = 'BPMN_DIAGRAM';
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
13
workflow/engine/src/ProcessMaker/Model/BpmnEvent.php
Normal file
13
workflow/engine/src/ProcessMaker/Model/BpmnEvent.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class BpmnEvent extends Model
|
||||
{
|
||||
protected $table = 'BPMN_EVENT';
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
13
workflow/engine/src/ProcessMaker/Model/BpmnProcess.php
Normal file
13
workflow/engine/src/ProcessMaker/Model/BpmnProcess.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class BpmnProcess extends Model
|
||||
{
|
||||
protected $table = 'BPMN_PROCESS';
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
@@ -9,6 +9,8 @@ class BpmnProject extends Model
|
||||
// Set our table name
|
||||
protected $table = 'BPMN_PROJECT';
|
||||
protected $primaryKey = 'PRJ_UID';
|
||||
public $incrementing = false;
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
13
workflow/engine/src/ProcessMaker/Model/EmailEvent.php
Normal file
13
workflow/engine/src/ProcessMaker/Model/EmailEvent.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class EmailEvent extends Model
|
||||
{
|
||||
protected $table = 'EMAIL_EVENT';
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ class ProcessFiles extends Model
|
||||
{
|
||||
protected $table = 'PROCESS_FILES';
|
||||
protected $primaryKey = 'PRF_UID';
|
||||
public $incrementing = false;
|
||||
public $timestamps = false;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user