ILIAS  release_8 Revision v8.24
ilMDRelation Class Reference
+ Inheritance diagram for ilMDRelation:
+ Collaboration diagram for ilMDRelation:

Public Member Functions

 getIdentifier_Ids ()
 
 getIdentifier_ (int $a_identifier__id)
 
 addIdentifier_ ()
 
 getDescriptionIds ()
 
 getDescription (int $a_description_id)
 
 addDescription ()
 
 setKind (string $a_kind)
 
 getKind ()
 
 save ()
 
 update ()
 
 delete ()
 
 __getFields ()
 
 read ()
 
 toXML (ilXmlWriter $writer)
 
- Public Member Functions inherited from ilMDBase
 __construct (int $a_rbac_id=0, int $a_obj_id=0, string $a_type='')
 constructor More...
 
 read ()
 
 setRBACId (int $a_id)
 
 getRBACId ()
 
 setObjId (int $a_id)
 
 getObjId ()
 
 setObjType (string $a_type)
 
 getObjType ()
 
 setMetaId (int $a_meta_id, bool $a_read_data=true)
 
 getMetaId ()
 
 setParentType (string $a_parent_type)
 
 getParentType ()
 
 setParentId (int $a_id)
 
 getParentId ()
 
 setExportMode (bool $a_export_mode=true)
 
 getExportMode ()
 
 validate ()
 
 update ()
 
 save ()
 
 delete ()
 
 toXML (ilXmlWriter $writer)
 

Static Public Member Functions

static _getIds (int $a_rbac_id, int $a_obj_id)
 

Private Attributes

string $kind = ''
 

Additional Inherited Members

- Protected Attributes inherited from ilMDBase
ilLogger $log
 
ilDBInterface $db
 

Detailed Description

Definition at line 26 of file class.ilMDRelation.php.

Member Function Documentation

◆ __getFields()

ilMDRelation::__getFields ( )
Returns
array<string, array<string, mixed>>

Definition at line 162 of file class.ilMDRelation.php.

162 : array
163 {
164 return array(
165 'rbac_id' => array('integer', $this->getRBACId()),
166 'obj_id' => array('integer', $this->getObjId()),
167 'obj_type' => array('text', $this->getObjType()),
168 'kind' => array('text', $this->getKind())
169 );
170 }

References getKind(), ilMDBase\getObjId(), ilMDBase\getObjType(), and ilMDBase\getRBACId().

Referenced by save(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getIds()

static ilMDRelation::_getIds ( int  $a_rbac_id,
int  $a_obj_id 
)
static
Returns
int[]

Definition at line 227 of file class.ilMDRelation.php.

227 : array
228 {
229 global $DIC;
230
231 $ilDB = $DIC->database();
232
233 $query = "SELECT meta_relation_id FROM il_meta_relation " .
234 "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
235 "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
236
237 $res = $ilDB->query($query);
238 $ids = [];
239 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
240 $ids[] = (int) $row->meta_relation_id;
241 }
242 return $ids;
243 }
global $DIC
Definition: feed.php:28
$res
Definition: ltiservices.php:69
$query

References $DIC, $ilDB, $query, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

Referenced by ilMD\getRelationIds().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addDescription()

ilMDRelation::addDescription ( )

Definition at line 79 of file class.ilMDRelation.php.

80 {
81 $des = new ilMDDescription($this->getRBACId(), $this->getObjId(), $this->getObjType());
82 $des->setParentId($this->getMetaId());
83 $des->setParentType('meta_relation');
84
85 return $des;
86 }

References ilMDBase\getMetaId(), ilMDBase\getObjId(), ilMDBase\getObjType(), and ilMDBase\getRBACId().

+ Here is the call graph for this function:

◆ addIdentifier_()

ilMDRelation::addIdentifier_ ( )

Definition at line 51 of file class.ilMDRelation.php.

52 {
53 $ide = new ilMDIdentifier_($this->getRBACId(), $this->getObjId(), $this->getObjType());
54 $ide->setParentId($this->getMetaId());
55 $ide->setParentType('meta_relation');
56
57 return $ide;
58 }

References ilMDBase\getMetaId(), ilMDBase\getObjId(), ilMDBase\getObjType(), and ilMDBase\getRBACId().

+ Here is the call graph for this function:

◆ delete()

ilMDRelation::delete ( )

Reimplemented from ilMDBase.

Definition at line 138 of file class.ilMDRelation.php.

138 : bool
139 {
140 if ($this->getMetaId()) {
141 $query = "DELETE FROM il_meta_relation " .
142 "WHERE meta_relation_id = " . $this->db->quote($this->getMetaId(), 'integer');
143 $res = $this->db->manipulate($query);
144
145 foreach ($this->getIdentifier_Ids() as $id) {
146 $ide = $this->getIdentifier_($id);
147 $ide->delete();
148 }
149 foreach ($this->getDescriptionIds() as $id) {
150 $des = $this->getDescription($id);
151 $des->delete();
152 }
153
154 return true;
155 }
156 return false;
157 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getDescription(int $a_description_id)
getIdentifier_(int $a_identifier__id)

References $id, $query, $res, getDescription(), getDescriptionIds(), getIdentifier_(), getIdentifier_Ids(), and ilMDBase\getMetaId().

+ Here is the call graph for this function:

◆ getDescription()

ilMDRelation::getDescription ( int  $a_description_id)

Definition at line 68 of file class.ilMDRelation.php.

69 {
70 if (!$a_description_id) {
71 return null;
72 }
73 $des = new ilMDDescription();
74 $des->setMetaId($a_description_id);
75
76 return $des;
77 }

Referenced by delete(), and toXML().

+ Here is the caller graph for this function:

◆ getDescriptionIds()

ilMDRelation::getDescriptionIds ( )
Returns
int[]

Definition at line 63 of file class.ilMDRelation.php.

63 : array
64 {
65 return ilMDDescription::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_relation');
66 }
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)

References ilMDDescription\_getIds(), ilMDBase\getMetaId(), ilMDBase\getObjId(), and ilMDBase\getRBACId().

Referenced by delete(), and toXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIdentifier_()

ilMDRelation::getIdentifier_ ( int  $a_identifier__id)

Definition at line 40 of file class.ilMDRelation.php.

41 {
42 if (!$a_identifier__id) {
43 return null;
44 }
45 $ide = new ilMDIdentifier_();
46 $ide->setMetaId($a_identifier__id);
47
48 return $ide;
49 }

Referenced by delete(), and toXML().

+ Here is the caller graph for this function:

◆ getIdentifier_Ids()

ilMDRelation::getIdentifier_Ids ( )
Returns
int[]

Definition at line 35 of file class.ilMDRelation.php.

35 : array
36 {
37 return ilMDIdentifier_::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_relation');
38 }
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)

References ilMDIdentifier_\_getIds(), ilMDBase\getMetaId(), ilMDBase\getObjId(), and ilMDBase\getRBACId().

Referenced by delete(), and toXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getKind()

ilMDRelation::getKind ( )

Definition at line 112 of file class.ilMDRelation.php.

112 : string
113 {
114 return $this->kind;
115 }

References $kind.

Referenced by __getFields(), and toXML().

+ Here is the caller graph for this function:

◆ read()

ilMDRelation::read ( )

Reimplemented from ilMDBase.

Definition at line 172 of file class.ilMDRelation.php.

172 : bool
173 {
174 if ($this->getMetaId()) {
175 $query = "SELECT * FROM il_meta_relation " .
176 "WHERE meta_relation_id = " . $this->db->quote($this->getMetaId(), 'integer');
177
178 $res = $this->db->query($query);
179 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
180 $this->setRBACId((int) $row->rbac_id);
181 $this->setObjId((int) $row->obj_id);
182 $this->setObjType($row->obj_type);
183 $this->setKind($row->kind ?? '');
184 }
185 }
186 return true;
187 }
setObjType(string $a_type)
setObjId(int $a_id)
setRBACId(int $a_id)
setKind(string $a_kind)

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, ilMDBase\getMetaId(), setKind(), ilMDBase\setObjId(), ilMDBase\setObjType(), and ilMDBase\setRBACId().

+ Here is the call graph for this function:

◆ save()

ilMDRelation::save ( )

Reimplemented from ilMDBase.

Definition at line 117 of file class.ilMDRelation.php.

117 : int
118 {
119 $fields = $this->__getFields();
120 $fields['meta_relation_id'] = array('integer', $next_id = $this->db->nextId('il_meta_relation'));
121
122 if ($this->db->insert('il_meta_relation', $fields)) {
123 $this->setMetaId($next_id);
124 return $this->getMetaId();
125 }
126 return 0;
127 }
setMetaId(int $a_meta_id, bool $a_read_data=true)

References __getFields(), ilMDBase\getMetaId(), and ilMDBase\setMetaId().

+ Here is the call graph for this function:

◆ setKind()

ilMDRelation::setKind ( string  $a_kind)

Definition at line 89 of file class.ilMDRelation.php.

89 : bool
90 {
91 switch ($a_kind) {
92 case 'IsPartOf':
93 case 'HasPart':
94 case 'IsVersionOf':
95 case 'HasVersion':
96 case 'IsFormatOf':
97 case 'HasFormat':
98 case 'References':
99 case 'IsReferencedBy':
100 case 'IsBasedOn':
101 case 'IsBasisFor':
102 case 'Requires':
103 case 'IsRequiredBy':
104 $this->kind = $a_kind;
105 return true;
106
107 default:
108 return false;
109 }
110 }

Referenced by read().

+ Here is the caller graph for this function:

◆ toXML()

ilMDRelation::toXML ( ilXmlWriter  $writer)

Reimplemented from ilMDBase.

Definition at line 189 of file class.ilMDRelation.php.

189 : void
190 {
191 $writer->xmlStartTag('Relation', array(
192 'Kind' => $this->getKind() ?: 'IsPartOf'
193 ));
194 $writer->xmlStartTag('Resource');
195
196 // Identifier_
197 $ides = $this->getIdentifier_Ids();
198 foreach ($ides as $id) {
199 $ide = $this->getIdentifier_($id);
200 $ide->toXML($writer);
201 }
202 if (!count($ides)) {
203 $ide = new ilMDIdentifier_($this->getRBACId(), $this->getObjId());
204 $ide->toXML($writer);
205 }
206
207 // Description
208 $dess = $this->getDescriptionIds();
209 foreach ($dess as $id) {
210 $des = $this->getDescription($id);
211 $des->toXML($writer);
212 }
213 if (!count($dess)) {
214 $des = new ilMDDescription($this->getRBACId(), $this->getObjId());
215 $des->toXML($writer);
216 }
217
218 $writer->xmlEndTag('Resource');
219 $writer->xmlEndTag('Relation');
220 }
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.

References $id, getDescription(), getDescriptionIds(), getIdentifier_(), getIdentifier_Ids(), getKind(), ilMDBase\getObjId(), ilMDBase\getRBACId(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

+ Here is the call graph for this function:

◆ update()

ilMDRelation::update ( )

Reimplemented from ilMDBase.

Definition at line 129 of file class.ilMDRelation.php.

129 : bool
130 {
131 return $this->getMetaId() && $this->db->update(
132 'il_meta_relation',
133 $this->__getFields(),
134 array("meta_relation_id" => array('integer', $this->getMetaId()))
135 );
136 }

References __getFields(), and ilMDBase\getMetaId().

+ Here is the call graph for this function:

Field Documentation

◆ $kind

string ilMDRelation::$kind = ''
private

Definition at line 28 of file class.ilMDRelation.php.

Referenced by getKind().


The documentation for this class was generated from the following file: