ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 if ($a_entity == "itgr_item") {
91 switch ($a_version) {
92 case "4.3.0":
93 case "5.3.0":
94 $this->getDirectDataFromQuery($q = "SELECT item_group_id itgr_id, item_ref_id item_id" .
95 " FROM item_group_item " .
96 "WHERE " .
97 $ilDB->in("item_group_id", $a_ids, false, "integer"));
98 break;
99 }
100 }
101 }
102
103 public function getXmlRecord(string $a_entity, string $a_version, array $a_set): array
104 {
105 if ($a_entity == "itgr_item") {
106 // make ref id an object id
107 $a_set["ItemId"] = ilObject::_lookupObjId($a_set["ItemId"]);
108 }
109 return $a_set;
110 }
111
112 protected function getDependencies(
113 string $a_entity,
114 string $a_version,
115 ?array $a_rec = null,
116 ?array $a_ids = null
117 ): array {
118 switch ($a_entity) {
119 case "itgr":
120 return array(
121 "itgr_item" => array("ids" => $a_rec["Id"] ?? [])
122 );
123 }
124
125 return [];
126 }
127
128 public function importRecord(
129 string $a_entity,
130 array $a_types,
131 array $a_rec,
132 ilImportMapping $a_mapping,
133 string $a_schema_version
134 ): void {
135 $a_rec = $this->stripTags($a_rec);
136 switch ($a_entity) {
137 case "itgr":
138 if ($new_id = $a_mapping->getMapping('components/ILIAS/Container', 'objs', $a_rec['Id'])) {
140 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
141 } else {
142 $newObj = new ilObjItemGroup();
143 $newObj->setType("itgr");
144 $newObj->create(true);
145 }
146
147 $newObj->setTitle($a_rec["Title"]);
148 $newObj->setDescription($a_rec["Description"]);
149 $newObj->setBehaviour($a_rec["Behaviour"]);
150 $newObj->setHideTitle($a_rec["HideTitle"]);
151 $newObj->update();
152 $this->current_obj = $newObj;
153 $a_mapping->addMapping("components/ILIAS/ItemGroup", "itgr", $a_rec["Id"], $newObj->getId());
154
155 break;
156
157 case "itgr_item":
158 if ($obj_id = $a_mapping->getMapping('components/ILIAS/Container', 'objs', $a_rec['ItemId'])) {
159 $ref_id = current(ilObject::_getAllReferences($obj_id));
160 $itgri = new ilItemGroupItems();
161 $itgri->setItemGroupId($this->current_obj->getId());
162 $itgri->read();
163 $itgri->addItem($ref_id);
164 $itgri->update();
165 }
166 break;
167 }
168 }
169}
A dataset contains in data in a common structure that can be shared and transformed for different pur...
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
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...
Class ilObjItemGroup.
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:66
$q
Definition: shib_logout.php:23