ILIAS  release_8 Revision v8.24
class.ilItemGroupDataSet.php
Go to the documentation of this file.
1<?php
2
24{
26
27 public function getSupportedVersions(): array
28 {
29 return array("4.3.0", "5.3.0");
30 }
31
32 public function getXmlNamespace(string $a_entity, string $a_schema_version): string
33 {
34 return "https://www.ilias.de/xml/Modules/ItemGroup/" . $a_entity;
35 }
36
37 protected function getTypes(string $a_entity, string $a_version): array
38 {
39 if ($a_entity == "itgr") {
40 switch ($a_version) {
41 case "4.3.0":
42 return array(
43 "Id" => "integer",
44 "Title" => "text",
45 "Description" => "text");
46 case "5.3.0":
47 return array(
48 "Id" => "integer",
49 "HideTitle" => "integer",
50 "Behaviour" => "integer",
51 "Title" => "text",
52 "Description" => "text");
53 }
54 }
55
56 if ($a_entity == "itgr_item") {
57 switch ($a_version) {
58 case "4.3.0":
59 case "5.3.0":
60 return array(
61 "ItemGroupId" => "integer",
62 "ItemId" => "text"
63 );
64 }
65 }
66 return [];
67 }
68
69 public function readData(string $a_entity, string $a_version, array $a_ids): void
70 {
72
73 if ($a_entity == "itgr") {
74 switch ($a_version) {
75 case "4.3.0":
76 $this->getDirectDataFromQuery("SELECT obj_id id, title, description " .
77 " FROM object_data " .
78 "WHERE " .
79 $ilDB->in("obj_id", $a_ids, false, "integer"));
80 break;
81 case "5.3.0":
82 $this->getDirectDataFromQuery("SELECT obj_id id, title, description, hide_title, behaviour " .
83 " FROM object_data JOIN itgr_data ON (object_data.obj_id = itgr_data.id)" .
84 "WHERE " .
85 $ilDB->in("obj_id", $a_ids, false, "integer"));
86 break;
87
88 }
89 }
90
91 if ($a_entity == "itgr_item") {
92 switch ($a_version) {
93 case "4.3.0":
94 case "5.3.0":
95 $this->getDirectDataFromQuery($q = "SELECT item_group_id itgr_id, item_ref_id item_id" .
96 " FROM item_group_item " .
97 "WHERE " .
98 $ilDB->in("item_group_id", $a_ids, false, "integer"));
99 break;
100 }
101 }
102 }
103
104 public function getXmlRecord(string $a_entity, string $a_version, array $a_set): array
105 {
106 if ($a_entity == "itgr_item") {
107 // make ref id an object id
108 $a_set["ItemId"] = ilObject::_lookupObjId($a_set["ItemId"]);
109 }
110 return $a_set;
111 }
112
113 protected function getDependencies(
114 string $a_entity,
115 string $a_version,
116 ?array $a_rec = null,
117 ?array $a_ids = null
118 ): array {
119 switch ($a_entity) {
120 case "itgr":
121 return array(
122 "itgr_item" => array("ids" => $a_rec["Id"] ?? [])
123 );
124 }
125
126 return [];
127 }
128
129 public function importRecord(
130 string $a_entity,
131 array $a_types,
132 array $a_rec,
133 ilImportMapping $a_mapping,
134 string $a_schema_version
135 ): void {
136 $a_rec = $this->stripTags($a_rec);
137 switch ($a_entity) {
138 case "itgr":
139 if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
141 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
142 } else {
143 $newObj = new ilObjItemGroup();
144 $newObj->setType("itgr");
145 $newObj->create(true);
146 }
147
148 $newObj->setTitle($a_rec["Title"]);
149 $newObj->setDescription($a_rec["Description"]);
150 $newObj->setBehaviour($a_rec["Behaviour"]);
151 $newObj->setHideTitle($a_rec["HideTitle"]);
152 $newObj->update();
153 $this->current_obj = $newObj;
154 $a_mapping->addMapping("Modules/ItemGroup", "itgr", $a_rec["Id"], $newObj->getId());
155
156 break;
157
158 case "itgr_item":
159 if ($obj_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['ItemId'])) {
160 $ref_id = current(ilObject::_getAllReferences($obj_id));
161 $itgri = new ilItemGroupItems();
162 $itgri->setItemGroupId($this->current_obj->getId());
163 $itgri->read();
164 $itgri->addItem($ref_id);
165 $itgri->update();
166 }
167 break;
168
169 }
170 }
171}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 ...
ilDBInterface $db
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDependencies(string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
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.
getXmlNamespace(string $a_entity, string $a_schema_version)
getXmlRecord(string $a_entity, string $a_version, array $a_set)
Get xml record for version.
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...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:67