ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilBookmarkDataSet.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/DataSet/classes/class.ilDataSet.php");
5
14{
15
19 public function __construct()
20 {
21 global $DIC;
22
23 parent::__construct();
24 $this->db = $DIC->database();
25 }
26
33 public function getSupportedVersions()
34 {
35 return array("4.3.0");
36 }
37
44 public function getXmlNamespace($a_entity, $a_schema_version)
45 {
46 return "http://www.ilias.de/xml/Services/Bookmarks/" . $a_entity;
47 }
48
55 protected function getTypes($a_entity, $a_version)
56 {
57 // bookmarks
58 if ($a_entity == "bookmarks") {
59 switch ($a_version) {
60 case "4.3.0":
61 return array(
62 "UserId" => "integer"
63 );
64 }
65 }
66
67 // bookmark_tree
68 if ($a_entity == "bookmark_tree") {
69 switch ($a_version) {
70 case "4.3.0":
71 return array(
72 "UserId" => "integer",
73 "Child" => "integer",
74 "Parent" => "integer",
75 "Depth" => "integer",
76 "Type" => "text",
77 "Title" => "text",
78 "Description" => "text",
79 "Target" => "text"
80 );
81 }
82 }
83 }
84
91 public function readData($a_entity, $a_version, $a_ids, $a_field = "")
92 {
94
95 if (!is_array($a_ids)) {
96 $a_ids = array($a_ids);
97 }
98
99 // bookmarks
100 if ($a_entity == "bookmarks") {
101 switch ($a_version) {
102 case "4.3.0":
103 $this->data = array();
104 foreach ($a_ids as $id) {
105 $this->data[] = array("UserId" => $id);
106 }
107 break;
108 }
109 }
110
111 // bookmark_tree
112 if ($a_entity == "bookmark_tree") {
113 switch ($a_version) {
114 case "4.3.0":
115 $this->getDirectDataFromQuery("SELECT tree user_id, child " .
116 " ,parent,depth,type,title,description,target " .
117 " FROM bookmark_tree JOIN bookmark_data ON (child = obj_id) " .
118 " WHERE " .
119 $ilDB->in("tree", $a_ids, false, "integer") .
120 " ORDER BY tree, depth");
121 break;
122 }
123 }
124 }
125
129 protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
130 {
131 switch ($a_entity) {
132 case "bookmarks":
133 return array(
134 "bookmark_tree" => array("ids" => $a_rec["UserId"])
135 );
136 }
137 return false;
138 }
139
143
144
151 public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
152 {
153 switch ($a_entity) {
154 case "bookmarks":
155 break;
156
157 case "bookmark_tree":
158 $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["UserId"]);
159 if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") {
160 //echo "<br><br>";
161 //var_dump($a_rec);
162 switch ($a_rec["Type"]) {
163 case "bmf":
164 if ($a_rec["Parent"] > 0) {
165 $parent = (int) $a_mapping->getMapping("Services/Bookmarks", "bookmark_tree", $a_rec["Parent"]);
166 include_once("./Services/Bookmarks/classes/class.ilBookmarkFolder.php");
167 $bmf = new ilBookmarkFolder(0, $usr_id);
168 $bmf->setTitle($a_rec["Title"]);
169 $bmf->setParent($parent);
170 $bmf->create();
171 $fold_id = $bmf->getId();
172 } else {
173 $tree = new ilTree($usr_id);
174 $tree->setTableNames('bookmark_tree', 'bookmark_data');
175 $fold_id = $tree->readRootId();
176 }
177 $a_mapping->addMapping(
178 "Services/Bookmarks",
179 "bookmark_tree",
180 $a_rec["Child"],
181 $fold_id
182 );
183 break;
184
185 case "bm":
186 $parent = 0;
187 if (((int) $a_rec["Parent"]) > 0) {
188 $parent = (int) $a_mapping->getMapping("Services/Bookmarks", "bookmark_tree", $a_rec["Parent"]);
189 } else {
190 return;
191 }
192
193 if ($parent == 0) {
194 $tree = new ilTree($usr_id);
195 $tree->setTableNames('bookmark_tree', 'bookmark_data');
196 $parent = $tree->readRootId();
197 }
198//echo "-$parent-";
199 include_once("./Services/Bookmarks/classes/class.ilBookmark.php");
200 $bm = new ilBookmark(0, $usr_id);
201 $bm->setTitle($a_rec["Title"]);
202 $bm->setDescription($a_rec["Description"]);
203 $bm->setTarget($a_rec["Target"]);
204 $bm->setParent($parent);
205 $bm->create();
206 break;
207
208 }
209 }
210 break;
211 }
212 }
213}
An exception for terminatinating execution or to throw for unit testing.
Bookmarks Data set class.
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.
getTypes($a_entity, $a_version)
Get field types for entity.
getSupportedVersions()
Get supported versions.
readData($a_entity, $a_version, $a_ids, $a_field="")
Read data.
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
bookmark folder (note: this class handles personal bookmarks folders only)
Class Bookmarks Bookmark management.
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 ...
static _lookupType($a_id, $a_reference=false)
lookup object type
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
if(!array_key_exists('StateId', $_REQUEST)) $id
global $DIC
Definition: saml.php:7
global $ilDB
$this data['403_header']