ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
UpdateSteps.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 use ilDBInterface;
25 use ilDBConstants;
26 
28 {
29  protected ilDBInterface $db;
30 
31  public function prepare(ilDBInterface $db): void
32  {
33  $this->db = $db;
34  }
35 
36  public function step_1(): void
37  {
38  $this->db->dropTable('chatroom_prooms', false);
39  $this->db->dropTable('chatroom_proomaccess', false);
40  $this->db->dropTable('chatroom_psessions', false);
41 
42  $this->dropColumnWhenExists('chatroom_history', 'sub_room');
43  $this->dropColumnWhenExists('chatroom_settings', 'allow_private_rooms');
44  $this->dropColumnWhenExists('chatroom_settings', 'private_rooms_enabled');
45  }
46 
47  public function step_2(): void
48  {
49  $this->dropTableWhenExists('chatroom_smilies');
50  }
51 
52  private function dropColumnWhenExists(string $table, string $column): void
53  {
54  if ($this->db->tableColumnExists($table, $column)) {
55  $this->db->dropTableColumn($table, $column);
56  }
57  }
58 
59  private function dropTableWhenExists(string $table): void
60  {
61  if ($this->db->tableExists($table)) {
62  $this->db->dropTable($table);
63  }
64  }
65 
66  public function step_3(): void
67  {
68  $this->dropColumnWhenExists('chatroom_settings', 'restrict_history');
69  }
70 
71  public function step_4(): void
72  {
73  $query = '
74  UPDATE object_data
75  INNER JOIN chatroom_settings ON object_data.obj_id = chatroom_settings.object_id
76  SET object_data.offline = IF(chatroom_settings.online_status = 1, 0, 1)
77  WHERE object_data.type = %s
78  ';
79 
80  $this->db->manipulateF(
81  $query,
83  ['chtr']
84  );
85  }
86 }
dropColumnWhenExists(string $table, string $column)
Definition: UpdateSteps.php:52