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 ilBookmarkFolder
00034 {
00040 var $tree;
00041
00047 var $ilias;
00048
00049 var $id;
00050 var $title;
00051 var $parent;
00052
00058 function ilBookmarkFolder($a_bmf_id = 0, $a_tree_id = 0)
00059 {
00060 global $ilias;
00061
00062
00063 $this->ilias =& $ilias;
00064 if ($a_tree_id == 0)
00065 {
00066 $a_tree_id = $_SESSION["AccountId"];
00067 }
00068
00069 $this->tree = new ilTree($a_tree_id);
00070 $this->tree->setTableNames('bookmark_tree','bookmark_data');
00071 $this->id = $a_bmf_id;
00072
00073 if(!empty($this->id))
00074 {
00075 $this->read();
00076 }
00077 }
00078
00082 function read()
00083 {
00084 global $ilias;
00085
00086 $q = "SELECT * FROM bookmark_data WHERE obj_id = '".$this->id."'";
00087 $bmf_set = $this->ilias->db->query($q);
00088 if ($bmf_set->numRows() == 0)
00089 {
00090 $message = "ilBookmarkFolder::read(): Bookmark Folder with id ".$this->id." not found!";
00091 $ilias->raiseError($message,$ilias->error_obj->WARNING);
00092 }
00093 else
00094 {
00095 $bmf = $bmf_set->fetchRow(DB_FETCHMODE_ASSOC);
00096 $this->setTitle($bmf["title"]);
00097 $this->setParent($this->tree->getParentId($this->id));
00098 }
00099 }
00100
00104 function delete()
00105 {
00106 $q = "DELETE FROM bookmark_data WHERE obj_id = '".$this->getId()."'";
00107 $this->ilias->db->query($q);
00108 }
00109
00113 function createNewBookmarkTree()
00114 {
00115 global $ilDB;
00116
00117
00118
00119
00120
00121
00122 $this->tree->addTree($this->tree->getTreeId(), 1);
00123 }
00124
00130 function create()
00131 {
00132 $q = "INSERT INTO bookmark_data (user_id, title, target, type) ".
00133 "VALUES ('".$_SESSION["AccountId"]."','".$this->getTitle()."','','bmf')";
00134 $this->ilias->db->query($q);
00135
00136 $this->setId($this->ilias->db->getLastInsertId());
00137
00138 $this->tree->insertNode($this->getId(), $this->getParent());
00139 }
00140
00141 function update()
00142 {
00143 $q = "UPDATE bookmark_data SET title = '".$this->getTitle()."' WHERE obj_id = '".$this->getId()."'";
00144 $this->ilias->db->query($q);
00145 }
00146
00147 function getId()
00148 {
00149 return $this->id;
00150 }
00151
00152 function setId($a_id)
00153 {
00154 $this->id = $a_id;
00155 }
00156
00157 function getTitle()
00158 {
00159 return $this->title;
00160 }
00161
00162 function setTitle($a_title)
00163 {
00164 $this->title = $a_title;
00165 }
00166
00167 function getParent()
00168 {
00169 return $this->parent;
00170 }
00171
00172 function setParent($a_parent_id)
00173 {
00174 $this->parent = $a_parent_id;
00175 }
00176
00180 function getObjects($a_id)
00181 {
00182 $a_tree_id = $_SESSION["AccountId"];
00183 $tree = new ilTree($a_tree_id);
00184 $tree->setTableNames('bookmark_tree','bookmark_data');
00185
00186 if(empty($a_id))
00187 {
00188 $a_id = $tree->getRootId();
00189 }
00190
00191 $childs = $tree->getChilds($a_id, "title");
00192
00193 $objects = array();
00194 $bookmarks = array();
00195
00196 foreach ($childs as $key => $child)
00197 {
00198 switch ($child["type"])
00199 {
00200 case "bmf":
00201 $objects[] = $child;
00202 break;
00203
00204 case "bm":
00205 $bookmarks[] = $child;
00206 break;
00207 }
00208 }
00209 foreach ($bookmarks as $key => $bookmark)
00210 {
00211 $objects[] = $bookmark;
00212 }
00213 return $objects;
00214 }
00215
00216 function isRootFolder($a_id)
00217 {
00218 $a_tree_id = $_SESSION["AccountId"];
00219 $tree = new ilTree($a_tree_id);
00220 $tree->setTableNames('bookmark_tree','bookmark_data');
00221
00222 if ($a_id == $tree->getRootId())
00223 {
00224 return true;
00225 }
00226 else
00227 {
00228 return false;
00229 }
00230 }
00231
00232 function getRootFolder()
00233 {
00234 $a_tree_id = $_SESSION["AccountId"];
00235 $tree = new ilTree($a_tree_id);
00236 $tree->setTableNames('bookmark_tree','bookmark_data');
00237
00238 return $tree->getRootId();
00239 }
00240 }
00241 ?>