ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 // SET/GET
36 function setEntity($a_entity)
37 {
38 $this->entity = $a_entity;
39 }
40 function getEntity()
41 {
42 return $this->entity;
43 }
44 function setDate($a_date)
45 {
46 $this->date = $a_date;
47 }
48 function getDate()
49 {
50 return $this->date;
51 }
52 function setDescription($a_desc)
53 {
54 $this->description = $a_desc;
55 }
56 function getDescription()
57 {
58 return $this->description;
59 }
60 function setDescriptionLanguage($lng_obj)
61 {
62 if(is_object($lng_obj))
63 {
64 $this->description_language =& $lng_obj;
65 }
66 }
68 {
69 return $this->description_language;
70 }
72 {
73 if(is_object($this->description_language))
74 {
75 return $this->description_language->getLanguageCode();
76 }
77 return false;
78 }
79
80 function save()
81 {
82 if($this->db->autoExecute('il_meta_annotation',
83 $this->__getFields(),
85 {
86 $this->setMetaId($this->db->getLastInsertId());
87
88 return $this->getMetaId();
89 }
90 return false;
91 }
92
93 function update()
94 {
95 global $ilDB;
96
97 if($this->getMetaId())
98 {
99 if($this->db->autoExecute('il_meta_annotation',
100 $this->__getFields(),
102 "meta_annotation_id = ".$ilDB->quote($this->getMetaId())))
103 {
104 return true;
105 }
106 }
107 return false;
108 }
109
110 function delete()
111 {
112 global $ilDB;
113
114 if($this->getMetaId())
115 {
116 $query = "DELETE FROM il_meta_annotation ".
117 "WHERE meta_annotation_id = ".$ilDB->quote($this->getMetaId());
118
119 $this->db->query($query);
120
121 return true;
122 }
123 return false;
124 }
125
126
127 function __getFields()
128 {
129 return array('rbac_id' => $this->getRBACId(),
130 'obj_id' => $this->getObjId(),
131 'obj_type' => ilUtil::prepareDBString($this->getObjType()),
132 'entity' => ilUtil::prepareDBString($this->getEntity()),
133 'date' => ilUtil::prepareDBString($this->getDate()),
134 'description' => ilUtil::prepareDBString($this->getDescription()),
135 'description_language' => ilUtil::prepareDBString($this->getDescriptionLanguageCode()));
136 }
137
138 function read()
139 {
140 global $ilDB;
141
142 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLanguageItem.php';
143
144 if($this->getMetaId())
145 {
146 $query = "SELECT * FROM il_meta_annotation ".
147 "WHERE meta_annotation_id = ".$ilDB->quote($this->getMetaId());
148
149 $res = $this->db->query($query);
150 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
151 {
152 $this->setRBACId($row->rbac_id);
153 $this->setObjId($row->obj_id);
154 $this->setObjType($row->obj_type);
155 $this->setEntity(ilUtil::stripSlashes($row->entity));
156 $this->setDate(ilUtil::stripSlashes($row->date));
157 $this->setDescription(ilUtil::stripSlashes($row->description));
158 $this->description_language = new ilMDLanguageItem($row->description_language);
159 }
160 }
161 return true;
162 }
163
164 /*
165 * XML Export of all meta data
166 * @param object (xml writer) see class.ilMD2XML.php
167 *
168 */
169 function toXML(&$writer)
170 {
171 $writer->xmlStartTag('Annotation');
172 $writer->xmlElement('Entity',null,$this->getEntity());
173 $writer->xmlElement('Date',null,$this->getDate());
174 $writer->xmlElement('Description',array('Language' => $this->getDescriptionLanguageCode()),$this->getDescription());
175 $writer->xmlEndTag('Annotation');
176 }
177
178
179
180 // STATIC
181 function _getIds($a_rbac_id,$a_obj_id)
182 {
183 global $ilDB;
184
185 $query = "SELECT meta_annotation_id FROM il_meta_annotation ".
186 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
187 "AND obj_id = ".$ilDB->quote($a_obj_id);
188
189
190 $res = $ilDB->query($query);
191 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
192 {
193 $ids[] = $row->meta_annotation_id;
194 }
195 return $ids ? $ids : array();
196 }
197}
198?>
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
setDescriptionLanguage($lng_obj)
_getIds($a_rbac_id, $a_obj_id)
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