|
1
|
|
|
<?php |
|
2
|
|
|
/* For licensing terms, see /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
declare(strict_types=1); |
|
5
|
|
|
|
|
6
|
|
|
namespace Chamilo\CoreBundle\Migrations\Schema\V200; |
|
7
|
|
|
|
|
8
|
|
|
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; |
|
9
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
10
|
|
|
|
|
11
|
|
|
final class Version20251021202800 extends AbstractMigrationChamilo |
|
12
|
|
|
{ |
|
13
|
|
|
private const DEBUG = true; |
|
14
|
|
|
|
|
15
|
|
|
public function getDescription(): string |
|
16
|
|
|
{ |
|
17
|
|
|
return 'Update titles/comments for show_tabs and show_tabs_per_role and ensure they live under category "display".'; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
private const UPDATES = [ |
|
21
|
|
|
'show_tabs' => [ |
|
22
|
|
|
'title' => 'Main menu entries', |
|
23
|
|
|
'comment' => 'Check the entrie you want to see appear in the main menu', |
|
24
|
|
|
], |
|
25
|
|
|
'show_tabs_per_role' => [ |
|
26
|
|
|
'title' => 'Main menu entries per role', |
|
27
|
|
|
'comment' => 'Define header tabs visibility per role.', |
|
28
|
|
|
], |
|
29
|
|
|
]; |
|
30
|
|
|
|
|
31
|
|
|
public function up(Schema $schema): void |
|
32
|
|
|
{ |
|
33
|
|
|
$conn = $this->connection; |
|
34
|
|
|
|
|
35
|
|
|
foreach (self::UPDATES as $var => $meta) { |
|
36
|
|
|
$affected = $conn->executeStatement( |
|
37
|
|
|
"UPDATE settings |
|
38
|
|
|
SET title = ?, comment = ?, category = 'display' |
|
39
|
|
|
WHERE variable = ?", |
|
40
|
|
|
[$meta['title'], $meta['comment'], $var] |
|
41
|
|
|
); |
|
42
|
|
|
|
|
43
|
|
|
$this->dbg(sprintf( |
|
44
|
|
|
"[UP] variable='%s' -> title='%s', comment='%s', category='display' (rows=%d)", |
|
45
|
|
|
$var, $meta['title'], $meta['comment'], $affected |
|
46
|
|
|
)); |
|
47
|
|
|
|
|
48
|
|
|
if ($affected === 0) { |
|
49
|
|
|
$this->dbg(sprintf("[WARN] No rows found for variable='%s' to update.", $var)); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
private function dbg(string $msg): void |
|
55
|
|
|
{ |
|
56
|
|
|
if (self::DEBUG) { |
|
57
|
|
|
error_log('[MIG][show_tabs_titles] ' . $msg); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|