ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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  $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 
125  $note = $this->notes_data->note(
126  0,
127  $context,
128  $a_rec["NoteText"],
129  (int) $usr_id,
130  Note::PRIVATE,
131  $a_rec["CreationDate"]
132  );
133  $this->notes_manager->createNote(
134  $note,
135  [],
136  true
137  );
138  }
139  }
140  break;
141  }
142  }
143 }
getTypes(string $a_entity, string $a_version)
$context
Definition: webdav.php:31
ILIAS Notes InternalDataService $notes_data
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readData(string $a_entity, string $a_version, array $a_ids)
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
ilDBInterface $db
getDirectDataFromQuery(string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
importRecord(string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
ILIAS Notes NotesManager $notes_manager
stripTags(array $rec, array $omit_keys=[])
Notes Data set class.
getXmlNamespace(string $a_entity, string $a_schema_version)