ILIAS
release_5-3 Revision v5.3.23-19-g915713cf615
◀ ilDoc Overview
class.ilMDRelation.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
31
include_once
'class.ilMDBase.php'
;
32
33
class
ilMDRelation
extends
ilMDBase
34
{
35
// METHODS OF CHILD OBJECTS (Taxon)
36
public
function
&
getIdentifier_Ids
()
37
{
38
include_once
'Services/MetaData/classes/class.ilMDIdentifier_.php'
;
39
40
return
ilMDIdentifier_::_getIds
($this->
getRBACId
(), $this->
getObjId
(), $this->
getMetaId
(),
'meta_relation'
);
41
}
42
public
function
&
getIdentifier_
($a_identifier__id)
43
{
44
include_once
'Services/MetaData/classes/class.ilMDIdentifier_.php'
;
45
46
if
(!$a_identifier__id) {
47
return
false
;
48
}
49
$ide =
new
ilMDIdentifier_
();
50
$ide->setMetaId($a_identifier__id);
51
52
return
$ide;
53
}
54
public
function
&
addIdentifier_
()
55
{
56
include_once
'Services/MetaData/classes/class.ilMDIdentifier_.php'
;
57
58
$ide =
new
ilMDIdentifier_
($this->
getRBACId
(), $this->
getObjId
(), $this->
getObjType
());
59
$ide->setParentId($this->
getMetaId
());
60
$ide->setParentType(
'meta_relation'
);
61
62
return
$ide;
63
}
64
65
public
function
&
getDescriptionIds
()
66
{
67
include_once
'Services/MetaData/classes/class.ilMDDescription.php'
;
68
69
return
ilMdDescription::_getIds($this->
getRBACId
(), $this->
getObjId
(), $this->
getMetaId
(),
'meta_relation'
);
70
}
71
public
function
&
getDescription
($a_description_id)
72
{
73
include_once
'Services/MetaData/classes/class.ilMDDescription.php'
;
74
75
if
(!$a_description_id) {
76
return
false
;
77
}
78
$des =
new
ilMDDescription
();
79
$des->setMetaId($a_description_id);
80
81
return
$des;
82
}
83
public
function
&
addDescription
()
84
{
85
include_once
'Services/MetaData/classes/class.ilMDDescription.php'
;
86
87
$des =
new
ilMDDescription
($this->
getRBACId
(), $this->
getObjId
(), $this->
getObjType
());
88
$des->setParentId($this->
getMetaId
());
89
$des->setParentType(
'meta_relation'
);
90
91
return
$des;
92
}
93
// SET/GET
94
public
function
setKind
($a_kind)
95
{
96
switch
($a_kind) {
97
case
'IsPartOf'
:
98
case
'HasPart'
:
99
case
'IsVersionOf'
:
100
case
'HasVersion'
:
101
case
'IsFormatOf'
:
102
case
'HasFormat'
:
103
case
'References'
:
104
case
'IsReferencedBy'
:
105
case
'IsBasedOn'
:
106
case
'IsBasisFor'
:
107
case
'Requires'
:
108
case
'IsRequiredBy'
:
109
$this->kind = $a_kind;
110
return
true
;
111
112
default
:
113
return
false
;
114
}
115
}
116
public
function
getKind
()
117
{
118
return
$this->kind;
119
}
120
121
122
public
function
save
()
123
{
124
global
$ilDB
;
125
126
$fields = $this->
__getFields
();
127
$fields[
'meta_relation_id'
] = array(
'integer'
,$next_id =
$ilDB
->nextId(
'il_meta_relation'
));
128
129
if
($this->db->insert(
'il_meta_relation'
, $fields)) {
130
$this->
setMetaId
($next_id);
131
return
$this->
getMetaId
();
132
}
133
return
false
;
134
}
135
136
public
function
update
()
137
{
138
global
$ilDB
;
139
140
if
($this->
getMetaId
()) {
141
if
($this->db->update(
142
'il_meta_relation'
,
143
$this->__getFields(),
144
array(
"meta_relation_id"
=> array(
'integer'
,$this->
getMetaId
()))
145
)) {
146
return
true
;
147
}
148
}
149
return
false
;
150
}
151
152
public
function
delete
()
153
{
154
global
$ilDB
;
155
156
if
($this->
getMetaId
()) {
157
$query
=
"DELETE FROM il_meta_relation "
.
158
"WHERE meta_relation_id = "
. $ilDB->quote($this->
getMetaId
(),
'integer'
);
159
$res
= $ilDB->manipulate(
$query
);
160
161
foreach
($this->
getIdentifier_Ids
() as
$id
) {
162
$ide = $this->
getIdentifier_
(
$id
);
163
$ide->delete();
164
}
165
foreach
($this->
getDescriptionIds
() as
$id
) {
166
$des = $this->
getDescription
($id);
167
$des->delete();
168
}
169
170
return
true
;
171
}
172
return
false
;
173
}
174
175
176
public
function
__getFields
()
177
{
178
return
array(
'rbac_id'
=> array(
'integer'
,$this->
getRBACId
()),
179
'obj_id'
=> array(
'integer'
,$this->
getObjId
()),
180
'obj_type'
=> array(
'text'
,$this->
getObjType
()),
181
'kind'
=> array(
'text'
,$this->
getKind
()));
182
}
183
184
public
function
read
()
185
{
186
global
$ilDB
;
187
188
if
($this->
getMetaId
()) {
189
$query
=
"SELECT * FROM il_meta_relation "
.
190
"WHERE meta_relation_id = "
. $ilDB->quote($this->
getMetaId
(),
'integer'
);
191
192
$res
= $this->db->query(
$query
);
193
while
(
$row
=
$res
->fetchRow(
ilDBConstants::FETCHMODE_OBJECT
)) {
194
$this->
setRBACId
(
$row
->rbac_id);
195
$this->
setObjId
(
$row
->obj_id);
196
$this->
setObjType
(
$row
->obj_type);
197
$this->
setKind
(
$row
->kind);
198
}
199
}
200
return
true
;
201
}
202
203
/*
204
* XML Export of all meta data
205
* @param object (xml writer) see class.ilMD2XML.php
206
*
207
*/
208
public
function
toXML
(&$writer)
209
{
210
$writer->xmlStartTag(
'Relation'
, array(
'Kind'
=> $this->
getKind
()
211
? $this->
getKind
()
212
:
'IsPartOf'
));
213
$writer->xmlStartTag(
'Resource'
);
214
215
// Identifier_
216
$ides = $this->
getIdentifier_Ids
();
217
foreach
($ides as
$id
) {
218
$ide =&$this->
getIdentifier_
($id);
219
$ide->toXML($writer);
220
}
221
if
(!count($ides)) {
222
include_once
'Services/MetaData/classes/class.ilMDIdentifier_.php'
;
223
$ide =
new
ilMDIdentifier_
($this->
getRBACId
(), $this->
getObjId
());
224
$ide->toXML($writer);
225
}
226
227
// Description
228
$dess = $this->
getDescriptionIds
();
229
foreach
($dess as
$id
) {
230
$des =&$this->
getDescription
($id);
231
$des->toXML($writer);
232
}
233
if
(!count($dess)) {
234
include_once
'Services/MetaData/classes/class.ilMDDescription.php'
;
235
$des =
new
ilMDDescription
($this->
getRBACId
(), $this->
getObjId
());
236
$des->toXML($writer);
237
}
238
239
$writer->xmlEndTag(
'Resource'
);
240
$writer->xmlEndTag(
'Relation'
);
241
}
242
243
244
245
// STATIC
246
public
static
function
_getIds
($a_rbac_id, $a_obj_id)
247
{
248
global
$ilDB
;
249
250
$query
=
"SELECT meta_relation_id FROM il_meta_relation "
.
251
"WHERE rbac_id = "
.
$ilDB
->quote($a_rbac_id,
'integer'
) .
" "
.
252
"AND obj_id = "
.
$ilDB
->quote($a_obj_id,
'integer'
);
253
254
$res
=
$ilDB
->query(
$query
);
255
while
(
$row
=
$res
->fetchRow(
ilDBConstants::FETCHMODE_OBJECT
)) {
256
$ids[] =
$row
->meta_relation_id;
257
}
258
return
$ids ? $ids : array();
259
}
260
}
$row
$row
Definition:
10autofilter-selection-1.php:74
php
An exception for terminatinating execution or to throw for unit testing.
ilDBConstants\FETCHMODE_OBJECT
const FETCHMODE_OBJECT
Definition:
class.ilDBConstants.php:13
ilMDBase
Definition:
class.ilMDBase.php:33
ilMDBase\getObjType
getObjType()
Definition:
class.ilMDBase.php:111
ilMDBase\getMetaId
getMetaId()
Definition:
class.ilMDBase.php:123
ilMDBase\setObjId
setObjId($a_id)
Definition:
class.ilMDBase.php:99
ilMDBase\setMetaId
setMetaId($a_meta_id, $a_read_data=true)
Definition:
class.ilMDBase.php:115
ilMDBase\getRBACId
getRBACId()
Definition:
class.ilMDBase.php:95
ilMDBase\getObjId
getObjId()
Definition:
class.ilMDBase.php:103
ilMDBase\setObjType
setObjType($a_type)
Definition:
class.ilMDBase.php:107
ilMDBase\setRBACId
setRBACId($a_id)
Definition:
class.ilMDBase.php:91
ilMDDescription
Definition:
class.ilMDDescription.php:34
ilMDIdentifier_
Definition:
class.ilMDIdentifier_.php:34
ilMDIdentifier_\_getIds
static _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
Definition:
class.ilMDIdentifier_.php:144
ilMDRelation
Definition:
class.ilMDRelation.php:34
ilMDRelation\setKind
setKind($a_kind)
Definition:
class.ilMDRelation.php:94
ilMDRelation\getIdentifier_
& getIdentifier_($a_identifier__id)
Definition:
class.ilMDRelation.php:42
ilMDRelation\addDescription
& addDescription()
Definition:
class.ilMDRelation.php:83
ilMDRelation\read
read()
Definition:
class.ilMDRelation.php:184
ilMDRelation\getKind
getKind()
Definition:
class.ilMDRelation.php:116
ilMDRelation\update
update()
Definition:
class.ilMDRelation.php:136
ilMDRelation\getIdentifier_Ids
& getIdentifier_Ids()
Definition:
class.ilMDRelation.php:36
ilMDRelation\getDescription
& getDescription($a_description_id)
Definition:
class.ilMDRelation.php:71
ilMDRelation\_getIds
static _getIds($a_rbac_id, $a_obj_id)
Definition:
class.ilMDRelation.php:246
ilMDRelation\getDescriptionIds
& getDescriptionIds()
Definition:
class.ilMDRelation.php:65
ilMDRelation\toXML
toXML(&$writer)
Definition:
class.ilMDRelation.php:208
ilMDRelation\__getFields
__getFields()
Definition:
class.ilMDRelation.php:176
ilMDRelation\save
save()
Definition:
class.ilMDRelation.php:122
ilMDRelation\addIdentifier_
& addIdentifier_()
Definition:
class.ilMDRelation.php:54
$id
if(!array_key_exists('StateId', $_REQUEST)) $id
Definition:
expirywarning.php:14
$query
$query
Definition:
proxy_ylocal.php:13
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
$ilDB
global $ilDB
Definition:
storeScorm2004.php:19
Services
MetaData
classes
class.ilMDRelation.php
Generated on Tue Sep 30 2025 19:01:16 for ILIAS by
1.9.4 (using
Doxyfile
)