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

classes/class.ilBookmark.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 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                 // Initiate variables
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         * set id
00140         * @access       public
00141         * @param        integer
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 ?>

Generated on Fri Dec 13 2013 09:06:33 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1