ILIAS  release_8 Revision v8.24
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");
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 return array(
62 "Id" => "integer",
63 "RepObjId" => "integer",
64 "ObjId" => "integer",
65 "ObjType" => "text",
66 "Type" => "integer",
67 "Author" => "integer",
68 "CreationDate" => "timestamp",
69 "NoteText" => "text",
70 "Label" => "integer",
71 "Subject" => "text",
72 "NoRepository" => "integer"
73 );
74 }
75 }
76 return [];
77 }
78
79 public function readData(
80 string $a_entity,
81 string $a_version,
82 array $a_ids
83 ): void {
84 $ilDB = $this->db;
85
86 // user notes
87 if ($a_entity === "user_notes") {
88 switch ($a_version) {
89 case "4.3.0":
90 $this->getDirectDataFromQuery("SELECT id, rep_obj_id, obj_id, obj_type, type, " .
91 " author, note_text, creation_date, label, subject, no_repository " .
92 " FROM note " .
93 " WHERE " .
94 $ilDB->in("author", $a_ids, false, "integer") .
95 " AND obj_type = " . $ilDB->quote("pd", "text"));
96 break;
97 }
98 }
99 }
100
101 public function importRecord(
102 string $a_entity,
103 array $a_types,
104 array $a_rec,
105 ilImportMapping $a_mapping,
106 string $a_schema_version
107 ): void {
108 $a_rec = $this->stripTags($a_rec);
109 switch ($a_entity) {
110 case "user_notes":
111 $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["Author"]);
112 if ($usr_id > 0) {
113 // only import real user (assigned to personal desktop) notes
114 // here.
115 if ((int) $a_rec["RepObjId"] === 0 &&
116 $a_rec["ObjId"] == $a_rec["Author"] &&
117 (int) $a_rec["Type"] === Note::PRIVATE &&
118 $a_rec["ObjType"] === "pd") {
119 $context = $this->notes_data->context(
120 0,
121 (int) $usr_id,
122 "pd"
123 );
124 $note = $this->notes_data->note(
125 0,
126 $context,
127 $a_rec["NoteText"],
128 (int) $usr_id,
129 Note::PRIVATE,
130 $a_rec["CreationDate"]
131 );
132 $this->notes_manager->createNote(
133 $note,
134 [],
135 true
136 );
137 }
138 }
139 break;
140 }
141 }
142}
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...
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)
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$context
Definition: webdav.php:29