Skip to content

Commit 2590ab4

Browse files
Merge branch 'develop' of github.com:ProcessMaker/processmaker into epic/FOUR-26391
2 parents 7405e82 + b6a50b2 commit 2590ab4

File tree

176 files changed

+7815
-2032
lines changed

Some content is hidden

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

176 files changed

+7815
-2032
lines changed

ProcessMaker/Application.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,28 @@
33
namespace ProcessMaker;
44

55
use Igaster\LaravelTheme\Facades\Theme;
6+
use Illuminate\Container\Container;
67
use Illuminate\Filesystem\Filesystem;
78
use Illuminate\Foundation\Application as IlluminateApplication;
9+
use Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables;
10+
use Illuminate\Foundation\Bootstrap\RegisterProviders;
811
use Illuminate\Foundation\PackageManifest;
12+
use Illuminate\Support\Env;
13+
use Illuminate\Support\Facades\App;
914
use Illuminate\Support\Facades\Auth;
15+
use Illuminate\Support\Facades\Config;
16+
use ProcessMaker\Console\Kernel;
17+
use ProcessMaker\Multitenancy\Tenant;
1018

1119
/**
1220
* Class Application.
1321
*/
1422
class Application extends IlluminateApplication
1523
{
24+
public $overrideTenantId = null;
25+
26+
public $skipCacheEvents = false;
27+
1628
/**
1729
* Sets the timezone for the application and for php with the specified timezone.
1830
*

ProcessMaker/AssignmentRules/ProcessManagerAssigned.php

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
use ProcessMaker\Exception\ThereIsNoProcessManagerAssignedException;
77
use ProcessMaker\Models\Process;
88
use ProcessMaker\Models\ProcessRequest;
9+
use ProcessMaker\Models\ProcessRequestToken;
10+
use ProcessMaker\Models\User;
911
use ProcessMaker\Nayra\Contracts\Bpmn\ActivityInterface;
1012
use ProcessMaker\Nayra\Contracts\Bpmn\TokenInterface;
1113

@@ -24,16 +26,62 @@ class ProcessManagerAssigned implements AssignmentRuleInterface
2426
* @param TokenInterface $token
2527
* @param Process $process
2628
* @param ProcessRequest $request
27-
* @return int
29+
* @return int|null
2830
* @throws ThereIsNoProcessManagerAssignedException
2931
*/
3032
public function getNextUser(ActivityInterface $task, TokenInterface $token, Process $process, ProcessRequest $request)
3133
{
32-
$user_id = $request->processVersion->manager_id;
34+
// review for multiple managers
35+
$managers = $request->processVersion->manager_id;
36+
$user_id = $this->getNextManagerAssigned($managers, $task, $request);
3337
if (!$user_id) {
3438
throw new ThereIsNoProcessManagerAssignedException($task);
3539
}
3640

3741
return $user_id;
3842
}
43+
44+
/**
45+
* Get the round robin manager using a true round robin algorithm
46+
*
47+
* @param array $managers
48+
* @param ActivityInterface $task
49+
* @param ProcessRequest $request
50+
* @return int|null
51+
*/
52+
private function getNextManagerAssigned($managers, $task, $request)
53+
{
54+
// Validate input
55+
if (empty($managers) || !is_array($managers)) {
56+
return null;
57+
}
58+
59+
// If only one manager, return it
60+
if (count($managers) === 1) {
61+
return $managers[0];
62+
}
63+
64+
// get the last manager assigned to the task across all requests
65+
$last = ProcessRequestToken::where('process_id', $request->process_id)
66+
->where('element_id', $task->getId())
67+
->whereIn('user_id', $managers)
68+
->orderBy('created_at', 'desc')
69+
->first();
70+
71+
$user_id = $last ? $last->user_id : null;
72+
73+
sort($managers);
74+
75+
$key = array_search($user_id, $managers);
76+
if ($key === false) {
77+
// If no previous manager found, start with the first manager
78+
$key = 0;
79+
} else {
80+
// Move to the next manager in the round-robin
81+
$key = ($key + 1) % count($managers);
82+
}
83+
$user_id = $managers[$key];
84+
85+
return $user_id;
86+
}
3987
}

ProcessMaker/Console/Commands/ProcessMakerLicenseRemove.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ class ProcessMakerLicenseRemove extends Command
3434
*/
3535
public function handle()
3636
{
37-
if (Storage::disk('root')->exists('license.json')) {
37+
if (Storage::disk('local')->exists('license.json')) {
3838
if ($this->option('force') || $this->confirm('Are you sure you want to remove the license.json file?')) {
39-
Storage::disk('root')->delete('license.json');
39+
Storage::disk('local')->delete('license.json');
4040
$this->info('license.json removed successfully!');
4141

4242
$this->info('Calling package:discover to update the package cache with enabled packages');

ProcessMaker/Console/Commands/ProcessMakerLicenseUpdate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function handle()
4040
return 1;
4141
}
4242

43-
Storage::disk('root')->put('license.json', $content);
43+
Storage::disk('local')->put('license.json', $content);
4444

4545
$this->info('Calling package:discover to update the package cache with enabled packages');
4646
Artisan::call('package:discover');

ProcessMaker/Console/Commands/TenantsCreate.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ public function handle()
198198
$this->line('- Run migrations and seed the database');
199199
$this->line('- Run the install command for each package');
200200
$this->line('- Run artisan upgrade');
201-
$this->line('- Install passport by calling passport:install');
201+
$this->line('- Install passport by calling passport:install (create the default clients');
202+
$this->line('- Reset the admin password with auth:set-password');
203+
$this->line('- Run processmaker:initialize-script-microservice');
202204
$this->info("For example, `TENANT={$tenant->id} php artisan migrate:fresh --seed`");
203205
}
204206
}

ProcessMaker/Console/Commands/TenantsList.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class TenantsList extends Command
1515
*
1616
* @var string
1717
*/
18-
protected $signature = 'tenants:list {--ids : Only output the ids}';
18+
protected $signature = 'tenants:list {--ids : Only output the ids} {--json : Output the tenants as JSON}';
1919

2020
/**
2121
* The console command description.
@@ -40,6 +40,12 @@ public function handle()
4040
return;
4141
}
4242

43+
if ($this->option('json')) {
44+
$this->line(json_encode($tenants->toArray(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
45+
46+
return;
47+
}
48+
4349
$formattedTenants = $tenants->map(function ($tenant) {
4450
$config = $tenant->config;
4551

0 commit comments

Comments
 (0)