ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMediaCastDataSet.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/DataSet/classes/class.ilDataSet.php");
5 
14 {
15  protected $order = array(); // [array]
16 
23  public function getSupportedVersions()
24  {
25  return array("5.0.0", "4.1.0");
26  }
27 
34  function getXmlNamespace($a_entity, $a_schema_version)
35  {
36  return "http://www.ilias.de/xml/Modules/MediaCast/".$a_entity;
37  }
38 
45  protected function getTypes($a_entity, $a_version)
46  {
47  if ($a_entity == "mcst")
48  {
49  switch ($a_version)
50  {
51  case "4.1.0":
52  return array(
53  "Id" => "integer",
54  "Title" => "text",
55  "Description" => "text",
56  "PublicFiles" => "integer",
57  "Downloadable" => "integer",
58  "DefaultAccess" => "integer");
59 
60  case "5.0.0":
61  return array(
62  "Id" => "integer",
63  "Title" => "text",
64  "Description" => "text",
65  "PublicFiles" => "integer",
66  "Downloadable" => "integer",
67  "DefaultAccess" => "integer",
68  "Sortmode" => "integer",
69  "Viewmode" => "text",
70  "PublicFeed" => "integer",
71  "KeepRssMin" => "integer",
72  "Order" => "text"
73  );
74  }
75  }
76 
77  }
78 
85  function readData($a_entity, $a_version, $a_ids, $a_field = "")
86  {
87  global $ilDB;
88 
89  if (!is_array($a_ids))
90  {
91  $a_ids = array($a_ids);
92  }
93 
94  if ($a_entity == "mcst")
95  {
96  switch ($a_version)
97  {
98  case "4.1.0":
99  $this->getDirectDataFromQuery("SELECT id, title, description, ".
100  " public_files, downloadable, def_access default_access".
101  " FROM il_media_cast_data JOIN object_data ON (il_media_cast_data.id = object_data.obj_id) ".
102  "WHERE ".
103  $ilDB->in("id", $a_ids, false, "integer"));
104  break;
105 
106  case "5.0.0":
107  $this->getDirectDataFromQuery("SELECT id, title, description, ".
108  " public_files, downloadable, def_access default_access, sortmode, viewmode".
109  " FROM il_media_cast_data JOIN object_data ON (il_media_cast_data.id = object_data.obj_id) ".
110  "WHERE ".
111  $ilDB->in("id", $a_ids, false, "integer"));
112 
113  // #17174 - manual order?
114  $order = array();
115  $set = $ilDB->query("SELECT * FROM il_media_cast_data_ord".
116  " WHERE ".$ilDB->in("obj_id", $a_ids, false, "integer").
117  " ORDER BY pos");
118  while($row = $ilDB->fetchAssoc($set))
119  {
120  $order[$row["obj_id"]][] = $row["item_id"];
121  }
122 
123  include_once("./Services/Block/classes/class.ilBlockSetting.php");
124  foreach ($this->data as $k => $v)
125  {
126  $this->data[$k]["PublicFeed"] = ilBlockSetting::_lookup("news", "public_feed", 0, $v["Id"]);
127  $this->data[$k]["KeepRssMin"] = (int) ilBlockSetting::_lookup("news", "keep_rss_min", 0, $v["Id"]);
128 
129  // manual order?
130  if($this->data[$k]["Sortmode"] == 4 &&
131  array_key_exists($v["Id"], $order))
132  {
133  $this->data[$k]["Order"] = implode(";", $order[$v["Id"]]);
134  }
135  }
136  break;
137  }
138  }
139 
140  }
141 
145  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
146  {
147  return false;
148  }
149 
150 
157  function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
158  {
159 //echo $a_entity;
160 //var_dump($a_rec);
161 
162  switch ($a_entity)
163  {
164  case "mcst":
165  include_once("./Modules/MediaCast/classes/class.ilObjMediaCast.php");
166 
167  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
168  {
169  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
170  }
171  else
172  {
173  $newObj = new ilObjMediaCast();
174  $newObj->setType("mcst");
175  $newObj->create(true);
176  }
177 
178  $newObj->setTitle($a_rec["Title"]);
179  $newObj->setDescription($a_rec["Description"]);
180  $newObj->setDefaultAccess($a_rec["DefaultAccess"]);
181  $newObj->setDownloadable($a_rec["Downloadable"]);
182  $newObj->setPublicFiles($a_rec["PublicFiles"]);
183 
184  if ($a_schema_version == "5.0.0")
185  {
186  $newObj->setOrder($a_rec["Sortmode"]);
187  $newObj->setViewMode($a_rec["Viewmode"]);
188 
189  if($a_rec["Order"])
190  {
191  $this->order[$newObj->getId()] = explode(";", $a_rec["Order"]);
192  }
193 
194  include_once("./Services/Block/classes/class.ilBlockSetting.php");
195  ilBlockSetting::_write("news", "public_feed",
196  $a_rec["PublicFeed"],
197  0, $newObj->getId());
198 
199  ilBlockSetting::_write("news", "keep_rss_min",
200  $a_rec["KeepRssMin"],
201  0, $newObj->getId());
202  }
203 
204  $newObj->update(true);
205  $this->current_obj = $newObj;
206  $a_mapping->addMapping("Modules/MediaCast", "mcst", $a_rec["Id"], $newObj->getId());
207  $a_mapping->addMapping("Services/News", "news_context",
208  $a_rec["Id"].":mcst:0:",
209  $newObj->getId().":mcst:0:");
210 //var_dump($a_mapping->mappings["Services/News"]["news_context"]);
211  break;
212  }
213  }
214 
215  public function getOrder()
216  {
217  return $this->order;
218  }
219 }
220 ?>