ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilItemGroupDataSet.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/DataSet/classes/class.ilDataSet.php");
5
14{
21 public function getSupportedVersions()
22 {
23 return array("4.3.0", "5.3.0");
24 }
25
32 public function getXmlNamespace($a_entity, $a_schema_version)
33 {
34 return "http://www.ilias.de/xml/Modules/ItemGroup/" . $a_entity;
35 }
36
43 protected function getTypes($a_entity, $a_version)
44 {
45 if ($a_entity == "itgr") {
46 switch ($a_version) {
47 case "4.3.0":
48 return array(
49 "Id" => "integer",
50 "Title" => "text",
51 "Description" => "text");
52 case "5.3.0":
53 return array(
54 "Id" => "integer",
55 "HideTitle" => "integer",
56 "Behaviour" => "integer",
57 "Title" => "text",
58 "Description" => "text");
59 }
60 }
61
62 if ($a_entity == "itgr_item") {
63 switch ($a_version) {
64 case "4.3.0":
65 case "5.3.0":
66 return array(
67 "ItemGroupId" => "integer",
68 "ItemId" => "text"
69 );
70 }
71 }
72 }
73
80 public function readData($a_entity, $a_version, $a_ids, $a_field = "")
81 {
83
84 if (!is_array($a_ids)) {
85 $a_ids = array($a_ids);
86 }
87
88 if ($a_entity == "itgr") {
89 switch ($a_version) {
90 case "4.3.0":
91 $this->getDirectDataFromQuery("SELECT obj_id id, title, description " .
92 " FROM object_data " .
93 "WHERE " .
94 $ilDB->in("obj_id", $a_ids, false, "integer"));
95 break;
96 case "5.3.0":
97 $this->getDirectDataFromQuery("SELECT obj_id id, title, description, hide_title, behaviour " .
98 " FROM object_data JOIN itgr_data ON (object_data.obj_id = itgr_data.id)" .
99 "WHERE " .
100 $ilDB->in("obj_id", $a_ids, false, "integer"));
101 break;
102
103 }
104 }
105
106 if ($a_entity == "itgr_item") {
107 switch ($a_version) {
108 case "4.3.0":
109 case "5.3.0":
110 $this->getDirectDataFromQuery($q = "SELECT item_group_id itgr_id, item_ref_id item_id" .
111 " FROM item_group_item " .
112 "WHERE " .
113 $ilDB->in("item_group_id", $a_ids, false, "integer"));
114 break;
115 }
116 }
117 }
118
125 public function getXmlRecord($a_entity, $a_version, $a_set)
126 {
127 if ($a_entity == "itgr_item") {
128 // make ref id an object id
129 $a_set["ItemId"] = ilObject::_lookupObjId($a_set["ItemId"]);
130 }
131 return $a_set;
132 }
133
137 protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
138 {
139 switch ($a_entity) {
140 case "itgr":
141 return array(
142 "itgr_item" => array("ids" => $a_rec["Id"])
143 );
144 }
145
146 return false;
147 }
148
155 public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
156 {
157 switch ($a_entity) {
158 case "itgr":
159 include_once("./Modules/ItemGroup/classes/class.ilObjItemGroup.php");
160
161 if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
162 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
163 } else {
164 $newObj = new ilObjItemGroup();
165 $newObj->setType("itgr");
166 $newObj->create(true);
167 }
168
169 $newObj->setTitle($a_rec["Title"]);
170 $newObj->setDescription($a_rec["Description"]);
171 $newObj->setBehaviour($a_rec["Behaviour"]);
172 $newObj->setHideTitle($a_rec["HideTitle"]);
173 $newObj->update(true);
174 $this->current_obj = $newObj;
175 $a_mapping->addMapping("Modules/ItemGroup", "itgr", $a_rec["Id"], $newObj->getId());
176
177 break;
178
179 case "itgr_item":
180 if ($obj_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['ItemId'])) {
181 $ref_id = current(ilObject::_getAllReferences($obj_id));
182 include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
183 $itgri = new ilItemGroupItems();
184 $itgri->setItemGroupId($this->current_obj->getId());
185 $itgri->read();
186 $itgri->addItem($ref_id);
187 $itgri->update();
188 }
189 break;
190
191 }
192 }
193}
An exception for terminatinating execution or to throw for unit testing.
A dataset contains in data in a common structure that can be shared and transformed for different pur...
getDirectDataFromQuery($a_query, $a_convert_to_leading_upper=true, $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
Item group data set class.
readData($a_entity, $a_version, $a_ids, $a_field="")
Read data.
getTypes($a_entity, $a_version)
Get field types for entity.
importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
Import record.
getSupportedVersions()
Get supported versions.
getDependencies($a_entity, $a_version, $a_rec, $a_ids)
Determine the dependent sets of data.
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
getXmlRecord($a_entity, $a_version, $a_set)
Get xml record (export)
Class ilObjItemGroup.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
global $ilDB