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