ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilMDIdentifier_.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
34{
35 function ilMDIdentifier_($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 setCatalog($a_catalog)
44 {
45 $this->catalog = $a_catalog;
46 }
47 function getCatalog()
48 {
49 return $this->catalog;
50 }
51 function setEntry($a_entry)
52 {
53 $this->entry = $a_entry;
54 }
55 function getEntry()
56 {
57 return $this->entry;
58 }
59
60
61 function save()
62 {
63 global $ilDB;
64
65 $fields = $this->__getFields();
66 $fields['meta_identifier__id'] = array('integer',$next_id = $ilDB->nextId('il_meta_identifier_'));
67
68 if($this->db->insert('il_meta_identifier_',$fields))
69 {
70 $this->setMetaId($next_id);
71 return $this->getMetaId();
72 }
73 return false;
74 }
75
76 function update()
77 {
78 global $ilDB;
79
80 if($this->getMetaId())
81 {
82 if($this->db->update('il_meta_identifier_',
83 $this->__getFields(),
84 array("meta_identifier__id" => array('integer',$this->getMetaId()))))
85 {
86 return true;
87 }
88 }
89 return false;
90 }
91
92 function delete()
93 {
94 global $ilDB;
95
96 if($this->getMetaId())
97 {
98 $query = "DELETE FROM il_meta_identifier_ ".
99 "WHERE meta_identifier__id = ".$ilDB->quote($this->getMetaId() ,'integer');
100 $res = $ilDB->manipulate($query);
101 return true;
102 }
103 return false;
104 }
105
106
107 function __getFields()
108 {
109 return array('rbac_id' => array('integer',$this->getRBACId()),
110 'obj_id' => array('integer',$this->getObjId()),
111 'obj_type' => array('text',$this->getObjType()),
112 'parent_type' => array('text',$this->getParentType()),
113 'parent_id' => array('integer',$this->getParentId()),
114 'catalog' => array('text',$this->getCatalog()),
115 'entry' => array('text',$this->getEntry()));
116 }
117
118 function read()
119 {
120 global $ilDB;
121
122 if($this->getMetaId())
123 {
124 $query = "SELECT * FROM il_meta_identifier_ ".
125 "WHERE meta_identifier__id = ".$ilDB->quote($this->getMetaId() ,'integer');
126
127 $res = $this->db->query($query);
128 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
129 {
130 $this->setRBACId($row->rbac_id);
131 $this->setObjId($row->obj_id);
132 $this->setObjType($row->obj_type);
133 $this->setParentId($row->parent_id);
134 $this->setParentType($row->parent_type);
135 $this->setCatalog($row->catalog);
136 $this->setEntry($row->entry);
137 }
138 }
139 return true;
140 }
141
142 /*
143 * XML Export of all meta data
144 * @param object (xml writer) see class.ilMD2XML.php
145 *
146 */
147 function toXML(&$writer)
148 {
149 $writer->xmlElement('Identifier_',array('Catalog' => $this->getCatalog(),
150 'Entry' => $this->getEntry() ? $this->getEntry() : "ID1"));
151 }
152
153
154 // STATIC
155 function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
156 {
157 global $ilDB;
158
159 $query = "SELECT meta_identifier__id FROM il_meta_identifier_ ".
160 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,'integer')." ".
161 "AND obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ".
162 "AND parent_id = ".$ilDB->quote($a_parent_id ,'integer')." ".
163 "AND parent_type = ".$ilDB->quote($a_parent_type ,'text');
164
165
166 $res = $ilDB->query($query);
167 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
168 {
169 $ids[] = $row->meta_identifier__id;
170 }
171 return $ids ? $ids : array();
172 }
173}
174?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
setObjId($a_id)
setParentId($a_id)
setMetaId($a_meta_id, $a_read_data=true)
setObjType($a_type)
setRBACId($a_id)
setParentType($a_parent_type)
ilMDIdentifier_($a_rbac_id=0, $a_obj_id=0, $a_obj_type='')
_getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
global $ilDB