PMCORE-624
This commit is contained in:
@@ -8,7 +8,7 @@ $factory->define(\ProcessMaker\Model\ProcessFiles::class, function(Faker $faker)
|
|||||||
'PRO_UID' => '',
|
'PRO_UID' => '',
|
||||||
'USR_UID' => '',
|
'USR_UID' => '',
|
||||||
'PRF_UPDATE_USR_UID' => '',
|
'PRF_UPDATE_USR_UID' => '',
|
||||||
'PRF_PATH' => '',
|
'PRF_PATH' => 'dummy_path',
|
||||||
'PRF_TYPE' => '',
|
'PRF_TYPE' => '',
|
||||||
'PRF_EDITABLE' => 1,
|
'PRF_EDITABLE' => 1,
|
||||||
'PRF_CREATE_DATE' => $faker->dateTime(),
|
'PRF_CREATE_DATE' => $faker->dateTime(),
|
||||||
|
|||||||
@@ -46,12 +46,16 @@ class FilesManagerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_should_deleted_public_files_when_not_exist()
|
public function it_should_deleted_public_files_when_not_exist()
|
||||||
{
|
{
|
||||||
$proUid = G::generateUniqueID();
|
$processFiles = factory(ProcessFilesModel::class)->create();
|
||||||
$prfUid = G::generateUniqueID();
|
|
||||||
|
$emailEvent = factory(EmailEventModel::class)->create([
|
||||||
|
'PRF_UID' => $processFiles->PRF_UID
|
||||||
|
]);
|
||||||
|
|
||||||
$filesManager = new FilesManager();
|
$filesManager = new FilesManager();
|
||||||
|
|
||||||
$this->expectException(Exception::class);
|
$this->expectException(Exception::class);
|
||||||
$filesManager->deleteProcessFilesManager($proUid, $prfUid);
|
$filesManager->deleteProcessFilesManager($emailEvent->PRJ_UID, $processFiles->PRF_UID, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -203,6 +207,6 @@ class FilesManagerTest extends TestCase
|
|||||||
$filesManager = new FilesManager();
|
$filesManager = new FilesManager();
|
||||||
|
|
||||||
$this->expectException(Exception::class);
|
$this->expectException(Exception::class);
|
||||||
$filesManager->deleteProcessFilesManager($process->PRO_UID, $processFiles->PRF_UID);
|
$filesManager->deleteProcessFilesManager($process->PRO_UID, $processFiles->PRF_UID, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -683,49 +683,52 @@ class FilesManager
|
|||||||
public function deleteProcessFilesManager($proUid, $prfUid, $verifyingRelationship = false)
|
public function deleteProcessFilesManager($proUid, $prfUid, $verifyingRelationship = false)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$path = '';
|
$relationshipEmailEvent = false;
|
||||||
$criteriaProcessFiles = new Criteria("workflow");
|
if ($verifyingRelationship) {
|
||||||
|
$criteriaEmailEvent = new Criteria('workflow');
|
||||||
|
$criteriaEmailEvent->addSelectColumn(EmailEventPeer::PRF_UID);
|
||||||
|
$criteriaEmailEvent->add(EmailEventPeer::PRF_UID, $prfUid, Criteria::EQUAL);
|
||||||
|
$resultSet1 = EmailEventPeer::doSelectRS($criteriaEmailEvent);
|
||||||
|
$resultSet1->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
|
if ($resultSet1->next()) {
|
||||||
|
$relationshipEmailEvent = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$criteriaProcessFiles = new Criteria('workflow');
|
||||||
$criteriaProcessFiles->addSelectColumn(ProcessFilesPeer::PRF_PATH);
|
$criteriaProcessFiles->addSelectColumn(ProcessFilesPeer::PRF_PATH);
|
||||||
$criteriaProcessFiles->add(ProcessFilesPeer::PRF_UID, $prfUid, Criteria::EQUAL);
|
$criteriaProcessFiles->add(ProcessFilesPeer::PRF_UID, $prfUid, Criteria::EQUAL);
|
||||||
$resultSet1 = ProcessFilesPeer::doSelectRS($criteriaProcessFiles);
|
$resultSet2 = 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')));
|
|
||||||
}
|
|
||||||
|
|
||||||
$relationshipEmailEvent = false;
|
|
||||||
$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->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
$resultSet2->next();
|
|
||||||
while ($row = $resultSet2->getRow()) {
|
|
||||||
$relationshipEmailEvent = true;
|
|
||||||
$resultSet2->next();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ($resultSet2->next()) {
|
||||||
|
$row = $resultSet2->getRow();
|
||||||
|
$path = $row['PRF_PATH'];
|
||||||
|
|
||||||
|
if (!empty($path)) {
|
||||||
$path = str_replace("\\", "/", $path);
|
$path = str_replace("\\", "/", $path);
|
||||||
$fileName = basename($path);
|
$fileName = basename($path);
|
||||||
if ($relationshipEmailEvent && !$verifyingRelationship) {
|
if ($relationshipEmailEvent) {
|
||||||
throw new Exception(G::LoadTranslation(G::LoadTranslation('ID_CANNOT_REMOVE_TEMPLATE_EMAIL_EVENT', [$fileName])));
|
throw new Exception(G::LoadTranslation(
|
||||||
|
G::LoadTranslation('ID_CANNOT_REMOVE_TEMPLATE_EMAIL_EVENT',
|
||||||
|
[$fileName]
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = PATH_DATA_MAILTEMPLATES . $proUid . "/" . $fileName;
|
$path = PATH_DATA_MAILTEMPLATES . $proUid . "/" . $fileName;
|
||||||
|
|
||||||
if (file_exists($path) && !is_dir($path)) {
|
if (file_exists($path) && !is_dir($path)) {
|
||||||
unlink($path);
|
unlink($path);
|
||||||
} else {
|
} else {
|
||||||
$path = PATH_DATA_PUBLIC . $proUid . "/" . $fileName;
|
$path = PATH_DATA_PUBLIC . $proUid . "/" . $fileName;
|
||||||
|
|
||||||
if (file_exists($path) && !is_dir($path)) {
|
if (file_exists($path) && !is_dir($path)) {
|
||||||
unlink($path);
|
unlink($path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
ProcessFilesPeer::doDelete($criteriaProcessFiles);
|
ProcessFilesPeer::doDelete($criteriaProcessFiles);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
|
|||||||
@@ -713,7 +713,7 @@ class BpmnWorkflow extends Project\Bpmn
|
|||||||
if ($emailEvent->existsEvent($bpmnEvent->getPrjUid(), $bpmnEvent->getEvnUid())) {
|
if ($emailEvent->existsEvent($bpmnEvent->getPrjUid(), $bpmnEvent->getEvnUid())) {
|
||||||
$arrayEmailEventData = $emailEvent->getEmailEventData($bpmnEvent->getPrjUid(), $bpmnEvent->getEvnUid());
|
$arrayEmailEventData = $emailEvent->getEmailEventData($bpmnEvent->getPrjUid(), $bpmnEvent->getEvnUid());
|
||||||
$arrayEmailEventData = array_change_key_case($arrayEmailEventData, CASE_UPPER);
|
$arrayEmailEventData = array_change_key_case($arrayEmailEventData, CASE_UPPER);
|
||||||
$emailEvent->delete($bpmnEvent->getPrjUid(), $arrayEmailEventData["EMAIL_EVENT_UID"], true);
|
$emailEvent->delete($bpmnEvent->getPrjUid(), $arrayEmailEventData["EMAIL_EVENT_UID"], true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user