ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ 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
$DIC
;
125
126
$ilDB
= $DIC[
'ilDB'
];
127
128
$fields = $this->
__getFields
();
129
$fields[
'meta_relation_id'
] = array(
'integer'
,$next_id =
$ilDB
->nextId(
'il_meta_relation'
));
130
131
if
($this->db->insert(
'il_meta_relation'
, $fields)) {
132
$this->
setMetaId
($next_id);
133
return
$this->
getMetaId
();
134
}
135
return
false
;
136
}
137
138
public
function
update
()
139
{
140
global
$DIC
;
141
142
$ilDB
= $DIC[
'ilDB'
];
143
144
if
($this->
getMetaId
()) {
145
if
($this->db->update(
146
'il_meta_relation'
,
147
$this->__getFields(),
148
array(
"meta_relation_id"
=> array(
'integer'
,$this->
getMetaId
()))
149
)) {
150
return
true
;
151
}
152
}
153
return
false
;
154
}
155
156
public
function
delete
()
157
{
158
global
$DIC
;
159
160
$ilDB
= $DIC[
'ilDB'
];
161
162
if
($this->
getMetaId
()) {
163
$query
=
"DELETE FROM il_meta_relation "
.
164
"WHERE meta_relation_id = "
.
$ilDB
->quote($this->
getMetaId
(),
'integer'
);
165
$res
=
$ilDB
->manipulate(
$query
);
166
167
foreach
($this->
getIdentifier_Ids
() as
$id
) {
168
$ide = $this->
getIdentifier_
($id);
169
$ide->delete();
170
}
171
foreach
($this->
getDescriptionIds
() as $id) {
172
$des = $this->
getDescription
($id);
173
$des->delete();
174
}
175
176
return
true
;
177
}
178
return
false
;
179
}
180
181
182
public
function
__getFields
()
183
{
184
return
array(
'rbac_id'
=> array(
'integer'
,$this->
getRBACId
()),
185
'obj_id'
=> array(
'integer'
,$this->
getObjId
()),
186
'obj_type'
=> array(
'text'
,$this->
getObjType
()),
187
'kind'
=> array(
'text'
,$this->
getKind
()));
188
}
189
190
public
function
read
()
191
{
192
global
$DIC
;
193
194
$ilDB
= $DIC[
'ilDB'
];
195
196
if
($this->
getMetaId
()) {
197
$query
=
"SELECT * FROM il_meta_relation "
.
198
"WHERE meta_relation_id = "
.
$ilDB
->quote($this->
getMetaId
(),
'integer'
);
199
200
$res
= $this->db->query(
$query
);
201
while
(
$row
=
$res
->fetchRow(
ilDBConstants::FETCHMODE_OBJECT
)) {
202
$this->
setRBACId
(
$row
->rbac_id);
203
$this->
setObjId
(
$row
->obj_id);
204
$this->
setObjType
(
$row
->obj_type);
205
$this->
setKind
(
$row
->kind);
206
}
207
}
208
return
true
;
209
}
210
211
/*
212
* XML Export of all meta data
213
* @param object (xml writer) see class.ilMD2XML.php
214
*
215
*/
216
public
function
toXML
(&$writer)
217
{
218
$writer->xmlStartTag(
'Relation'
, array(
'Kind'
=> $this->
getKind
()
219
? $this->
getKind
()
220
:
'IsPartOf'
));
221
$writer->xmlStartTag(
'Resource'
);
222
223
// Identifier_
224
$ides = $this->
getIdentifier_Ids
();
225
foreach
($ides as
$id
) {
226
$ide = &$this->
getIdentifier_
($id);
227
$ide->toXML($writer);
228
}
229
if
(!count($ides)) {
230
include_once
'Services/MetaData/classes/class.ilMDIdentifier_.php'
;
231
$ide =
new
ilMDIdentifier_
($this->
getRBACId
(), $this->
getObjId
());
232
$ide->toXML($writer);
233
}
234
235
// Description
236
$dess = $this->
getDescriptionIds
();
237
foreach
($dess as $id) {
238
$des = &$this->
getDescription
($id);
239
$des->toXML($writer);
240
}
241
if
(!count($dess)) {
242
include_once
'Services/MetaData/classes/class.ilMDDescription.php'
;
243
$des =
new
ilMDDescription
($this->
getRBACId
(), $this->
getObjId
());
244
$des->toXML($writer);
245
}
246
247
$writer->xmlEndTag(
'Resource'
);
248
$writer->xmlEndTag(
'Relation'
);
249
}
250
251
252
253
// STATIC
254
public
static
function
_getIds
($a_rbac_id, $a_obj_id)
255
{
256
global
$DIC
;
257
258
$ilDB
= $DIC[
'ilDB'
];
259
260
$query
=
"SELECT meta_relation_id FROM il_meta_relation "
.
261
"WHERE rbac_id = "
.
$ilDB
->quote($a_rbac_id,
'integer'
) .
" "
.
262
"AND obj_id = "
.
$ilDB
->quote($a_obj_id,
'integer'
);
263
264
$res
=
$ilDB
->query(
$query
);
265
while
(
$row
=
$res
->fetchRow(
ilDBConstants::FETCHMODE_OBJECT
)) {
266
$ids[] =
$row
->meta_relation_id;
267
}
268
return
$ids ? $ids : array();
269
}
270
}
ilMDRelation\_getIds
static _getIds($a_rbac_id, $a_obj_id)
Definition:
class.ilMDRelation.php:254
ilMDIdentifier_
Definition:
class.ilMDIdentifier_.php:33
ilMDBase\setObjType
setObjType($a_type)
Definition:
class.ilMDBase.php:109
ilMDRelation\getIdentifier_
& getIdentifier_($a_identifier__id)
Definition:
class.ilMDRelation.php:42
$DIC
global $DIC
Definition:
saml.php:7
$id
if(!array_key_exists('StateId', $_REQUEST)) $id
Definition:
expirywarning.php:14
ilMDRelation\getKind
getKind()
Definition:
class.ilMDRelation.php:116
ilMDBase\getRBACId
getRBACId()
Definition:
class.ilMDBase.php:97
ilMDRelation
Definition:
class.ilMDRelation.php:33
ilMDRelation\__getFields
__getFields()
Definition:
class.ilMDRelation.php:182
ilMDDescription
Definition:
class.ilMDDescription.php:33
ilMDBase\setMetaId
setMetaId($a_meta_id, $a_read_data=true)
Definition:
class.ilMDBase.php:117
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
ilMDBase\setObjId
setObjId($a_id)
Definition:
class.ilMDBase.php:101
ilMDRelation\setKind
setKind($a_kind)
Definition:
class.ilMDRelation.php:94
ilMDBase\setRBACId
setRBACId($a_id)
Definition:
class.ilMDBase.php:93
$query
$query
Definition:
proxy_ylocal.php:13
ilMDRelation\getDescriptionIds
& getDescriptionIds()
Definition:
class.ilMDRelation.php:65
$row
$row
Definition:
migrateto20.php:360
ilMDBase\getMetaId
getMetaId()
Definition:
class.ilMDBase.php:125
ilMDRelation\save
save()
Definition:
class.ilMDRelation.php:122
ilMDRelation\toXML
toXML(&$writer)
Definition:
class.ilMDRelation.php:216
ilMDRelation\update
update()
Definition:
class.ilMDRelation.php:138
ilMDBase\getObjId
getObjId()
Definition:
class.ilMDBase.php:105
$ilDB
global $ilDB
Definition:
storeScorm2004.php:16
ilMDRelation\getIdentifier_Ids
& getIdentifier_Ids()
Definition:
class.ilMDRelation.php:36
ilMDIdentifier_\_getIds
static _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
Definition:
class.ilMDIdentifier_.php:152
php
ilMDBase\getObjType
getObjType()
Definition:
class.ilMDBase.php:113
ilDBConstants\FETCHMODE_OBJECT
const FETCHMODE_OBJECT
Definition:
class.ilDBConstants.php:13
ilMDBase
Definition:
class.ilMDBase.php:32
ilMDRelation\addDescription
& addDescription()
Definition:
class.ilMDRelation.php:83
ilMDRelation\addIdentifier_
& addIdentifier_()
Definition:
class.ilMDRelation.php:54
ilMDRelation\read
read()
Definition:
class.ilMDRelation.php:190
ilMDRelation\getDescription
& getDescription($a_description_id)
Definition:
class.ilMDRelation.php:71
Services
MetaData
classes
class.ilMDRelation.php
Generated on Thu Jan 16 2025 19:02:26 for ILIAS by
1.8.13 (using
Doxyfile
)