Skip to content

Commit 7301e17

Browse files
Merge branch 'develop' into epic/FOUR-28647
2 parents a634023 + b60ade1 commit 7301e17

90 files changed

Lines changed: 5211 additions & 546 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ProcessMaker/Console/Commands/BuildScriptExecutors.php

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ class BuildScriptExecutors extends Command
1818
*
1919
* @var string
2020
*/
21-
protected $signature = 'processmaker:build-script-executor {lang} {user?} {--rebuild}';
21+
protected $signature = 'processmaker:build-script-executor
22+
{lang : The ID or language of the script executor}
23+
{user? : The user ID to send the broadcast event to}
24+
{--rebuild : Rebuild the docker image}
25+
{--build-args= : The build arguments for the docker build command}';
2226

2327
/**
2428
* The console command description.
@@ -159,6 +163,12 @@ public function buildExecutor()
159163
$command = Docker::command() .
160164
" build --build-arg SDK_DIR=./sdk -t {$image} -f {$packagePath}/Dockerfile.custom {$packagePath}";
161165

166+
$buildArgs = $this->getBuildArgs();
167+
168+
foreach ($buildArgs as $buildArg) {
169+
$command .= ' ' . $buildArg;
170+
}
171+
162172
$this->execCommand($command);
163173

164174
$isNayra = $scriptExecutor->language === Base::NAYRA_LANG;
@@ -167,6 +177,29 @@ public function buildExecutor()
167177
}
168178
}
169179

180+
/**
181+
* Get the build arguments for the docker build command.
182+
*
183+
* @return array
184+
* - '--build-arg <key>=<value>'
185+
*/
186+
public function getBuildArgs(): array
187+
{
188+
$args = $this->option('build-args');
189+
190+
if ($args) {
191+
$buildArgs = [];
192+
193+
foreach (explode(',', $args) as $arg) {
194+
$buildArgs[] = '--build-arg ' . $arg;
195+
}
196+
197+
return $buildArgs;
198+
}
199+
200+
return [];
201+
}
202+
170203
public function getDockerfileContent(ScriptExecutor $scriptExecutor): string
171204
{
172205
$lang = $scriptExecutor->language;

ProcessMaker/Console/Commands/Install.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Install extends Command
5252
{--data-username= : The data database username}
5353
{--data-password= : The data database password}
5454
{--data-schema= : The data database schema (if pgsql)}
55-
{--redis-client=predis : The Redis client (predis or phpredis)}
55+
{--redis-client=phpredis : The Redis client (predis or phpredis)}
5656
{--redis-host= : The Redis host, default is 127.0.0.1}
5757
{--redis-prefix= : The prefix to be appended to Redis entries}
5858
{--horizon-prefix=horizon: : The prefix to be appended to Horizon queue entries}

ProcessMaker/Console/Kernel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ protected function schedule(Schedule $schedule)
2424
{
2525
$schedule->command('bpmn:timer')
2626
->everyMinute()
27-
->onOneServer();
27+
->onOneServer()
28+
->withoutOverlapping(config('app.scheduler.bpmn_timer_overlap_minutes', 5));
2829

2930
$schedule->command('processmaker:sync-recommendations --queue')
3031
->daily()
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace ProcessMaker\Contracts;
4+
5+
use ProcessMaker\Models\ProcessRequestToken;
6+
7+
/**
8+
* @see \ProcessMaker\Services\ConditionalRedirectService
9+
* @package ProcessMaker\Contracts
10+
*/
11+
interface ConditionalRedirectServiceInterface
12+
{
13+
/**
14+
* Process a set of conditions and return the first that satisfies for an array of data.
15+
*
16+
* @param array $conditionalRedirect
17+
* @param array $data
18+
*
19+
* @return array|null
20+
*/
21+
public function resolve(array $conditionalRedirect, array $data): ?array;
22+
23+
/**
24+
* Process a set of conditions and return the first that satisfies for a process request token.
25+
*
26+
* @param array $conditionalRedirect
27+
* @param ProcessRequestToken $token
28+
*
29+
* @return array|null
30+
*/
31+
public function resolveForToken(array $conditionalRedirect, ProcessRequestToken $token): ?array;
32+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace ProcessMaker\Events;
4+
5+
use Carbon\Carbon;
6+
use Illuminate\Foundation\Events\Dispatchable;
7+
use ProcessMaker\Contracts\SecurityLogEventInterface;
8+
use ProcessMaker\Traits\FormatSecurityLogChanges;
9+
10+
class CaseDeleted implements SecurityLogEventInterface
11+
{
12+
use Dispatchable;
13+
use FormatSecurityLogChanges;
14+
15+
private string $caseNumber;
16+
17+
private string $caseTitle;
18+
19+
/**
20+
* Create a new event instance.
21+
*
22+
* @return void
23+
*/
24+
public function __construct(string $caseNumber, string $caseTitle)
25+
{
26+
$this->caseNumber = $caseNumber;
27+
$this->caseTitle = $caseTitle;
28+
}
29+
30+
/**
31+
* Get specific data related to the event
32+
*
33+
* @return array
34+
*/
35+
public function getData(): array
36+
{
37+
return [
38+
'name' => $this->caseTitle,
39+
'case_number' => $this->caseNumber,
40+
'deleted_at' => Carbon::now(),
41+
];
42+
}
43+
44+
/**
45+
* Get specific data related to the event
46+
*
47+
* @return array
48+
*/
49+
public function getChanges(): array
50+
{
51+
return [
52+
'case_number' => $this->caseNumber,
53+
];
54+
}
55+
56+
/**
57+
* Get the Event name
58+
*
59+
* @return string
60+
*/
61+
public function getEventName(): string
62+
{
63+
return 'CaseDeleted';
64+
}
65+
}

ProcessMaker/Events/ProcessUpdated.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class ProcessUpdated implements ShouldBroadcastNow
2626

2727
public $activeTokens;
2828

29+
public $elementDestination;
30+
2931
/**
3032
* Create a new event instance.
3133
*
@@ -41,6 +43,7 @@ public function __construct(ProcessRequest $processRequest, $event, TokenInterfa
4143
if ($token) {
4244
$this->tokenId = $token->getId();
4345
$this->elementType = $token->element_type;
46+
$this->elementDestination = $token->elementDestination;
4447
}
4548
}
4649

ProcessMaker/Helpers/DataTypeHelper.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ private static function isDate($value)
1010
{
1111
if (is_string($value)) {
1212
if (strlen($value) > 5) {
13+
if (!preg_match('/\d{4}-\d{2}-\d{2}/', $value)) {
14+
return false;
15+
}
1316
try {
1417
$parsed = Carbon::parse($value);
1518
if ($parsed->isMidnight()) {
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?php
2+
3+
namespace ProcessMaker\Http\Controllers\Api\Actions\Cases;
4+
5+
use Illuminate\Support\Facades\DB;
6+
use ProcessMaker\Events\CaseDeleted;
7+
use ProcessMaker\Models\CaseStarted;
8+
use ProcessMaker\Models\ProcessRequest;
9+
use ProcessMaker\Models\ProcessRequestToken;
10+
use ProcessMaker\Models\TaskDraft;
11+
12+
class DeleteCase
13+
{
14+
use DeletesCaseRecords;
15+
16+
public function __invoke(string $caseNumber): void
17+
{
18+
$requestIds = $this->getRequestIds($caseNumber);
19+
20+
if ($requestIds === []) {
21+
abort(404);
22+
}
23+
24+
$caseTitle = $this->getCaseTitle($caseNumber);
25+
$tokenIds = $this->getRequestTokenIds($requestIds);
26+
27+
DB::transaction(function () use ($caseNumber, $requestIds, $tokenIds) {
28+
$this->deleteInboxRuleLogs($tokenIds);
29+
$this->deleteInboxRules($tokenIds);
30+
$this->deleteProcessRequestLocks($requestIds, $tokenIds);
31+
$this->deleteProcessAbeRequestTokens($requestIds, $tokenIds);
32+
$this->deleteScheduledTasks($requestIds, $tokenIds);
33+
$this->deleteEllucianEthosSyncTasks($tokenIds);
34+
$draftIds = $this->getTaskDraftIds($tokenIds);
35+
$this->deleteTaskDraftMedia($draftIds);
36+
$this->deleteTaskDrafts($tokenIds);
37+
$this->deleteComments($caseNumber, $requestIds, $tokenIds);
38+
$this->deleteNotifications($requestIds);
39+
$this->deleteRequestMedia($requestIds);
40+
$this->deleteCaseNumbers($requestIds);
41+
$this->deleteCasesStarted($caseNumber);
42+
$this->deleteCasesParticipated($caseNumber);
43+
$this->deleteProcessRequestTokens($requestIds);
44+
$this->deleteProcessRequests($requestIds);
45+
});
46+
47+
CaseDeleted::dispatch($caseNumber, $caseTitle);
48+
49+
$this->dispatchSavedSearchRecount();
50+
}
51+
52+
private function getRequestIds(string $caseNumber): array
53+
{
54+
return ProcessRequest::query()
55+
->where('case_number', $caseNumber)
56+
->pluck('id')
57+
->all();
58+
}
59+
60+
private function getCaseTitle(string $caseNumber): string
61+
{
62+
$caseStarted = CaseStarted::query()
63+
->where('case_number', $caseNumber)
64+
->first();
65+
66+
if ($caseStarted) {
67+
return $caseStarted->case_title ?? "Case #{$caseNumber}";
68+
} else {
69+
// If CaseStarted doesn't exist, get case title from the first ProcessRequest
70+
$firstRequest = ProcessRequest::query()
71+
->where('case_number', $caseNumber)
72+
->whereNull('parent_request_id')
73+
->first();
74+
75+
return $firstRequest?->case_title ?? "Case #{$caseNumber}";
76+
}
77+
}
78+
79+
private function getRequestTokenIds(array $requestIds): array
80+
{
81+
if ($requestIds === []) {
82+
return [];
83+
}
84+
85+
return ProcessRequestToken::query()
86+
->whereIn('process_request_id', $requestIds)
87+
->pluck('id')
88+
->all();
89+
}
90+
91+
private function getTaskDraftIds(array $tokenIds): array
92+
{
93+
if ($tokenIds === []) {
94+
return [];
95+
}
96+
97+
return TaskDraft::query()
98+
->whereIn('task_id', $tokenIds)
99+
->pluck('id')
100+
->all();
101+
}
102+
103+
private function dispatchSavedSearchRecount(): void
104+
{
105+
if (!config('savedsearch.count', false)) {
106+
return;
107+
}
108+
109+
$jobClass = 'ProcessMaker\\Package\\SavedSearch\\Jobs\\RecountAllSavedSearches';
110+
if (!class_exists($jobClass)) {
111+
return;
112+
}
113+
114+
DB::afterCommit(static function () use ($jobClass): void {
115+
$jobClass::dispatch(['request', 'task']);
116+
});
117+
}
118+
}

0 commit comments

Comments
 (0)