• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/class.ilBookmarkFolder.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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                 // Initiate variables
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                 $this->tree->addTree($this->tree->getTreeId(), 1);
00116         }
00117 
00123         function create()
00124         {
00125                 $q =    "INSERT INTO bookmark_data (user_id, title, target, type) ".
00126                                 "VALUES ('".$_SESSION["AccountId"]."','".$this->getTitle()."','','bmf')";
00127                 $this->ilias->db->query($q);
00128 
00129                 $this->setId($this->ilias->db->getLastInsertId());
00130 
00131                 $this->tree->insertNode($this->getId(), $this->getParent());
00132         }
00133 
00134         function update()
00135         {
00136                 $q = "UPDATE bookmark_data SET title = '".$this->getTitle()."' WHERE obj_id = '".$this->getId()."'";
00137                 $this->ilias->db->query($q);
00138         }
00139 
00140         function getId()
00141         {
00142                 return $this->id;
00143         }
00144 
00145         function setId($a_id)
00146         {
00147                 $this->id = $a_id;
00148         }
00149 
00150         function getTitle()
00151         {
00152                 return $this->title;
00153         }
00154 
00155         function setTitle($a_title)
00156         {
00157                 $this->title = $a_title;
00158         }
00159 
00160         function getParent()
00161         {
00162                 return $this->parent;
00163         }
00164 
00165         function setParent($a_parent_id)
00166         {
00167                 $this->parent = $a_parent_id;
00168         }
00169 
00173         function getObjects($a_id)
00174         {
00175                 $a_tree_id = $_SESSION["AccountId"];
00176                 $tree = new ilTree($a_tree_id);
00177                 $tree->setTableNames('bookmark_tree','bookmark_data');
00178 
00179                 if(empty($a_id))
00180                 {
00181                         $a_id = $tree->getRootId();
00182                 }
00183 
00184                 $childs = $tree->getChilds($a_id, "title");
00185 
00186                 $objects = array();
00187                 $bookmarks = array();
00188 
00189                 foreach ($childs as $key => $child)
00190                 {
00191                         switch ($child["type"])
00192                         {
00193                                 case "bmf":
00194                                         $objects[] = $child;
00195                                         break;
00196 
00197                                 case "bm":
00198                                         $bookmarks[] = $child;
00199                                         break;
00200                         }
00201                 }
00202                 foreach ($bookmarks as $key => $bookmark)
00203                 {
00204                         $objects[] = $bookmark;
00205                 }
00206                 return $objects;
00207         }
00208 
00209         function isRootFolder($a_id)
00210         {
00211                 $a_tree_id = $_SESSION["AccountId"];
00212                 $tree = new ilTree($a_tree_id);
00213                 $tree->setTableNames('bookmark_tree','bookmark_data');
00214 
00215                 if ($a_id == $tree->getRootId())
00216                 {
00217                         return true;
00218                 }
00219                 else
00220                 {
00221                         return false;
00222                 }
00223         }
00224 
00225         function getRootFolder()
00226         {
00227                 $a_tree_id = $_SESSION["AccountId"];
00228                 $tree = new ilTree($a_tree_id);
00229                 $tree->setTableNames('bookmark_tree','bookmark_data');
00230 
00231                 return $tree->getRootId();
00232         }
00233 }
00234 ?>

Generated on Fri Dec 13 2013 08:00:14 for ILIAS Release_3_3_x_branch .rev 46803 by  doxygen 1.7.1