ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilPortfolioDataSet.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
17{
19
23 public function getSupportedVersions()
24 {
25 return array("4.4.0", "5.0.0");
26 }
27
31 public function getXmlNamespace($a_entity, $a_schema_version)
32 {
33 return "http://www.ilias.de/xml/Modules/Portfolio/" . $a_entity;
34 }
35
39 protected function getTypes($a_entity, $a_version)
40 {
41 if ($a_entity == "prtt") {
42 switch ($a_version) {
43 case "4.4.0":
44 case "5.0.0":
45 return array(
46 "Id" => "integer",
47 "Title" => "text",
48 "Description" => "text",
49 "Comments" => "integer",
50 "BgColor" => "text",
51 "FontColor" => "text",
52 "Img" => "text",
53 "Ppic" => "integer",
54 "Dir" => "directory"
55 );
56 }
57 }
58
59 if ($a_entity == "portfolio_page") {
60 switch ($a_version) {
61 case "4.4.0":
62 case "5.0.0":
63 return array(
64 "Id" => "integer",
65 "PortfolioId" => "integer",
66 "Title" => "integer",
67 "OrderNr" => "integer",
68 "Type" => "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 == "prtt") {
89 switch ($a_version) {
90 case "4.4.0":
91 $this->getDirectDataFromQuery("SELECT prtf.id,od.title,od.description," .
92 "prtf.comments,prtf.bg_color,prtf.font_color,prtf.img,prtf.ppic" .
93 " FROM usr_portfolio prtf" .
94 " JOIN object_data od ON (od.obj_id = prtf.id)" .
95 " WHERE " . $ilDB->in("prtf.id", $a_ids, false, "integer") .
96 " AND od.type = " . $ilDB->quote("prtt", "text"));
97 break;
98
99 case "5.0.0":
100 $this->getDirectDataFromQuery("SELECT prtf.id,od.title,od.description," .
101 "prtf.bg_color,prtf.font_color,prtf.img,prtf.ppic" .
102 " FROM usr_portfolio prtf" .
103 " JOIN object_data od ON (od.obj_id = prtf.id)" .
104 " WHERE " . $ilDB->in("prtf.id", $a_ids, false, "integer") .
105 " AND od.type = " . $ilDB->quote("prtt", "text"));
106 break;
107 }
108 }
109
110 if ($a_entity == "portfolio_page") {
111 switch ($a_version) {
112 case "4.4.0":
113 case "5.0.0":
114 $this->getDirectDataFromQuery("SELECT id,portfolio_id,title,order_nr,type" .
115 " FROM usr_portfolio_page" .
116 " WHERE " . $ilDB->in("portfolio_id", $a_ids, false, "integer"));
117 break;
118 }
119 }
120 }
121
125 protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
126 {
127 switch ($a_entity) {
128 case "prtt":
129 return array(
130 "portfolio_page" => array("ids" => $a_rec["Id"])
131 );
132 }
133 return false;
134 }
135
142 public function getXmlRecord($a_entity, $a_version, $a_set)
143 {
144 if ($a_entity == "prtt") {
145 $dir = ilObjPortfolioTemplate::initStorage($a_set["Id"]);
146 $a_set["Dir"] = $dir;
147
148 $a_set["Comments"] = ilNote::commentsActivated($a_set["Id"], 0, "prtt");
149 }
150
151 return $a_set;
152 }
153
160 public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
161 {
162 switch ($a_entity) {
163 case "prtt":
164
165 // container copy
166 if ($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"])) {
167 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
168 } else {
169 $newObj = new ilObjPortfolioTemplate();
170 $newObj->create();
171 }
172
173 $newObj->setTitle($a_rec["Title"]);
174 $newObj->setDescription($a_rec["Description"]);
175 $newObj->setPublicComments($a_rec["Comments"]);
176 $newObj->setBackgroundColor($a_rec["BgColor"]);
177 $newObj->setFontColor($a_rec["FontColor"]);
178 $newObj->setProfilePicture($a_rec["Ppic"]);
179 $newObj->setImage($a_rec["Img"]);
180 $newObj->update();
181
182 // handle image(s)
183 if ($a_rec["Img"]) {
184 $dir = str_replace("..", "", $a_rec["Dir"]);
185 if ($dir != "" && $this->getImportDirectory() != "") {
186 $source_dir = $this->getImportDirectory() . "/" . $dir;
187 $target_dir = ilObjPortfolioTemplate::initStorage($newObj->getId());
188 ilUtil::rCopy($source_dir, $target_dir);
189 }
190 }
191
192 $a_mapping->addMapping("Modules/Portfolio", "prtt", $a_rec["Id"], $newObj->getId());
193 $a_mapping->addMapping("Services/Object", "obj", $a_rec["Id"], $newObj->getId());
194 break;
195
196 case "portfolio_page":
197 $prtt_id = (int) $a_mapping->getMapping("Modules/Portfolio", "prtt", $a_rec["PortfolioId"]);
198 if ($prtt_id) {
199 $newObj = new ilPortfolioTemplatePage();
200 $newObj->setPortfolioId($prtt_id);
201 $newObj->setTitle($a_rec["Title"]);
202 $newObj->setType($a_rec["Type"]);
203 $newObj->setOrderNr($a_rec["OrderNr"]);
204 $newObj->create(true);
205
206 $a_mapping->addMapping("Services/COPage", "pg", "prtt:" . $a_rec["Id"], "prtt:" . $newObj->getId());
207 }
208 break;
209 }
210 }
211}
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, $a_news_id=0)
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