ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilNotesDBUpdateSteps.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\Notes\Setup;
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 //
33 }
34
35 public function step_2(): void
36 {
37 if (!$this->db->tableColumnExists('note', 'recipient')) {
38 $this->db->addTableColumn('note', 'recipient', array(
39 'type' => 'integer',
40 'notnull' => true,
41 'length' => 4,
42 'default' => 0
43 ));
44 }
45 }
46
47 public function step_3(): void
48 {
49 $db = $this->db;
50 $set1 = $db->queryF(
51 "SELECT * FROM note_settings " .
52 " WHERE obj_type = %s AND obj_id = %s",
53 ["text", "integer"],
54 ["0", "0"]
55 );
56 while ($rec1 = $db->fetchAssoc($set1)) {
57 // get type
58 $set2 = $db->queryF(
59 "SELECT type FROM object_data " .
60 " WHERE obj_id = %s ",
61 ["integer"],
62 [$rec1["rep_obj_id"]]
63 );
64 if ($rec2 = $db->fetchAssoc($set2)) {
65
66 // get activation with current query
67 $set3 = $db->query(
68 "SELECT rep_obj_id FROM note_settings " .
69 " WHERE rep_obj_id = " . $db->quote($rec1["rep_obj_id"], "integer") .
70 " AND activated = " . $db->quote(1, "integer")
71 );
72 $active = 0;
73 if ($db->fetchAssoc($set3)) {
74 $active = 1;
75 }
76 $db->replace(
77 "note_settings",
78 [
79 "rep_obj_id" => ["integer", $rec1["rep_obj_id"]],
80 "obj_id" => ["integer", $rec1["obj_id"]]
81 ],
82 [
83 "obj_type" => ["text", $rec2["type"]],
84 "activated" => ["integer", $active],
85 ]
86 );
88 "DELETE FROM note_settings WHERE " .
89 " rep_obj_id = %s AND obj_id = %s AND obj_type = %s",
90 ["integer", "integer", "text"],
91 [$rec1["rep_obj_id"], $rec1["obj_id"], $rec1["obj_type"]]
92 );
93
94 }
95 }
96 }
97}
prepare(\ilDBInterface $db)
Prepare the execution of the steps.
Interface ilDBInterface.
replace(string $table, array $primary_keys, array $other_columns)
Replace into method.
quote($value, string $type)
manipulateF(string $query, array $types, array $values)
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.Agent.php:21