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