ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
UpdateSteps.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\OnScreenChat\Setup;
22 
24 use ilDBInterface;
25 use ilDBConstants;
26 
28 {
29  public function prepare(ilDBInterface $db): void
30  {
31  $this->db = $db;
32  }
33 
34  public function step_1(): void
35  {
36  $replace = [
37  '&lt;' => '<',
38  '&gt;' => '>',
39  '&amp;' => '&',
40  '&quot;' => '"',
41  ];
42 
43  $replaced_message = 'message';
44  foreach ($replace as $from => $to) {
45  $replaced_message = sprintf(
46  'REPLACE(%s, %s, %s)',
47  $replaced_message,
48  $this->db->quote($from, ilDBConstants::T_TEXT),
49  $this->db->quote($to, ilDBConstants::T_TEXT)
50  );
51  }
52 
53  $this->db->manipulate('UPDATE osc_messages SET message = ' . $replaced_message);
54  }
55 }