ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilNotesDataSet.php
Go to the documentation of this file.
1<?php
2
21
30{
31 protected \ILIAS\Notes\InternalDataService $notes_data;
32 protected \ILIAS\Notes\NotesManager $notes_manager;
33
34 public function __construct()
35 {
36 global $DIC;
37
39 $this->notes_manager = $DIC->notes()->internal()->domain()->notes();
40 $this->notes_data = $DIC->notes()->internal()->data();
41 }
42
43 public function getSupportedVersions(): array
44 {
45 return array("4.3.0", "10.0");
46 }
47
48 protected function getXmlNamespace(string $a_entity, string $a_schema_version): string
49 {
50 return "https://www.ilias.de/xml/Services/Notes/" . $a_entity;
51 }
52
53 protected function getTypes(
54 string $a_entity,
55 string $a_version
56 ): array {
57 // user notes
58 if ($a_entity === "user_notes") {
59 switch ($a_version) {
60 case "4.3.0":
61 case "10.0":
62 return array(
63 "Id" => "integer",
64 "RepObjId" => "integer",
65 "ObjId" => "integer",
66 "ObjType" => "text",
67 "Type" => "integer",
68 "Author" => "integer",
69 "CreationDate" => "timestamp",
70 "NoteText" => "text",
71 "Label" => "integer",
72 "Subject" => "text",
73 "NoRepository" => "integer"
74 );
75 }
76 }
77 if ($a_entity === "comments_settings") {
78 switch ($a_version) {
79 case "10.0":
80 return array(
81 "Id" => "integer",
82 "Active" => "integer"
83 );
84 }
85 }
86 return [];
87 }
88
89 public function readData(
90 string $a_entity,
91 string $a_version,
92 array $a_ids
93 ): void {
94 $ilDB = $this->db;
95
96 // user notes
97 if ($a_entity === "user_notes") {
98 switch ($a_version) {
99 case "4.3.0":
100 case "10.0":
101 $this->getDirectDataFromQuery("SELECT id, rep_obj_id, obj_id, obj_type, type, " .
102 " author, note_text, creation_date, label, subject, no_repository " .
103 " FROM note " .
104 " WHERE " .
105 $ilDB->in("author", $a_ids, false, "integer") .
106 " AND obj_type = " . $ilDB->quote("pd", "text"));
107 break;
108 }
109 }
110 if ($a_entity === "comments_settings") {
111 switch ($a_version) {
112 case "10.0":
113 foreach($a_ids as $id) {
114 $this->data[] = [
115 "Id" => $id,
116 "Active" => (int) $this->notes_manager->commentsActive((int) $id)
117 ];
118 }
119 break;
120 }
121 }
122 }
123
124 public function importRecord(
125 string $a_entity,
126 array $a_types,
127 array $a_rec,
128 ilImportMapping $a_mapping,
129 string $a_schema_version
130 ): void {
131 $a_rec = $this->stripTags($a_rec);
132 switch ($a_entity) {
133 case "user_notes":
134 $usr_id = $a_mapping->getMapping("components/ILIAS/User", "usr", $a_rec["Author"]);
135 if ($usr_id > 0) {
136 // only import real user (assigned to personal desktop) notes
137 // here.
138 if ((int) $a_rec["RepObjId"] === 0 &&
139 $a_rec["ObjId"] == $a_rec["Author"] &&
140 $a_rec["Type"] == Note::PRIVATE &&
141 $a_rec["ObjType"] === "pd") {
142 $context = $this->notes_data->context(
143 0,
144 (int) $usr_id,
145 "pd"
146 );
147
148 $note = $this->notes_data->note(
149 0,
150 $context,
151 $a_rec["NoteText"],
152 (int) $usr_id,
153 Note::PRIVATE,
154 $a_rec["CreationDate"]
155 );
156 $this->notes_manager->createNote(
157 $note,
158 [],
159 true
160 );
161 }
162 }
163 break;
164 case "comments_settings":
165 $obj_id = (int) $a_mapping->getMapping("components/ILIAS/ILIASObject", "obj", $a_rec["Id"]);
166 if ($obj_id > 0 && ((bool) ($a_rec["Active"] ?? false) === true)) {
167 $this->notes_manager->activateComments($obj_id, true);
168 }
169 break;
170 }
171 }
172}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
A dataset contains in data in a common structure that can be shared and transformed for different pur...
getMapping(string $a_comp, string $a_entity, string $a_old_id)
Notes Data set class.
readData(string $a_entity, string $a_version, array $a_ids)
Read data from DB.
getTypes(string $a_entity, string $a_version)
Get (abstract) types for (abstract) field names.
importRecord(string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
Needs to be overwritten for import use case.
ILIAS Notes InternalDataService $notes_data
ILIAS Notes NotesManager $notes_manager
getXmlNamespace(string $a_entity, string $a_schema_version)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$context
Definition: webdav.php:31