1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
4
|
|
|
|
5
|
|
|
declare(strict_types=1); |
6
|
|
|
|
7
|
|
|
namespace Chamilo\CoreBundle\Migrations\Schema\V200; |
8
|
|
|
|
9
|
|
|
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; |
10
|
|
|
use Doctrine\DBAL\Schema\Schema; |
11
|
|
|
|
12
|
|
|
final class Version20250612070100 extends AbstractMigrationChamilo |
13
|
|
|
{ |
14
|
|
|
public function getDescription(): string |
15
|
|
|
{ |
16
|
|
|
return 'Replace per-profile login redirection settings with a unified redirect_after_login JSON setting'; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public function up(Schema $schema): void |
20
|
|
|
{ |
21
|
|
|
$this->connection->executeStatement(" |
22
|
|
|
DELETE FROM settings |
23
|
|
|
WHERE variable IN ( |
24
|
|
|
'page_after_login', |
25
|
|
|
'student_page_after_login', |
26
|
|
|
'teacher_page_after_login', |
27
|
|
|
'drh_page_after_login', |
28
|
|
|
'sessionadmin_page_after_login' |
29
|
|
|
) |
30
|
|
|
"); |
31
|
|
|
|
32
|
|
|
$jsonValue = json_encode([ |
33
|
|
|
'COURSEMANAGER' => '', |
34
|
|
|
'STUDENT' => '', |
35
|
|
|
'DRH' => '', |
36
|
|
|
'SESSIONADMIN' => 'admin-dashboard', |
37
|
|
|
'STUDENT_BOSS' => '', |
38
|
|
|
'INVITEE' => '', |
39
|
|
|
'ADMIN' => 'admin-dashboard', |
40
|
|
|
]); |
41
|
|
|
|
42
|
|
|
$existing = $this->connection->fetchOne(" |
43
|
|
|
SELECT COUNT(*) |
44
|
|
|
FROM settings |
45
|
|
|
WHERE variable = 'redirect_after_login' |
46
|
|
|
"); |
47
|
|
|
|
48
|
|
|
if ($existing > 0) { |
49
|
|
|
$this->connection->executeStatement(" |
50
|
|
|
UPDATE settings |
51
|
|
|
SET selected_value = :value |
52
|
|
|
WHERE variable = 'redirect_after_login' |
53
|
|
|
", ['value' => $jsonValue]); |
54
|
|
|
} else { |
55
|
|
|
$this->connection->insert('settings', [ |
56
|
|
|
'variable' => 'redirect_after_login', |
57
|
|
|
'type' => 'textfield', |
58
|
|
|
'category' => 'registration', |
59
|
|
|
'selected_value' => $jsonValue, |
60
|
|
|
'title' => 'Redirect after login (per profile)', |
61
|
|
|
'comment' => 'Define redirection per profile after login using a JSON object', |
62
|
|
|
'scope' => null, |
63
|
|
|
'access_url' => 1, |
64
|
|
|
'access_url_changeable' => 0, |
65
|
|
|
'access_url_locked' => 0, |
66
|
|
|
]); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|