ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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");
24 }
25
32 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 {
47 switch ($a_version)
48 {
49 case "4.3.0":
50 return array(
51 "Id" => "integer",
52 "Title" => "text",
53 "Description" => "text");
54 }
55 }
56
57 if ($a_entity == "itgr_item")
58 {
59 switch ($a_version)
60 {
61 case "4.3.0":
62 return array(
63 "ItemGroupId" => "integer",
64 "ItemId" => "text"
65 );
66 }
67 }
68
69 }
70
77 function readData($a_entity, $a_version, $a_ids, $a_field = "")
78 {
79 global $ilDB;
80
81 if (!is_array($a_ids))
82 {
83 $a_ids = array($a_ids);
84 }
85
86 if ($a_entity == "itgr")
87 {
88 switch ($a_version)
89 {
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 }
97 }
98
99 if ($a_entity == "itgr_item")
100 {
101 switch ($a_version)
102 {
103 case "4.3.0":
104 $this->getDirectDataFromQuery($q = "SELECT item_group_id itgr_id, item_ref_id item_id".
105 " FROM item_group_item ".
106 "WHERE ".
107 $ilDB->in("item_group_id", $a_ids, false, "integer"));
108 break;
109 }
110 }
111
112 }
113
120 function getXmlRecord($a_entity, $a_version, $a_set)
121 {
122 if ($a_entity == "itgr_item")
123 {
124 // make ref id an object id
125 $a_set["ItemId"] = ilObject::_lookupObjId($a_set["ItemId"]);
126 }
127 return $a_set;
128 }
129
133 protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
134 {
135 switch ($a_entity)
136 {
137 case "itgr":
138 return array (
139 "itgr_item" => array("ids" => $a_rec["Id"])
140 );
141 }
142
143 return false;
144 }
145
152 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
153 {
154 global $ilLog;
155
156//echo $a_entity;
157//var_dump($a_rec);
158
159 switch ($a_entity)
160 {
161 case "itgr":
162 include_once("./Modules/ItemGroup/classes/class.ilObjItemGroup.php");
163
164 if ($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
165 {
166 $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
167 }
168 else
169 {
170 $newObj = new ilObjItemGroup();
171 $newObj->setType("itgr");
172 $newObj->create(true);
173 }
174
175 $newObj->setTitle($a_rec["Title"]);
176 $newObj->setDescription($a_rec["Description"]);
177 $newObj->update(true);
178 $this->current_obj = $newObj;
179 $a_mapping->addMapping("Modules/ItemGroup", "itgr", $a_rec["Id"], $newObj->getId());
180
181 break;
182
183 case "itgr_item":
184 if($obj_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['ItemId']))
185 {
186 $ref_id = current(ilObject::_getAllReferences($obj_id));
187 include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
188 $itgri = new ilItemGroupItems();
189 $itgri->setItemGroupId($this->current_obj->getId());
190 $itgri->read();
191 $itgri->addItem($ref_id);
192//$ilLog->write("Adding item with ref id -".$ref_id."- to group with id -".$this->current_obj->getId()."-.");
193 $itgri->update();
194 }
195 break;
196
197 }
198 }
199}
200?>
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)
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.
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
$ref_id
Definition: sahs_server.php:39
global $ilDB