ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilNotificationUpdateSteps.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24{
25 protected ilDBInterface $db;
26
27 public function prepare(ilDBInterface $db): void
28 {
29 $this->db = $db;
30 }
31
32 public function step_1(): void
33 {
34 // Creation of administration node forced by \ilTreeAdminNodeAddedObjective
35 }
36
37 public function step_2(): void
38 {
39 $this->db->manipulateF(
40 'DELETE FROM settings WHERE module = %s AND keyword = %s',
42 ['notifications', 'enable_mail']
43 );
44 $this->db->manipulateF(
45 'UPDATE settings SET keyword = %s WHERE module = %s AND keyword = %s',
47 ['osd_interval', 'notifications', 'osd_polling_intervall']
48 );
49 $this->db->manipulateF(
50 'UPDATE settings SET module = %s, keyword = %s WHERE module = %s AND keyword = %s',
52 ['notifications', 'play_sound', 'chatroom', 'play_invitation_sound']
53 );
54 $this->db->manipulateF(
55 'UPDATE usr_pref SET keyword = %s WHERE keyword = %s',
57 ['play_sound', 'chat_play_invitation_sound']
58 );
59 }
60
61 public function step_3(): void
62 {
63 $this->db->manipulateF(
64 'DELETE FROM notification_usercfg WHERE module = %s',
66 ['osd_main']
67 );
68 ilNotificationSetupHelper::registerType(
69 $this->db,
70 'buddysystem_request',
71 'buddysystem_request',
72 'buddysystem_request_desc',
73 'contact',
74 'set_by_admin'
75 );
76 }
77
78 public function step_4(): void
79 {
80 ilNotificationSetupHelper::registerType(
81 $this->db,
82 'who_is_online',
83 'who_is_online',
84 'who_is_online_desc',
85 'user',
86 'set_by_admin'
87 );
88 $this->db->insert(
89 'notification_usercfg',
90 [
91 'usr_id' => [ilDBConstants::T_INTEGER, -1],
92 'module' => [ilDBConstants::T_TEXT, 'who_is_online'],
93 'channel' => [ilDBConstants::T_TEXT, 'osd']
94 ]
95 );
96 $this->db->manipulateF(
97 'UPDATE notification_osd SET type = %s WHERE type = %s AND serialized LIKE %s',
99 ['who_is_online', 'osd_main', '%icon_usr.svg%']
100 );
101 }
102
103 public function step_5(): void
104 {
105 ilNotificationSetupHelper::registerType(
106 $this->db,
107 'badge_received',
108 'badge_received',
109 'badge_received_desc',
110 'achievement',
111 'set_by_admin'
112 );
113 $this->db->insert(
114 'notification_usercfg',
115 [
116 'usr_id' => [ilDBConstants::T_INTEGER, -1],
117 'module' => [ilDBConstants::T_TEXT, 'badge_received'],
118 'channel' => [ilDBConstants::T_TEXT, 'osd']
119 ]
120 );
121 $this->db->manipulateF(
122 'UPDATE notification_osd SET type = %s WHERE type = %s AND serialized LIKE %s',
124 ['badge_received', 'osd_main', '%icon_bdga.svg%']
125 );
126 }
127
128 public function step_6(): void
129 {
130 }
131
132 public function step_7(): void
133 {
134 $this->db->insert('settings', [
135 'module' => [ilDBConstants::T_TEXT, 'notifications'],
136 'keyword' => [ilDBConstants::T_TEXT, 'enable_mail'],
137 'value' => [ilDBConstants::T_TEXT, '1']
138 ]);
139 }
140
141 public function step_8(): void
142 {
143 $this->db->addIndex('notification_osd', ['usr_id', 'type', 'time_added'], 'i1');
144 }
145
146 public function step_9(): void
147 {
148 $this->db->manipulateF(
149 "UPDATE settings SET value = CONCAT(value , '000') WHERE keyword = %s",
151 ['osd_interval']
152 );
153 $this->db->manipulateF(
154 'UPDATE usr_pref SET keyword = %s WHERE keyword = %s',
156 ['osd_play_sound', 'play_sound']
157 );
158 }
159
160 public function step_10(): void
161 {
162 if (!$this->db->tableColumnExists('notification_osd', 'identification')) {
163 $this->db->addTableColumn('notification_osd', 'identification', [
164 'type' => ilDBConstants::T_TEXT,
165 'length' => 255,
166 'notnull' => true,
167 'default' => ''
168 ]);
169 }
170
171 $this->db->manipulate('TRUNCATE TABLE notification_osd');
172 }
173
174 public function step_11(): void
175 {
176 $this->db->manipulateF(
177 'DELETE FROM settings WHERE module = %s AND keyword = %s',
179 ['notifications', 'enable_mail']
180 );
181 $this->db->insert('settings', [
182 'module' => [ilDBConstants::T_TEXT, 'notifications'],
183 'keyword' => [ilDBConstants::T_TEXT, 'enable_mail'],
184 'value' => [ilDBConstants::T_TEXT, '1']
185 ]);
186 }
187}
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...