ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilNotesDBUpdateSteps.php
Go to the documentation of this file.
1 <?php
2 
19 namespace 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  $db = $this->db;
33  $set1 = $db->queryF(
34  "SELECT * FROM note_settings " .
35  " WHERE obj_type = %s AND obj_id = %s",
36  ["text", "integer"],
37  ["0", "0"]
38  );
39  while ($rec1 = $db->fetchAssoc($set1)) {
40  // get type
41  $set2 = $db->queryF(
42  "SELECT type FROM object_data " .
43  " WHERE obj_id = %s ",
44  ["integer"],
45  [$rec1["rep_obj_id"]]
46  );
47  if ($rec2 = $db->fetchAssoc($set2)) {
48 
49  // get activation with current query
50  $set3 = $db->query(
51  "SELECT rep_obj_id FROM note_settings " .
52  " WHERE rep_obj_id = " . $db->quote($rec1["rep_obj_id"], "integer") .
53  " AND activated = " . $db->quote(1, "integer")
54  );
55  $active = 0;
56  if ($db->fetchAssoc($set3)) {
57  $active = 1;
58  }
59  $db->replace(
60  "note_settings",
61  [
62  "rep_obj_id" => ["integer", $rec1["rep_obj_id"]],
63  "obj_id" => ["integer", $rec1["obj_id"]]
64  ],
65  [
66  "obj_type" => ["text", $rec2["type"]],
67  "activated" => ["integer", $active],
68  ]
69  );
70  $db->manipulateF(
71  "DELETE FROM note_settings WHERE " .
72  " rep_obj_id = %s AND obj_id = %s AND obj_type = %s",
73  ["integer", "integer", "text"],
74  [$rec1["rep_obj_id"], $rec1["obj_id"], $rec1["obj_type"]]
75  );
76 
77  }
78  }
79  }
80 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.Agent.php:21
prepare(\ilDBInterface $db)
Prepare the execution of the steps.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
queryF(string $query, array $types, array $values)