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