ILIAS  release_8 Revision v8.24
class.ilMailDatabaseUpdateSteps.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected ilDBInterface $db;
24
25 public function prepare(ilDBInterface $db): void
26 {
27 $this->db = $db;
28 }
29
30 public function step_1(): void
31 {
32 if ($this->db->tableExists('mail') && $this->db->tableColumnExists('mail', 'm_email')) {
33 $this->db->dropTableColumn('mail', 'm_email');
34 }
35 }
36
37 public function step_2(): 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 }
52
53 public function step_3(): 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 }
69
70 public function step_4(): 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 }
86}
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...