ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMDEntity.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 
32 include_once 'class.ilMDBase.php';
33 
34 class ilMDEntity extends ilMDBase
35 {
36  // SET/GET
37  function setEntity($a_entity)
38  {
39  $this->entity = $a_entity;
40  }
41  function getEntity()
42  {
43  return $this->entity;
44  }
45 
46  function save()
47  {
48  global $ilDB;
49 
50  $fields = $this->__getFields();
51  $fields['meta_entity_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_entity'));
52 
53  if($this->db->insert('il_meta_entity',$fields))
54  {
55  $this->setMetaId($next_id);
56  return $this->getMetaId();
57  }
58  return false;
59  }
60 
61  function update()
62  {
63  global $ilDB;
64 
65  if($this->getMetaId())
66  {
67  if($this->db->update('il_meta_entity',
68  $this->__getFields(),
69  array("meta_entity_id" => array('integer',$this->getMetaId()))))
70  {
71  return true;
72  }
73  }
74  return false;
75  }
76 
77  function delete()
78  {
79  global $ilDB;
80 
81  if($this->getMetaId())
82  {
83  $query = "DELETE FROM il_meta_entity ".
84  "WHERE meta_entity_id = ".$ilDB->quote($this->getMetaId(),'integer');
85  $res = $ilDB->manipulate($query);
86 
87  $this->db->query($query);
88 
89  return true;
90  }
91  return false;
92  }
93 
94 
95  function __getFields()
96  {
97  return array('rbac_id' => array('integer',$this->getRBACId()),
98  'obj_id' => array('integer',$this->getObjId()),
99  'obj_type' => array('text',$this->getObjType()),
100  'parent_type' => array('text',$this->getParentType()),
101  'parent_id' => array('integer',$this->getParentId()),
102  'entity' => array('text',$this->getEntity()));
103  }
104 
105  function read()
106  {
107  global $ilDB;
108 
109  if($this->getMetaId())
110  {
111  $query = "SELECT * FROM il_meta_entity ".
112  "WHERE meta_entity_id = ".$ilDB->quote($this->getMetaId() ,'integer');
113 
114  $res = $this->db->query($query);
115  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
116  {
117  $this->setRBACId($row->rbac_id);
118  $this->setObjId($row->obj_id);
119  $this->setObjType($row->obj_type);
120  $this->setParentId($row->parent_id);
121  $this->setParentType($row->parent_type);
122  $this->setEntity($row->entity);
123  }
124  }
125  return true;
126  }
127 
128  /*
129  * XML Export of all meta data
130  * @param object (xml writer) see class.ilMD2XML.php
131  *
132  */
133  function toXML(&$writer)
134  {
135  $writer->xmlElement('Entity',null,$this->getEntity());
136  }
137 
138 
139  // STATIC
140  public static function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
141  {
142  global $ilDB;
143 
144  $query = "SELECT meta_entity_id FROM il_meta_entity ".
145  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,'integer')." ".
146  "AND obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ".
147  "AND parent_id = ".$ilDB->quote($a_parent_id ,'integer')." ".
148  "AND parent_type = ".$ilDB->quote($a_parent_type ,'text')." ".
149  "ORDER BY meta_entity_id ";
150 
151  $res = $ilDB->query($query);
152  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
153  {
154  $ids[] = $row->meta_entity_id;
155  }
156  return $ids ? $ids : array();
157  }
158 }
159 ?>
setObjType($a_type)
toXML(&$writer)
static _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
setMetaId($a_meta_id, $a_read_data=true)
setObjId($a_id)
setRBACId($a_id)
Create styles array
The data for the language used.
setParentId($a_id)
global $ilDB
setParentType($a_parent_type)
setEntity($a_entity)