ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
4include_once("./Services/DataSet/classes/class.ilDataSet.php");
5
20{
22
26 public function getSupportedVersions()
27 {
28 return array("4.4.0", "5.0.0");
29 }
30
34 public 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 switch ($a_version) {
46 case "4.4.0":
47 case "5.0.0":
48 return array(
49 "Id" => "integer",
50 "Title" => "text",
51 "Description" => "text",
52 "Comments" => "integer",
53 "BgColor" => "text",
54 "FontColor" => "text",
55 "Img" => "text",
56 "Ppic" => "integer",
57 "Dir" => "directory"
58 );
59 }
60 }
61
62 if ($a_entity == "portfolio_page") {
63 switch ($a_version) {
64 case "4.4.0":
65 case "5.0.0":
66 return array(
67 "Id" => "integer",
68 "PortfolioId" => "integer",
69 "Title" => "integer",
70 "OrderNr" => "integer",
71 "Type" => "text"
72 );
73 }
74 }
75 }
76
83 public function readData($a_entity, $a_version, $a_ids, $a_field = "")
84 {
86
87 if (!is_array($a_ids)) {
88 $a_ids = array($a_ids);
89 }
90
91 if ($a_entity == "prtt") {
92 switch ($a_version) {
93 case "4.4.0":
94 $this->getDirectDataFromQuery("SELECT prtf.id,od.title,od.description," .
95 "prtf.comments,prtf.bg_color,prtf.font_color,prtf.img,prtf.ppic" .
96 " FROM usr_portfolio prtf" .
97 " JOIN object_data od ON (od.obj_id = prtf.id)" .
98 " WHERE " . $ilDB->in("prtf.id", $a_ids, false, "integer") .
99 " AND od.type = " . $ilDB->quote("prtt", "text"));
100 break;
101
102 case "5.0.0":
103 $this->getDirectDataFromQuery("SELECT prtf.id,od.title,od.description," .
104 "prtf.bg_color,prtf.font_color,prtf.img,prtf.ppic" .
105 " FROM usr_portfolio prtf" .
106 " JOIN object_data od ON (od.obj_id = prtf.id)" .
107 " WHERE " . $ilDB->in("prtf.id", $a_ids, false, "integer") .
108 " AND od.type = " . $ilDB->quote("prtt", "text"));
109 break;
110 }
111 }
112
113 if ($a_entity == "portfolio_page") {
114 switch ($a_version) {
115 case "4.4.0":
116 case "5.0.0":
117 $this->getDirectDataFromQuery("SELECT id,portfolio_id,title,order_nr,type" .
118 " FROM usr_portfolio_page" .
119 " WHERE " . $ilDB->in("portfolio_id", $a_ids, false, "integer"));
120 break;
121 }
122 }
123 }
124
128 protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
129 {
130 switch ($a_entity) {
131 case "prtt":
132 return array(
133 "portfolio_page" => array("ids" => $a_rec["Id"])
134 );
135 }
136 return false;
137 }
138
145 public function getXmlRecord($a_entity, $a_version, $a_set)
146 {
147 if ($a_entity == "prtt") {
148 include_once("./Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php");
149 $dir = ilObjPortfolioTemplate::initStorage($a_set["Id"]);
150 $a_set["Dir"] = $dir;
151
152 include_once("./Services/Notes/classes/class.ilNote.php");
153 $a_set["Comments"] = ilNote::commentsActivated($a_set["Id"], 0, "prtt");
154 }
155
156 return $a_set;
157 }
158
165 public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
166 {
167 switch ($a_entity) {
168 case "prtt":
169 include_once("./Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php");
170
171 // container copy
172 if ($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"])) {
173 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
174 } else {
175 $newObj = new ilObjPortfolioTemplate();
176 $newObj->create();
177 }
178
179 $newObj->setTitle($a_rec["Title"]);
180 $newObj->setDescription($a_rec["Description"]);
181 $newObj->setPublicComments($a_rec["Comments"]);
182 $newObj->setBackgroundColor($a_rec["BgColor"]);
183 $newObj->setFontColor($a_rec["FontColor"]);
184 $newObj->setProfilePicture($a_rec["Ppic"]);
185 $newObj->setImage($a_rec["Img"]);
186 $newObj->update();
187
188 // handle image(s)
189 if ($a_rec["Img"]) {
190 $dir = str_replace("..", "", $a_rec["Dir"]);
191 if ($dir != "" && $this->getImportDirectory() != "") {
192 $source_dir = $this->getImportDirectory() . "/" . $dir;
193 $target_dir = ilObjPortfolioTemplate::initStorage($newObj->getId());
194 ilUtil::rCopy($source_dir, $target_dir);
195 }
196 }
197
198 $a_mapping->addMapping("Modules/Portfolio", "prtt", $a_rec["Id"], $newObj->getId());
199 $a_mapping->addMapping("Services/Object", "obj", $a_rec["Id"], $newObj->getId());
200 break;
201
202 case "portfolio_page":
203 $prtt_id = (int) $a_mapping->getMapping("Modules/Portfolio", "prtt", $a_rec["PortfolioId"]);
204 if ($prtt_id) {
205 include_once("./Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php");
206 $newObj = new ilPortfolioTemplatePage();
207 $newObj->setPortfolioId($prtt_id);
208 $newObj->setTitle($a_rec["Title"]);
209 $newObj->setType($a_rec["Type"]);
210 $newObj->setOrderNr($a_rec["OrderNr"]);
211 $newObj->create(true);
212
213 $a_mapping->addMapping("Services/COPage", "pg", "prtt:" . $a_rec["Id"], "prtt:" . $newObj->getId());
214 }
215 break;
216 }
217 }
218}
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 ...
getImportDirectory()
Get import directory.
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
Are comments activated for object?
static initStorage($a_id, $a_subdir=null)
Init file system storage.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Portfolio Data set class.
importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
Import record.
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
readData($a_entity, $a_version, $a_ids, $a_field="")
Read data.
getXmlRecord($a_entity, $a_version, $a_set)
Get xml record.
getSupportedVersions()
Get supported versions.
getTypes($a_entity, $a_version)
Get field types for entity.
getDependencies($a_entity, $a_version, $a_rec, $a_ids)
Determine the dependent sets of data.
Page for portfolio template.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
global $ilDB