ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilBookmark.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4
18{
25
31 var $ilias;
32 var $tree;
33
34 var $title;
37 var $id;
39
45 function ilBookmark($a_bm_id = 0, $a_tree_id = 0)
46 {
47 global $ilias;
48
49 // Initiate variables
50 $this->ilias =& $ilias;
51 if ($a_tree_id == 0)
52 {
53 $a_tree_id = $_SESSION["AccountId"];
54 }
55
56 $this->tree = new ilTree($a_tree_id);
57 $this->tree->setTableNames('bookmark_tree','bookmark_data');
58
59 $this->id = $a_bm_id;
60
61 if(!empty($this->id))
62 {
63 $this->read();
64 }
65
66 }
67
68
72 function read()
73 {
74 global $ilias, $ilDB;
75
76 $q = "SELECT * FROM bookmark_data WHERE obj_id = ".
77 $ilDB->quote($this->getId(), "integer");
78 $bm_set = $ilDB->query($q);
79 if ($ilDB->numRows($bm_set) == 0)
80 {
81 $message = "ilBookmark::read(): Bookmark with id ".$this->id." not found!";
82 $ilias->raiseError($message,$ilias->error_obj->WARNING);
83 }
84 else
85 {
86 $bm = $ilDB->fetchAssoc($bm_set);
87 $this->setTitle($bm["title"]);
88 $this->setDescription($bm["description"]);
89 $this->setTarget($bm["target"]);
90 $this->setParent($this->tree->getParentId($this->id));
91 }
92 }
93
97 function delete()
98 {
99 global $ilDB;
100
101 if ($this->getId() != 1)
102 {
103 $q = "DELETE FROM bookmark_data WHERE obj_id = ".
104 $ilDB->quote($this->getId(), "integer");
105 $ilDB->manipulate($q);
106 }
107 }
108
109
113 function create()
114 {
115 global $ilDB;
116
117 $this->setId($ilDB->nextId("bookmark_data"));
118 $q = sprintf(
119 "INSERT INTO bookmark_data (obj_id, user_id, title,description, target, type) ".
120 "VALUES (%s,%s,%s,%s,%s,%s)",
121 $ilDB->quote($this->getId(), "integer"),
122 $ilDB->quote($_SESSION["AccountId"], "integer"),
123 $ilDB->quote($this->getTitle(), "text"),
124 $ilDB->quote($this->getDescription(), "text"),
125 $ilDB->quote($this->getTarget(), "text"),
126 $ilDB->quote('bm', "text")
127 );
128
129 $ilDB->manipulate($q);
130 $this->tree->insertNode($this->getId(), $this->getParent());
131 }
132
136 function update()
137 {
138 global $ilDB;
139
140 $q = sprintf(
141 "UPDATE bookmark_data SET title=%s,description=%s,target=%s ".
142 "WHERE obj_id=%s",
143 $ilDB->quote($this->getTitle(), "text"),
144 $ilDB->quote($this->getDescription(), "text"),
145 $ilDB->quote($this->getTarget(), "text"),
146 $ilDB->quote($this->getId(), "integer")
147 );
148 $ilDB->manipulate($q);
149 }
150
151
152 /*
153 * set id
154 * @access public
155 * @param integer
156 */
157 function setId($a_id)
158 {
159 $this->id = $a_id;
160 }
161
162 function getId()
163 {
164 return $this->id;
165 }
166
172 function setTitle($a_str)
173 {
174 $this->title = $a_str;
175 }
176
177 function getTitle()
178 {
179 return $this->title;
180 }
186 function setDescription($a_str)
187 {
188 $this->description = $a_str;
189 }
190
191 function getDescription()
192 {
193 return $this->description;
194 }
195
201 function setTarget($a_target)
202 {
203 $this->target = $a_target;
204 }
205
206
207 function getTarget()
208 {
209 return $this->target;
210 }
211
212 function setParent($a_parent_id)
213 {
214 $this->parent = $a_parent_id;
215 }
216
217 function getParent()
218 {
219 return $this->parent;
220 }
221
226 public static function _getTypeOfId($a_id)
227 {
228 global $ilias, $ilDB;
229
230 $q = "SELECT * FROM bookmark_data WHERE obj_id = ".
231 $ilDB->quote($a_id, "integer");
232 $bm_set = $ilDB->query($q);
233 if ($ilDB->numRows($bm_set) == 0)
234 {
235 return null;
236 }
237 else
238 {
239 $bm = $ilDB->fetchAssoc($bm_set);
240 return $bm["type"];
241 }
242 }
243}
244?>
$_SESSION["AccountId"]
Class Bookmarks Bookmark management.
ilBookmark($a_bm_id=0, $a_tree_id=0)
Constructor @access public.
setTarget($a_target)
set target @access public
read()
read bookmark folder data from db
update()
Update bookmark item.
setParent($a_parent_id)
setTitle($a_str)
set title @access public
static _getTypeOfId($a_id)
get type of a given id
create()
Create new bookmark item.
setDescription($a_str)
set description @access public
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
redirection script todo: (a better solution should control the processing via a xml file)
global $ilDB