ILIAS  release_7 Revision v7.30-3-g800a261c036
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 $a_rec = $this->stripTags($a_rec);
163 switch ($a_entity) {
164 case "prtt":
165
166 // container copy
167 if ($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"])) {
168 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
169 } else {
170 $newObj = new ilObjPortfolioTemplate();
171 $newObj->create();
172 }
173
174 $newObj->setTitle($a_rec["Title"]);
175 $newObj->setDescription($a_rec["Description"]);
176 $newObj->setPublicComments($a_rec["Comments"]);
177 $newObj->setBackgroundColor($a_rec["BgColor"]);
178 $newObj->setFontColor($a_rec["FontColor"]);
179 $newObj->setProfilePicture($a_rec["Ppic"]);
180 $newObj->setImage($a_rec["Img"]);
181 $newObj->update();
182
183 // handle image(s)
184 if ($a_rec["Img"]) {
185 $dir = str_replace("..", "", $a_rec["Dir"]);
186 if ($dir != "" && $this->getImportDirectory() != "") {
187 $source_dir = $this->getImportDirectory() . "/" . $dir;
188 $target_dir = ilObjPortfolioTemplate::initStorage($newObj->getId());
189 ilUtil::rCopy($source_dir, $target_dir);
190 }
191 }
192
193 $a_mapping->addMapping("Modules/Portfolio", "prtt", $a_rec["Id"], $newObj->getId());
194 $a_mapping->addMapping("Services/Object", "obj", $a_rec["Id"], $newObj->getId());
195 break;
196
197 case "portfolio_page":
198 $prtt_id = (int) $a_mapping->getMapping("Modules/Portfolio", "prtt", $a_rec["PortfolioId"]);
199 if ($prtt_id) {
200 $newObj = new ilPortfolioTemplatePage();
201 $newObj->setPortfolioId($prtt_id);
202 $newObj->setTitle($a_rec["Title"]);
203 $newObj->setType($a_rec["Type"]);
204 $newObj->setOrderNr($a_rec["OrderNr"]);
205 $newObj->create(true);
206
207 $a_mapping->addMapping("Services/COPage", "pg", "prtt:" . $a_rec["Id"], "prtt:" . $newObj->getId());
208 }
209 break;
210 }
211 }
212}
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...
stripTags(array $rec, array $omit_keys=[])
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