Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00033 class ilBookmark
00034 {
00040 var $user_Id;
00041
00047 var $ilias;
00048 var $tree;
00049
00050 var $title;
00051 var $description;
00052 var $target;
00053 var $id;
00054 var $parent;
00055
00061 function ilBookmark($a_bm_id = 0, $a_tree_id = 0)
00062 {
00063 global $ilias;
00064
00065
00066 $this->ilias =& $ilias;
00067 if ($a_tree_id == 0)
00068 {
00069 $a_tree_id = $_SESSION["AccountId"];
00070 }
00071
00072 $this->tree = new ilTree($a_tree_id);
00073 $this->tree->setTableNames('bookmark_tree','bookmark_data');
00074
00075 $this->id = $a_bm_id;
00076
00077 if(!empty($this->id))
00078 {
00079 $this->read();
00080 }
00081
00082 }
00083
00084
00088 function read()
00089 {
00090 global $ilias;
00091
00092 $q = "SELECT * FROM bookmark_data WHERE obj_id = ".$this->ilias->db->quote($this->getId());
00093 $bm_set = $this->ilias->db->query($q);
00094 if ($bm_set->numRows() == 0)
00095 {
00096 $message = "ilBookmark::read(): Bookmark with id ".$this->id." not found!";
00097 $ilias->raiseError($message,$ilias->error_obj->WARNING);
00098 }
00099 else
00100 {
00101 $bm = $bm_set->fetchRow(DB_FETCHMODE_ASSOC);
00102 $this->setTitle($bm["title"]);
00103 $this->setDescription($bm["description"]);
00104 $this->setTarget($bm["target"]);
00105 $this->setParent($this->tree->getParentId($this->id));
00106 }
00107 }
00108
00112 function delete()
00113 {
00114 $q = "DELETE FROM bookmark_data WHERE obj_id = ".$this->ilias->db->quote($this->getId());
00115 $this->ilias->db->query($q);
00116 }
00117
00118
00119 function create()
00120 {
00121 $q = sprintf(
00122 "INSERT INTO bookmark_data (user_id, title,description, target, type) ".
00123 "VALUES (%s,%s,%s,%s,%s)",
00124 $this->ilias->db->quote($_SESSION["AccountId"]),
00125 $this->ilias->db->quote($this->getTitle()),
00126 $this->ilias->db->quote($this->getDescription()),
00127 $this->ilias->db->quote($this->getTarget()),
00128 $this->ilias->db->quote('bm')
00129 );
00130
00131 $this->ilias->db->query($q);
00132 $this->setId($this->ilias->db->getLastInsertId());
00133 $this->tree->insertNode($this->getId(), $this->getParent());
00134 }
00135
00136 function update()
00137 {
00138 $q = sprintf(
00139 "UPDATE bookmark_data SET title=%s,description=%s,target=%s ".
00140 "WHERE obj_id=%s",
00141 $this->ilias->db->quote($this->getTitle()),
00142 $this->ilias->db->quote($this->getDescription()),
00143 $this->ilias->db->quote($this->getTarget()),
00144 $this->ilias->db->quote($this->getId())
00145 );
00146 $this->ilias->db->query($q);
00147 }
00148
00149
00150
00151
00152
00153
00154
00155 function setId($a_id)
00156 {
00157 $this->id = $a_id;
00158 }
00159
00160 function getId()
00161 {
00162 return $this->id;
00163 }
00164
00170 function setTitle($a_str)
00171 {
00172 $this->title = $a_str;
00173 }
00174
00175 function getTitle()
00176 {
00177 return $this->title;
00178 }
00184 function setDescription($a_str)
00185 {
00186 $this->description = $a_str;
00187 }
00188
00189 function getDescription()
00190 {
00191 return $this->description;
00192 }
00193
00199 function setTarget($a_target)
00200 {
00201 $this->target = $a_target;
00202 }
00203
00204
00205 function getTarget()
00206 {
00207 return $this->target;
00208 }
00209
00210 function setParent($a_parent_id)
00211 {
00212 $this->parent = $a_parent_id;
00213 }
00214
00215 function getParent()
00216 {
00217 return $this->parent;
00218 }
00219 }
00220 ?>