ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 // SET/GET
36 function setCatalog($a_catalog)
37 {
38 $this->catalog = $a_catalog;
39 }
40 function getCatalog()
41 {
42 return $this->catalog;
43 }
44 function setEntry($a_entry)
45 {
46 $this->entry = $a_entry;
47 }
48 function getEntry()
49 {
50 return $this->entry;
51 }
52
53
54 function save()
55 {
56 if($this->db->autoExecute('il_meta_identifier_',
57 $this->__getFields(),
59 {
60 $this->setMetaId($this->db->getLastInsertId());
61
62 return $this->getMetaId();
63 }
64 return false;
65 }
66
67 function update()
68 {
69 global $ilDB;
70
71 if($this->getMetaId())
72 {
73 if($this->db->autoExecute('il_meta_identifier_',
74 $this->__getFields(),
76 "meta_identifier__id = ".$ilDB->quote($this->getMetaId())))
77 {
78 return true;
79 }
80 }
81 return false;
82 }
83
84 function delete()
85 {
86 global $ilDB;
87
88 if($this->getMetaId())
89 {
90 $query = "DELETE FROM il_meta_identifier_ ".
91 "WHERE meta_identifier__id = ".$ilDB->quote($this->getMetaId());
92
93 $this->db->query($query);
94
95 return true;
96 }
97 return false;
98 }
99
100
101 function __getFields()
102 {
103 return array('rbac_id' => $this->getRBACId(),
104 'obj_id' => $this->getObjId(),
105 'obj_type' => ilUtil::prepareDBString($this->getObjType()),
106 'parent_type' => $this->getParentType(),
107 'parent_id' => $this->getParentId(),
108 'catalog' => ilUtil::prepareDBString($this->getCatalog()),
109 'entry' => ilUtil::prepareDBString($this->getEntry()));
110
111 }
112
113 function read()
114 {
115 global $ilDB;
116
117 if($this->getMetaId())
118 {
119 $query = "SELECT * FROM il_meta_identifier_ ".
120 "WHERE meta_identifier__id = ".$ilDB->quote($this->getMetaId());
121
122 $res = $this->db->query($query);
123 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
124 {
125 $this->setRBACId($row->rbac_id);
126 $this->setObjId($row->obj_id);
127 $this->setObjType($row->obj_type);
128 $this->setParentId($row->parent_id);
129 $this->setParentType($row->parent_type);
130 $this->setCatalog(ilUtil::stripSlashes($row->catalog));
131 $this->setEntry(ilUtil::stripSlashes($row->entry));
132 }
133 }
134 return true;
135 }
136
137 /*
138 * XML Export of all meta data
139 * @param object (xml writer) see class.ilMD2XML.php
140 *
141 */
142 function toXML(&$writer)
143 {
144 $writer->xmlElement('Identifier_',array('Catalog' => $this->getCatalog(),
145 'Entry' => $this->getEntry()));
146 }
147
148
149 // STATIC
150 function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
151 {
152 global $ilDB;
153
154 $query = "SELECT meta_identifier__id FROM il_meta_identifier_ ".
155 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
156 "AND obj_id = ".$ilDB->quote($a_obj_id)." ".
157 "AND parent_id = ".$ilDB->quote($a_parent_id)." ".
158 "AND parent_type = ".$ilDB->quote($a_parent_type);
159
160
161 $res = $ilDB->query($query);
162 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
163 {
164 $ids[] = $row->meta_identifier__id;
165 }
166 return $ids ? $ids : array();
167 }
168}
169?>
An exception for terminatinating execution or to throw for unit testing.
setObjId($a_id)
setParentId($a_id)
setMetaId($a_meta_id, $a_read_data=true)
setObjType($a_type)
setRBACId($a_id)
setParentType($a_parent_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