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
33class ilMDIdentifier_ extends ilMDBase
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 if($this->db->autoExecute('il_meta_identifier_',
64 $this->__getFields(),
65 DB_AUTOQUERY_INSERT))
66 {
67 $this->setMetaId($this->db->getLastInsertId());
68
69 return $this->getMetaId();
70 }
71 return false;
72 }
73
74 function update()
75 {
76 global $ilDB;
77
78 if($this->getMetaId())
79 {
80 if($this->db->autoExecute('il_meta_identifier_',
81 $this->__getFields(),
82 DB_AUTOQUERY_UPDATE,
83 "meta_identifier__id = ".$ilDB->quote($this->getMetaId())))
84 {
85 return true;
86 }
87 }
88 return false;
89 }
90
91 function delete()
92 {
93 global $ilDB;
94
95 if($this->getMetaId())
96 {
97 $query = "DELETE FROM il_meta_identifier_ ".
98 "WHERE meta_identifier__id = ".$ilDB->quote($this->getMetaId());
99
100 $this->db->query($query);
101
102 return true;
103 }
104 return false;
105 }
106
107
108 function __getFields()
109 {
110 return array('rbac_id' => $this->getRBACId(),
111 'obj_id' => $this->getObjId(),
112 'obj_type' => ilUtil::prepareDBString($this->getObjType()),
113 'parent_type' => $this->getParentType(),
114 'parent_id' => $this->getParentId(),
115 'catalog' => ilUtil::prepareDBString($this->getCatalog()),
116 'entry' => ilUtil::prepareDBString($this->getEntry()));
117
118 }
119
120 function read()
121 {
122 global $ilDB;
123
124 if($this->getMetaId())
125 {
126 $query = "SELECT * FROM il_meta_identifier_ ".
127 "WHERE meta_identifier__id = ".$ilDB->quote($this->getMetaId());
128
129 $res = $this->db->query($query);
130 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
131 {
132 $this->setRBACId($row->rbac_id);
133 $this->setObjId($row->obj_id);
134 $this->setObjType($row->obj_type);
135 $this->setParentId($row->parent_id);
136 $this->setParentType($row->parent_type);
137 $this->setCatalog(ilUtil::stripSlashes($row->catalog));
138 $this->setEntry(ilUtil::stripSlashes($row->entry));
139 }
140 }
141 return true;
142 }
143
144 /*
145 * XML Export of all meta data
146 * @param object (xml writer) see class.ilMD2XML.php
147 *
148 */
149 function toXML(&$writer)
150 {
151 $writer->xmlElement('Identifier_',array('Catalog' => $this->getCatalog(),
152 'Entry' => $this->getEntry()));
153 }
154
155
156 // STATIC
157 function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
158 {
159 global $ilDB;
160
161 $query = "SELECT meta_identifier__id FROM il_meta_identifier_ ".
162 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
163 "AND obj_id = ".$ilDB->quote($a_obj_id)." ".
164 "AND parent_id = ".$ilDB->quote($a_parent_id)." ".
165 "AND parent_type = ".$ilDB->quote($a_parent_type);
166
167
168 $res = $ilDB->query($query);
169 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
170 {
171 $ids[] = $row->meta_identifier__id;
172 }
173 return $ids ? $ids : array();
174 }
175}
176?>
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)
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