ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMailDatabaseUpdateSteps Class Reference
+ Inheritance diagram for ilMailDatabaseUpdateSteps:
+ Collaboration diagram for ilMailDatabaseUpdateSteps:

Public Member Functions

 prepare (ilDBInterface $db)
 
 step_1 ()
 
 step_2 ()
 
 step_3 ()
 
 step_4 ()
 
 step_5 ()
 
 step_6 ()
 
 step_7 ()
 
 step_8 ()
 
 step_9 ()
 
 step_10 ()
 
 step_11 ()
 
 step_12 ()
 
 step_13 ()
 
 step_14 ()
 
 step_15 ()
 
- Public Member Functions inherited from ilDatabaseUpdateSteps
 prepare (\ilDBInterface $db)
 Prepare the execution of the steps. More...
 

Protected Attributes

ilDBInterface $db
 

Detailed Description

Definition at line 21 of file class.ilMailDatabaseUpdateSteps.php.

Member Function Documentation

◆ prepare()

ilMailDatabaseUpdateSteps::prepare ( ilDBInterface  $db)

Definition at line 25 of file class.ilMailDatabaseUpdateSteps.php.

25 : void
26 {
27 $this->db = $db;
28 }

References $db.

◆ step_1()

ilMailDatabaseUpdateSteps::step_1 ( )

Definition at line 30 of file class.ilMailDatabaseUpdateSteps.php.

30 : void
31 {
32 if ($this->db->tableExists('mail') && $this->db->tableColumnExists('mail', 'm_email')) {
33 $this->db->dropTableColumn('mail', 'm_email');
34 }
35 }

◆ step_10()

ilMailDatabaseUpdateSteps::step_10 ( )

Definition at line 157 of file class.ilMailDatabaseUpdateSteps.php.

157 : void
158 {
159 if (!$this->db->tableColumnExists('mail_options', 'absence_ar_subject')) {
160 $this->db->addTableColumn(
161 'mail_options',
162 'absence_ar_subject',
163 [
164 'type' => 'text',
165 'length' => 255,
166 'notnull' => false,
167 'default' => null
168 ]
169 );
170 }
171 }

◆ step_11()

ilMailDatabaseUpdateSteps::step_11 ( )

Definition at line 173 of file class.ilMailDatabaseUpdateSteps.php.

173 : void
174 {
175 if (!$this->db->tableExists('mail_auto_responder')) {
176 $this->db->createTable(
177 'mail_auto_responder',
178 [
179 'sender_id' => [
180 'type' => 'integer',
181 'length' => 8,
182 'notnull' => true
183 ],
184 'receiver_id' => [
185 'type' => 'integer',
186 'length' => 8,
187 'notnull' => true
188 ],
189 'sent_time' => [
190 'type' => 'timestamp',
191 'notnull' => true
192 ]
193 ]
194 );
195 $this->db->addPrimaryKey('mail_auto_responder', ['sender_id', 'receiver_id']);
196 }
197 }

◆ step_12()

ilMailDatabaseUpdateSteps::step_12 ( )

Definition at line 199 of file class.ilMailDatabaseUpdateSteps.php.

199 : void
200 {
201 $settings = [
202 'mail_system_sys_signature',
203 'mail_system_usr_from_name',
204 ];
205
206 foreach ($settings as $keyword) {
207 $res = $this->db->queryF(
208 "SELECT value FROM settings WHERE keyword = %s AND value IS NOT NULL AND value != ''",
210 [$keyword]
211 );
212 if ($this->db->numRows($res) === 1) {
213 $value = $this->db->fetchAssoc($res)['value'] ?? '';
214 if ($value === '') {
215 return;
216 }
217
218 $value = preg_replace(
219 '/\[([A-Z_]+?)\]/',
220 '{{$1}}',
221 $value
222 );
223
224 $this->db->manipulateF(
225 'UPDATE settings SET value = %s WHERE keyword = %s',
227 [$value, $keyword]
228 );
229 }
230 }
231 }
$res
Definition: ltiservices.php:69

References $res, and ilDBConstants\T_TEXT.

◆ step_13()

ilMailDatabaseUpdateSteps::step_13 ( )

Definition at line 233 of file class.ilMailDatabaseUpdateSteps.php.

233 : void
234 {
235 if ($this->db->tableExists("mail_tpl_ctx")) {
236 $query = "UPDATE mail_tpl_ctx SET " . PHP_EOL
237 . " component = REPLACE(component, 'Modules', 'components/ILIAS') " . PHP_EOL
238 . " WHERE component LIKE ('Modules/%')";
239
240 $this->db->manipulate($query);
241 }
242 }

◆ step_14()

ilMailDatabaseUpdateSteps::step_14 ( )

Definition at line 244 of file class.ilMailDatabaseUpdateSteps.php.

244 : void
245 {
246 if ($this->db->tableExists("mail_tpl_ctx")) {
247 $query = "UPDATE mail_tpl_ctx SET " . PHP_EOL
248 . " path = REPLACE(path, 'Modules', 'components/ILIAS') " . PHP_EOL
249 . " WHERE component LIKE ('Modules/%')" . PHP_EOL
250 . " AND path IS NOT NULL";
251
252 $this->db->manipulate($query);
253 }
254 }

◆ step_15()

ilMailDatabaseUpdateSteps::step_15 ( )

Definition at line 256 of file class.ilMailDatabaseUpdateSteps.php.

256 : void
257 {
258 $res = $this->db->queryF(
259 "SELECT value FROM settings WHERE keyword = %s AND value IS NOT NULL AND value != ''",
261 ['mail_system_sys_signature']
262 );
263 if ($this->db->numRows($res) === 1) {
264 $value = $this->db->fetchAssoc($res)['value'] ?? '';
265 $sys_general_signature = preg_replace('/(\s?\*\s?){2,}/', "\n\n-- \n", $value);
266 // replace [] with {{}}
267 $sys_general_signature = preg_replace('/\[([A-Z_]+?)\]/', '{{$1}}', $sys_general_signature);
268 $sys_general_signature = str_replace(
269 ['CLIENT_URL', 'CLIENT'],
270 ['ILIAS_URL', 'INSTALLATION'],
271 $sys_general_signature
272 );
273 $this->db->manipulateF(
274 'DELETE FROM settings WHERE keyword = %s',
276 ['mail_system_sys_signature']
277 );
278 }
279 $this->db->insert('settings', [
280 'module' => ['text', 'common'],
281 'keyword' => ['text', 'mail_system_sys_general_signature'],
282 'value' => [
283 'text',
284 $sys_general_signature ?? "\n\n-- \n{{INSTALLATION_NAME}}\n{{INSTALLATION_DESC}}\n{{ILIAS_URL}}\n"
285 ],
286 ]);
287 $this->db->insert('settings', [
288 'module' => ['text', 'common'],
289 'keyword' => ['text', 'mail_system_usr_general_signature'],
290 'value' => ['text', "\n\n-- \nThis mail was sent by {{USER_FULLNAME}} from {{INSTALLATION_NAME}}\n"],
291 ]);
292 }

References $res, and ilDBConstants\T_TEXT.

◆ step_2()

ilMailDatabaseUpdateSteps::step_2 ( )

Definition at line 37 of file class.ilMailDatabaseUpdateSteps.php.

37 : void
38 {
39 $result = $this->db->queryF('SELECT value FROM settings WHERE module = %s AND keyword = %s', ['text', 'text'], ['common', 'mail_system_sys_signature']);
40 $row = $this->db->fetchAssoc($result);
41 if (isset($row['value']) && $row['value'] !== '') {
42 $new_value = str_replace(['[CLIENT_NAME]', '[CLIENT_DESC]', '[CLIENT_URL]'], ['[INSTALLATION_NAME]', '[INSTALLATION_DESC]', '[ILIAS_URL]'], $row['value']);
43 if ($new_value !== $row['value']) {
44 $this->db->manipulateF(
45 'UPDATE settings SET value = %s WHERE module = %s AND keyword = %s',
46 ['text', 'text', 'text'],
47 [$new_value, 'common', 'mail_system_sys_signature']
48 );
49 }
50 }
51 }

◆ step_3()

ilMailDatabaseUpdateSteps::step_3 ( )

Definition at line 53 of file class.ilMailDatabaseUpdateSteps.php.

53 : void
54 {
55 $result = $this->db->query("SELECT tpl_id, m_message FROM mail_man_tpl WHERE m_message LIKE '%[CLIENT_NAME]%'");
56 while ($row = $this->db->fetchAssoc($result)) {
57 if (isset($row['m_message'], $row['tpl_id']) && $row['m_message'] !== '' && $row['tpl_id'] !== '') {
58 $new_value = str_replace('[CLIENT_NAME]', '[INSTALLATION_NAME]', $row['m_message']);
59 if ($new_value !== $row['m_message']) {
60 $this->db->manipulateF(
61 'UPDATE mail_man_tpl SET m_message = %s WHERE tpl_id = %s',
62 ['text', 'text'],
63 [$new_value, $row['tpl_id']]
64 );
65 }
66 }
67 }
68 }

◆ step_4()

ilMailDatabaseUpdateSteps::step_4 ( )

Definition at line 70 of file class.ilMailDatabaseUpdateSteps.php.

70 : void
71 {
72 $result = $this->db->query("SELECT lang, type, body FROM mail_template WHERE body LIKE '%[CLIENT_NAME]%'");
73 while ($row = $this->db->fetchAssoc($result)) {
74 if (isset($row['lang'], $row['type'], $row['body']) && $row['body'] !== '') {
75 $new_value = str_replace('[CLIENT_NAME]', '[INSTALLATION_NAME]', $row['body']);
76 if ($new_value !== $row['body']) {
77 $this->db->manipulateF(
78 'UPDATE mail_template SET body = %s WHERE lang = %s AND type = %s',
79 ['text', 'text', 'text'],
80 [$new_value, $row['lang'], $row['type']]
81 );
82 }
83 }
84 }
85 }

◆ step_5()

ilMailDatabaseUpdateSteps::step_5 ( )

Definition at line 87 of file class.ilMailDatabaseUpdateSteps.php.

87 : void
88 {
89 if ($this->db->tableExists('mail_options') && $this->db->tableColumnExists('mail_options', 'linebreak')) {
90 $this->db->dropTableColumn('mail_options', 'linebreak');
91 }
92 }

◆ step_6()

ilMailDatabaseUpdateSteps::step_6 ( )

Definition at line 94 of file class.ilMailDatabaseUpdateSteps.php.

94 : void
95 {
96 if (!$this->db->tableColumnExists('mail_options', 'absence_status')) {
97 $this->db->addTableColumn(
98 'mail_options',
99 'absence_status',
100 [
101 'type' => 'integer',
102 'length' => 1,
103 'notnull' => true,
104 'default' => 0
105 ]
106 );
107 }
108 }

◆ step_7()

ilMailDatabaseUpdateSteps::step_7 ( )

Definition at line 110 of file class.ilMailDatabaseUpdateSteps.php.

110 : void
111 {
112 if (!$this->db->tableColumnExists('mail_options', 'absent_from')) {
113 $this->db->addTableColumn(
114 'mail_options',
115 'absent_from',
116 [
117 'type' => 'integer',
118 'length' => 8,
119 'notnull' => true,
120 'default' => 0
121 ]
122 );
123 }
124 }

◆ step_8()

ilMailDatabaseUpdateSteps::step_8 ( )

Definition at line 126 of file class.ilMailDatabaseUpdateSteps.php.

126 : void
127 {
128 if (!$this->db->tableColumnExists('mail_options', 'absent_until')) {
129 $this->db->addTableColumn(
130 'mail_options',
131 'absent_until',
132 [
133 'type' => 'integer',
134 'length' => 8,
135 'notnull' => true,
136 'default' => 0
137 ]
138 );
139 }
140 }

◆ step_9()

ilMailDatabaseUpdateSteps::step_9 ( )

Definition at line 142 of file class.ilMailDatabaseUpdateSteps.php.

142 : void
143 {
144 if (!$this->db->tableColumnExists('mail_options', 'absence_ar_body')) {
145 $this->db->addTableColumn(
146 'mail_options',
147 'absence_ar_body',
148 [
149 'type' => 'clob',
150 'notnull' => false,
151 'default' => null
152 ]
153 );
154 }
155 }

Field Documentation

◆ $db

ilDBInterface ilMailDatabaseUpdateSteps::$db
protected

Definition at line 23 of file class.ilMailDatabaseUpdateSteps.php.

Referenced by prepare().


The documentation for this class was generated from the following file: