ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
class.ilPortfolioDataSet.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/DataSet/classes/class.ilDataSet.php");
5 
20 {
21  protected $current_portfolio;
22 
26  public function getSupportedVersions()
27  {
28  return array("4.4.0", "5.0.0");
29  }
30 
34  function getXmlNamespace($a_entity, $a_schema_version)
35  {
36  return "http://www.ilias.de/xml/Modules/Portfolio/".$a_entity;
37  }
38 
42  protected function getTypes($a_entity, $a_version)
43  {
44  if ($a_entity == "prtt")
45  {
46  switch ($a_version)
47  {
48  case "4.4.0":
49  case "5.0.0":
50  return array(
51  "Id" => "integer",
52  "Title" => "text",
53  "Description" => "text",
54  "Comments" => "integer",
55  "BgColor" => "text",
56  "FontColor" => "text",
57  "Img" => "text",
58  "Ppic" => "integer",
59  "Dir" => "directory"
60  );
61  }
62  }
63 
64  if ($a_entity == "portfolio_page")
65  {
66  switch ($a_version)
67  {
68  case "4.4.0":
69  case "5.0.0":
70  return array(
71  "Id" => "integer",
72  "PortfolioId" => "integer",
73  "Title" => "integer",
74  "OrderNr" => "integer",
75  "Type" => "text"
76  );
77  }
78  }
79  }
80 
87  function readData($a_entity, $a_version, $a_ids, $a_field = "")
88  {
89  global $ilDB;
90 
91  if (!is_array($a_ids))
92  {
93  $a_ids = array($a_ids);
94  }
95 
96  if ($a_entity == "prtt")
97  {
98  switch ($a_version)
99  {
100  case "4.4.0":
101  $this->getDirectDataFromQuery("SELECT prtf.id,od.title,od.description,".
102  "prtf.comments,prtf.bg_color,prtf.font_color,prtf.img,prtf.ppic".
103  " FROM usr_portfolio prtf".
104  " JOIN object_data od ON (od.obj_id = prtf.id)".
105  " WHERE ".$ilDB->in("prtf.id", $a_ids, false, "integer").
106  " AND od.type = ".$ilDB->quote("prtt", "text"));
107  break;
108 
109  case "5.0.0":
110  $this->getDirectDataFromQuery("SELECT prtf.id,od.title,od.description,".
111  "prtf.bg_color,prtf.font_color,prtf.img,prtf.ppic".
112  " FROM usr_portfolio prtf".
113  " JOIN object_data od ON (od.obj_id = prtf.id)".
114  " WHERE ".$ilDB->in("prtf.id", $a_ids, false, "integer").
115  " AND od.type = ".$ilDB->quote("prtt", "text"));
116  break;
117  }
118  }
119 
120  if ($a_entity == "portfolio_page")
121  {
122  switch ($a_version)
123  {
124  case "4.4.0":
125  case "5.0.0":
126  $this->getDirectDataFromQuery("SELECT id,portfolio_id,title,order_nr,type".
127  " FROM usr_portfolio_page".
128  " WHERE ".$ilDB->in("portfolio_id", $a_ids, false, "integer"));
129  break;
130  }
131  }
132  }
133 
137  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
138  {
139  switch ($a_entity)
140  {
141  case "prtt":
142  return array (
143  "portfolio_page" => array("ids" => $a_rec["Id"])
144  );
145  }
146  return false;
147  }
148 
155  function getXmlRecord($a_entity, $a_version, $a_set)
156  {
157  if ($a_entity == "prtt")
158  {
159  include_once("./Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php");
160  $dir = ilObjPortfolioTemplate::initStorage($a_set["Id"]);
161  $a_set["Dir"] = $dir;
162 
163  include_once("./Services/Notes/classes/class.ilNote.php");
164  $a_set["Comments"] = ilNote::commentsActivated($a_set["Id"], 0, "prtt");
165  }
166 
167  return $a_set;
168  }
169 
176  function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
177  {
178  switch ($a_entity)
179  {
180  case "prtt":
181  include_once("./Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php");
182 
183  // container copy
184  if($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"]))
185  {
186  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
187  }
188  else
189  {
190  $newObj = new ilObjPortfolioTemplate();
191  $newObj->create();
192  }
193 
194  $newObj->setTitle($a_rec["Title"]);
195  $newObj->setDescription($a_rec["Description"]);
196  $newObj->setPublicComments($a_rec["Comments"]);
197  $newObj->setBackgroundColor($a_rec["BgColor"]);
198  $newObj->setFontColor($a_rec["FontColor"]);
199  $newObj->setProfilePicture($a_rec["Ppic"]);
200  $newObj->setImage($a_rec["Img"]);
201  $newObj->update();
202 
203  // handle image(s)
204  if($a_rec["Img"])
205  {
206  $dir = str_replace("..", "", $a_rec["Dir"]);
207  if ($dir != "" && $this->getImportDirectory() != "")
208  {
209  $source_dir = $this->getImportDirectory()."/".$dir;
210  $target_dir = ilObjPortfolioTemplate::initStorage($newObj->getId());
211  ilUtil::rCopy($source_dir, $target_dir);
212  }
213  }
214 
215  $a_mapping->addMapping("Modules/Portfolio", "prtt", $a_rec["Id"], $newObj->getId());
216  $a_mapping->addMapping("Services/Object", "obj", $a_rec["Id"], $newObj->getId());
217  break;
218 
219  case "portfolio_page":
220  $prtt_id = (int)$a_mapping->getMapping("Modules/Portfolio", "prtt", $a_rec["PortfolioId"]);
221  if($prtt_id)
222  {
223  include_once("./Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php");
224  $newObj = new ilPortfolioTemplatePage();
225  $newObj->setPortfolioId($prtt_id);
226  $newObj->setTitle($a_rec["Title"]);
227  $newObj->setType($a_rec["Type"]);
228  $newObj->setOrderNr($a_rec["OrderNr"]);
229  $newObj->create(true);
230 
231  $a_mapping->addMapping("Services/COPage", "pg", "prtt:".$a_rec["Id"], "prtt:".$newObj->getId());
232  }
233  break;
234  }
235  }
236 }
237 
238 ?>
getXmlRecord($a_entity, $a_version, $a_set)
Get xml record.
getTypes($a_entity, $a_version)
Get field types for entity.
readData($a_entity, $a_version, $a_ids, $a_field="")
Read data.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static initStorage($a_id, $a_subdir=null)
Init file system storage.
Portfolio Data set class.
getImportDirectory()
Get import directory.
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
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 ...
Page for portfolio template.
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
getDependencies($a_entity, $a_version, $a_rec, $a_ids)
Determine the dependent sets of data.
importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
Import record.
getSupportedVersions()
Get supported versions.
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
Are comments activated for object?
global $ilDB
A dataset contains in data in a common structure that can be shared and transformed for different pur...