• 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 
00034 class ilBookmark
00035 {
00041         var $user_Id;
00042 
00048         var $ilias;
00049         var $tree;
00050 
00051         var $title;
00052         var $description;
00053         var $target;
00054         var $id;
00055         var $parent;
00056 
00062         function ilBookmark($a_bm_id = 0, $a_tree_id = 0)
00063         {
00064                 global $ilias;
00065 
00066                 // Initiate variables
00067                 $this->ilias =& $ilias;
00068                 if ($a_tree_id == 0)
00069                 {
00070                         $a_tree_id = $_SESSION["AccountId"];
00071                 }
00072 
00073                 $this->tree = new ilTree($a_tree_id);
00074                 $this->tree->setTableNames('bookmark_tree','bookmark_data');
00075 
00076                 $this->id = $a_bm_id;
00077 
00078                 if(!empty($this->id))
00079                 {
00080                         $this->read();
00081                 }
00082 
00083         }
00084 
00085 
00089         function read()
00090         {
00091                 global $ilias;
00092 
00093                 $q = "SELECT * FROM bookmark_data WHERE obj_id = ".$this->ilias->db->quote($this->getId());
00094                 $bm_set = $this->ilias->db->query($q);
00095                 if ($bm_set->numRows() == 0)
00096                 {
00097                         $message = "ilBookmark::read(): Bookmark with id ".$this->id." not found!";
00098                         $ilias->raiseError($message,$ilias->error_obj->WARNING);
00099                 }
00100                 else
00101                 {
00102                         $bm = $bm_set->fetchRow(DB_FETCHMODE_ASSOC);
00103                         $this->setTitle($bm["title"]);
00104                         $this->setDescription($bm["description"]);
00105                         $this->setTarget($bm["target"]);
00106                         $this->setParent($this->tree->getParentId($this->id));
00107                 }
00108         }
00109 
00113         function delete()
00114         {
00115                 $q = "DELETE FROM bookmark_data WHERE obj_id = ".$this->ilias->db->quote($this->getId());
00116                 $this->ilias->db->query($q);
00117         }
00118 
00119 
00120         function create()
00121         {
00122                 $q = sprintf(
00123                                 "INSERT INTO bookmark_data (user_id, title,description, target, type) ".
00124                                 "VALUES (%s,%s,%s,%s,%s)",
00125                                 $this->ilias->db->quote($_SESSION["AccountId"]),
00126                                 $this->ilias->db->quote($this->getTitle()),
00127                                 $this->ilias->db->quote($this->getDescription()),
00128                                 $this->ilias->db->quote($this->getTarget()),
00129                                 $this->ilias->db->quote('bm')
00130                         );
00131 
00132                 $this->ilias->db->query($q);
00133                 $this->setId($this->ilias->db->getLastInsertId());
00134                 $this->tree->insertNode($this->getId(), $this->getParent());
00135         }
00136 
00137         function update()
00138         {
00139                 $q = sprintf(
00140                                 "UPDATE bookmark_data SET title=%s,description=%s,target=%s ".
00141                                 "WHERE obj_id=%s",
00142                                 $this->ilias->db->quote($this->getTitle()),
00143                                 $this->ilias->db->quote($this->getDescription()),
00144                                 $this->ilias->db->quote($this->getTarget()),
00145                                 $this->ilias->db->quote($this->getId())
00146                         );
00147                 $this->ilias->db->query($q);
00148         }
00149 
00150 
00151         /*
00152         * set id
00153         * @access       public
00154         * @param        integer
00155         */
00156         function setId($a_id)
00157         {
00158                 $this->id = $a_id;
00159         }
00160 
00161         function getId()
00162         {
00163                 return $this->id;
00164         }
00165 
00171         function setTitle($a_str)
00172         {
00173                 $this->title = $a_str;
00174         }
00175 
00176         function getTitle()
00177         {
00178                 return $this->title;
00179         }
00185         function setDescription($a_str)
00186         {
00187                 $this->description = $a_str;
00188         }
00189 
00190         function getDescription()
00191         {
00192                 return $this->description;
00193         }
00194 
00200         function setTarget($a_target)
00201         {
00202                 $this->target = $a_target;
00203         }
00204 
00205 
00206         function getTarget()
00207         {
00208                 return $this->target;
00209         }
00210 
00211         function setParent($a_parent_id)
00212         {
00213                 $this->parent = $a_parent_id;
00214         }
00215 
00216         function getParent()
00217         {
00218                 return $this->parent;
00219         }
00220 }
00221 ?>

Generated on Fri Dec 13 2013 11:57:53 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1