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 $target;
00052 var $id;
00053 var $parent;
00054
00060 function ilBookmark($a_bm_id = 0, $a_tree_id = 0)
00061 {
00062 global $ilias;
00063
00064
00065 $this->ilias =& $ilias;
00066 if ($a_tree_id == 0)
00067 {
00068 $a_tree_id = $_SESSION["AccountId"];
00069 }
00070
00071 $this->tree = new ilTree($a_tree_id);
00072 $this->tree->setTableNames('bookmark_tree','bookmark_data');
00073
00074 $this->id = $a_bm_id;
00075
00076 if(!empty($this->id))
00077 {
00078 $this->read();
00079 }
00080
00081 }
00082
00083
00087 function read()
00088 {
00089 global $ilias;
00090
00091 $q = "SELECT * FROM bookmark_data WHERE obj_id = '".$this->id."'";
00092 $bm_set = $this->ilias->db->query($q);
00093 if ($bm_set->numRows() == 0)
00094 {
00095 $message = "ilBookmark::read(): Bookmark with id ".$this->id." not found!";
00096 $ilias->raiseError($message,$ilias->error_obj->WARNING);
00097 }
00098 else
00099 {
00100 $bm = $bm_set->fetchRow(DB_FETCHMODE_ASSOC);
00101 $this->setTitle($bm["title"]);
00102 $this->setTarget($bm["target"]);
00103 $this->setParent($this->tree->getParentId($this->id));
00104 }
00105 }
00106
00110 function delete()
00111 {
00112 $q = "DELETE FROM bookmark_data WHERE obj_id = '".$this->getId()."'";
00113 $this->ilias->db->query($q);
00114 }
00115
00116
00117 function create()
00118 {
00119 $q = "INSERT INTO bookmark_data (user_id, title, target, type) ".
00120 "VALUES ('".$_SESSION["AccountId"]."','".$this->getTitle().
00121 "','".$this->getTarget()."','bm')";
00122
00123 $this->ilias->db->query($q);
00124
00125 $this->setId($this->ilias->db->getLastInsertId());
00126
00127 $this->tree->insertNode($this->getId(), $this->getParent());
00128 }
00129
00130 function update()
00131 {
00132 $q = "UPDATE bookmark_data SET title = '".$this->getTitle().
00133 "', target = '".$this->getTarget()."' WHERE obj_id = '".$this->getId()."'";
00134 $this->ilias->db->query($q);
00135 }
00136
00137
00138
00139
00140
00141
00142
00143 function setId($a_id)
00144 {
00145 $this->id = $a_id;
00146 }
00147
00148 function getId()
00149 {
00150 return $this->id;
00151 }
00152
00158 function setTitle($a_str)
00159 {
00160 $this->title = $a_str;
00161 }
00162
00163 function getTitle()
00164 {
00165 return $this->title;
00166 }
00167
00173 function setTarget($a_target)
00174 {
00175 $this->target = $a_target;
00176 }
00177
00178
00179 function getTarget()
00180 {
00181 return $this->target;
00182 }
00183
00184 function setParent($a_parent_id)
00185 {
00186 $this->parent = $a_parent_id;
00187 }
00188
00189 function getParent()
00190 {
00191 return $this->parent;
00192 }
00193 }
00194 ?>