ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMDTaxon.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 ilMDTaxon extends ilMDBase
34 {
35  // SET/GET
36  function setTaxon($a_taxon)
37  {
38  $this->taxon = $a_taxon;
39  }
40  function getTaxon()
41  {
42  return $this->taxon;
43  }
44  function setTaxonLanguage(&$lng_obj)
45  {
46  if(is_object($lng_obj))
47  {
48  $this->taxon_language = $lng_obj;
49  }
50  }
51  function &getTaxonLanguage()
52  {
53  return is_object($this->taxon_language) ? $this->taxon_language : false;
54  }
56  {
57  return is_object($this->taxon_language) ? $this->taxon_language->getLanguageCode() : false;
58  }
59  function setTaxonId($a_taxon_id)
60  {
61  $this->taxon_id = $a_taxon_id;
62  }
63  function getTaxonId()
64  {
65  return $this->taxon_id;
66  }
67 
68 
69  function save()
70  {
71  if($this->db->autoExecute('il_meta_taxon',
72  $this->__getFields(),
74  {
75  $this->setMetaId($this->db->getLastInsertId());
76 
77  return $this->getMetaId();
78  }
79  return false;
80  }
81 
82  function update()
83  {
84  global $ilDB;
85 
86  if($this->getMetaId())
87  {
88  if($this->db->autoExecute('il_meta_taxon',
89  $this->__getFields(),
91  "meta_taxon_id = ".$ilDB->quote($this->getMetaId())))
92  {
93  return true;
94  }
95  }
96  return false;
97  }
98 
99  function delete()
100  {
101  if($this->getMetaId())
102  {
103  $query = "DELETE FROM il_meta_taxon ".
104  "WHERE meta_taxon_id = ".$ilDB->quote($this->getMetaId());
105 
106  $this->db->query($query);
107 
108  return true;
109  }
110  return false;
111  }
112 
113 
114  function __getFields()
115  {
116  return array('rbac_id' => $this->getRBACId(),
117  'obj_id' => $this->getObjId(),
118  'obj_type' => ilUtil::prepareDBString($this->getObjType()),
119  'parent_type' => $this->getParentType(),
120  'parent_id' => $this->getParentId(),
121  'taxon' => ilUtil::prepareDBString($this->getTaxon()),
122  'taxon_language' => ilUtil::prepareDBString($this->getTaxonLanguageCode()),
123  'taxon_id' => ilUtil::prepareDBString($this->getTaxonId()));
124  }
125 
126  function read()
127  {
128  global $ilDB;
129 
130  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLanguageItem.php';
131 
132  if($this->getMetaId())
133  {
134  $query = "SELECT * FROM il_meta_taxon ".
135  "WHERE meta_taxon_id = ".$ilDB->quote($this->getMetaId());
136 
137  $res = $this->db->query($query);
138  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
139  {
140  $this->setRBACId($row->rbac_id);
141  $this->setObjId($row->obj_id);
142  $this->setObjType($row->obj_type);
143  $this->setParentId($row->parent_id);
144  $this->setParentType($row->parent_type);
145  $this->setTaxon(ilUtil::stripSlashes($row->taxon));
146  $this->taxon_language = new ilMDLanguageItem($row->taxon_language);
147  $this->setTaxonId(ilUtil::stripSlashes($row->taxon_id));
148  }
149  }
150  return true;
151  }
152 
153  /*
154  * XML Export of all meta data
155  * @param object (xml writer) see class.ilMD2XML.php
156  *
157  */
158  function toXML(&$writer)
159  {
160  $writer->xmlElement('Taxon',array('Language' => $this->getTaxonLanguageCode(),
161  'Id' => $this->getTaxonId()),$this->getTaxon());
162  }
163 
164 
165  // STATIC
166  function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
167  {
168  global $ilDB;
169 
170  $query = "SELECT meta_taxon_id FROM il_meta_taxon ".
171  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
172  "AND obj_id = ".$ilDB->quote($a_obj_id)." ".
173  "AND parent_id = ".$ilDB->quote($a_parent_id)." ".
174  "AND parent_type = ".$ilDB->quote($a_parent_type);
175 
176 
177  $res = $ilDB->query($query);
178  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
179  {
180  $ids[] = $row->meta_taxon_id;
181  }
182  return $ids ? $ids : array();
183  }
184 }
185 ?>
setObjType($a_type)
setTaxonLanguage(&$lng_obj)
_getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
setTaxon($a_taxon)
setTaxonId($a_taxon_id)
setMetaId($a_meta_id, $a_read_data=true)
setObjId($a_id)
setRBACId($a_id)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
setParentId($a_id)
toXML(&$writer)
static prepareDBString($a_str)
prepare a string for db writing (insert/update)
global $ilDB
setParentType($a_parent_type)
& getTaxonLanguage()