ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilMDAnnotation.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24
31include_once 'class.ilMDBase.php';
32
33class ilMDAnnotation extends ilMDBase
34{
35 function ilMDAnnotation($a_rbac_id = 0,$a_obj_id = 0,$a_obj_type = '')
36 {
37 parent::ilMDBase($a_rbac_id,
38 $a_obj_id,
39 $a_obj_type);
40 }
41
42 // SET/GET
43 function setEntity($a_entity)
44 {
45 $this->entity = $a_entity;
46 }
47 function getEntity()
48 {
49 return $this->entity;
50 }
51 function setDate($a_date)
52 {
53 $this->date = $a_date;
54 }
55 function getDate()
56 {
57 return $this->date;
58 }
59 function setDescription($a_desc)
60 {
61 $this->description = $a_desc;
62 }
63 function getDescription()
64 {
65 return $this->description;
66 }
67 function setDescriptionLanguage($lng_obj)
68 {
69 if(is_object($lng_obj))
70 {
71 $this->description_language =& $lng_obj;
72 }
73 }
75 {
76 return $this->description_language;
77 }
79 {
80 if(is_object($this->description_language))
81 {
82 return $this->description_language->getLanguageCode();
83 }
84 return false;
85 }
86
87 function save()
88 {
89 if($this->db->autoExecute('il_meta_annotation',
90 $this->__getFields(),
91 DB_AUTOQUERY_INSERT))
92 {
93 $this->setMetaId($this->db->getLastInsertId());
94
95 return $this->getMetaId();
96 }
97 return false;
98 }
99
100 function update()
101 {
102 global $ilDB;
103
104 if($this->getMetaId())
105 {
106 if($this->db->autoExecute('il_meta_annotation',
107 $this->__getFields(),
108 DB_AUTOQUERY_UPDATE,
109 "meta_annotation_id = ".$ilDB->quote($this->getMetaId())))
110 {
111 return true;
112 }
113 }
114 return false;
115 }
116
117 function delete()
118 {
119 global $ilDB;
120
121 if($this->getMetaId())
122 {
123 $query = "DELETE FROM il_meta_annotation ".
124 "WHERE meta_annotation_id = ".$ilDB->quote($this->getMetaId());
125
126 $this->db->query($query);
127
128 return true;
129 }
130 return false;
131 }
132
133
134 function __getFields()
135 {
136 return array('rbac_id' => $this->getRBACId(),
137 'obj_id' => $this->getObjId(),
138 'obj_type' => ilUtil::prepareDBString($this->getObjType()),
139 'entity' => ilUtil::prepareDBString($this->getEntity()),
140 'date' => ilUtil::prepareDBString($this->getDate()),
141 'description' => ilUtil::prepareDBString($this->getDescription()),
142 'description_language' => ilUtil::prepareDBString($this->getDescriptionLanguageCode()));
143 }
144
145 function read()
146 {
147 global $ilDB;
148
149 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLanguageItem.php';
150
151 if($this->getMetaId())
152 {
153 $query = "SELECT * FROM il_meta_annotation ".
154 "WHERE meta_annotation_id = ".$ilDB->quote($this->getMetaId());
155
156 $res = $this->db->query($query);
157 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
158 {
159 $this->setRBACId($row->rbac_id);
160 $this->setObjId($row->obj_id);
161 $this->setObjType($row->obj_type);
162 $this->setEntity(ilUtil::stripSlashes($row->entity));
163 $this->setDate(ilUtil::stripSlashes($row->date));
164 $this->setDescription(ilUtil::stripSlashes($row->description));
165 $this->description_language =& new ilMDLanguageItem($row->description_language);
166 }
167 }
168 return true;
169 }
170
171 /*
172 * XML Export of all meta data
173 * @param object (xml writer) see class.ilMD2XML.php
174 *
175 */
176 function toXML(&$writer)
177 {
178 $writer->xmlStartTag('Annotation');
179 $writer->xmlElement('Entity',null,$this->getEntity());
180 $writer->xmlElement('Date',null,$this->getDate());
181 $writer->xmlElement('Description',array('Language' => $this->getDescriptionLanguageCode()),$this->getDescription());
182 $writer->xmlEndTag('Annotation');
183 }
184
185
186
187 // STATIC
188 function _getIds($a_rbac_id,$a_obj_id)
189 {
190 global $ilDB;
191
192 $query = "SELECT meta_annotation_id FROM il_meta_annotation ".
193 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
194 "AND obj_id = ".$ilDB->quote($a_obj_id);
195
196
197 $res = $ilDB->query($query);
198 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
199 {
200 $ids[] = $row->meta_annotation_id;
201 }
202 return $ids ? $ids : array();
203 }
204}
205?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
setDescriptionLanguage($lng_obj)
_getIds($a_rbac_id, $a_obj_id)
ilMDAnnotation($a_rbac_id=0, $a_obj_id=0, $a_obj_type='')
setObjId($a_id)
setMetaId($a_meta_id, $a_read_data=true)
setObjType($a_type)
setRBACId($a_id)
static prepareDBString($a_str)
prepare a string for db writing (insert/update)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $ilDB