ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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

const KIND_TRANSLATION
 Compatibility fix for legacy MD classes for new db tables. More...
 
const string $kind = ''
 

Additional Inherited Members

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

Detailed Description

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

Member Function Documentation

◆ __getFields()

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

Compatibility fix for legacy MD classes for new db tables

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

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

Referenced by save(), and update().

181  : array
182  {
186  $kind = (string) array_search(
187  $this->getKind(),
188  self::KIND_TRANSLATION
189  );
190 
191  return array(
192  'rbac_id' => array('integer', $this->getRBACId()),
193  'obj_id' => array('integer', $this->getObjId()),
194  'obj_type' => array('text', $this->getObjType()),
195  'kind' => array('text', $kind)
196  );
197  }
const string $kind
+ 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 261 of file class.ilMDRelation.php.

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

Referenced by ilMD\getRelationIds().

261  : array
262  {
263  global $DIC;
264 
265  $ilDB = $DIC->database();
266 
267  $query = "SELECT meta_relation_id FROM il_meta_relation " .
268  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
269  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
270 
271  $res = $ilDB->query($query);
272  $ids = [];
273  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
274  $ids[] = (int) $row->meta_relation_id;
275  }
276  return $ids;
277  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addDescription()

ilMDRelation::addDescription ( )

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

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

99  {
100  $des = new ilMDDescription($this->getRBACId(), $this->getObjId(), $this->getObjType());
101  $des->setParentId($this->getMetaId());
102  $des->setParentType('meta_relation');
103 
104  return $des;
105  }
+ Here is the call graph for this function:

◆ addIdentifier_()

ilMDRelation::addIdentifier_ ( )

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

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

71  {
72  $ide = new ilMDIdentifier_($this->getRBACId(), $this->getObjId(), $this->getObjType());
73  $ide->setParentId($this->getMetaId());
74  $ide->setParentType('meta_relation');
75 
76  return $ide;
77  }
+ Here is the call graph for this function:

◆ delete()

ilMDRelation::delete ( )

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

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

157  : bool
158  {
159  if ($this->getMetaId()) {
160  $query = "DELETE FROM il_meta_relation " .
161  "WHERE meta_relation_id = " . $this->db->quote($this->getMetaId(), 'integer');
162  $res = $this->db->manipulate($query);
163 
164  foreach ($this->getIdentifier_Ids() as $id) {
165  $ide = $this->getIdentifier_($id);
166  $ide->delete();
167  }
168  foreach ($this->getDescriptionIds() as $id) {
169  $des = $this->getDescription($id);
170  $des->delete();
171  }
172 
173  return true;
174  }
175  return false;
176  }
$res
Definition: ltiservices.php:66
getDescription(int $a_description_id)
getIdentifier_(int $a_identifier__id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getDescription()

ilMDRelation::getDescription ( int  $a_description_id)

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

References null.

Referenced by delete(), and toXML().

88  {
89  if (!$a_description_id) {
90  return null;
91  }
92  $des = new ilMDDescription();
93  $des->setMetaId($a_description_id);
94 
95  return $des;
96  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getDescriptionIds()

ilMDRelation::getDescriptionIds ( )
Returns
int[]

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

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

Referenced by delete(), and toXML().

82  : array
83  {
84  return ilMDDescription::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_relation');
85  }
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)
+ 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 59 of file class.ilMDRelation.php.

References null.

Referenced by delete(), and toXML().

60  {
61  if (!$a_identifier__id) {
62  return null;
63  }
64  $ide = new ilMDIdentifier_();
65  $ide->setMetaId($a_identifier__id);
66 
67  return $ide;
68  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getIdentifier_Ids()

ilMDRelation::getIdentifier_Ids ( )
Returns
int[]

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

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

Referenced by delete(), and toXML().

54  : array
55  {
56  return ilMDIdentifier_::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_relation');
57  }
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getKind()

ilMDRelation::getKind ( )

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

References $kind.

Referenced by __getFields(), and toXML().

131  : string
132  {
133  return $this->kind;
134  }
const string $kind
+ Here is the caller graph for this function:

◆ read()

ilMDRelation::read ( )

Compatibility fix for legacy MD classes for new db tables

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

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

199  : bool
200  {
201  if ($this->getMetaId()) {
202  $query = "SELECT * FROM il_meta_relation " .
203  "WHERE meta_relation_id = " . $this->db->quote($this->getMetaId(), 'integer');
204 
205  $res = $this->db->query($query);
206  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
210  if (key_exists($row->kind ?? '', self::KIND_TRANSLATION)) {
211  $row->kind = self::KIND_TRANSLATION[$row->kind ?? ''];
212  }
213 
214  $this->setRBACId((int) $row->rbac_id);
215  $this->setObjId((int) $row->obj_id);
216  $this->setObjType($row->obj_type);
217  $this->setKind($row->kind ?? '');
218  }
219  }
220  return true;
221  }
$res
Definition: ltiservices.php:66
setKind(string $a_kind)
setRBACId(int $a_id)
setObjId(int $a_id)
setObjType(string $a_type)
+ Here is the call graph for this function:

◆ save()

ilMDRelation::save ( )

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

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

136  : int
137  {
138  $fields = $this->__getFields();
139  $fields['meta_relation_id'] = array('integer', $next_id = $this->db->nextId('il_meta_relation'));
140 
141  if ($this->db->insert('il_meta_relation', $fields)) {
142  $this->setMetaId($next_id);
143  return $this->getMetaId();
144  }
145  return 0;
146  }
setMetaId(int $a_meta_id, bool $a_read_data=true)
+ Here is the call graph for this function:

◆ setKind()

ilMDRelation::setKind ( string  $a_kind)

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

Referenced by read().

108  : bool
109  {
110  switch ($a_kind) {
111  case 'IsPartOf':
112  case 'HasPart':
113  case 'IsVersionOf':
114  case 'HasVersion':
115  case 'IsFormatOf':
116  case 'HasFormat':
117  case 'References':
118  case 'IsReferencedBy':
119  case 'IsBasedOn':
120  case 'IsBasisFor':
121  case 'Requires':
122  case 'IsRequiredBy':
123  $this->kind = $a_kind;
124  return true;
125 
126  default:
127  return false;
128  }
129  }
+ Here is the caller graph for this function:

◆ toXML()

ilMDRelation::toXML ( ilXmlWriter  $writer)

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

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

223  : void
224  {
225  $writer->xmlStartTag('Relation', array(
226  'Kind' => $this->getKind() ?: 'IsPartOf'
227  ));
228  $writer->xmlStartTag('Resource');
229 
230  // Identifier_
231  $ides = $this->getIdentifier_Ids();
232  foreach ($ides as $id) {
233  $ide = $this->getIdentifier_($id);
234  $ide->toXML($writer);
235  }
236  if (!count($ides)) {
237  $ide = new ilMDIdentifier_($this->getRBACId(), $this->getObjId());
238  $ide->toXML($writer);
239  }
240 
241  // Description
242  $dess = $this->getDescriptionIds();
243  foreach ($dess as $id) {
244  $des = $this->getDescription($id);
245  $des->toXML($writer);
246  }
247  if (!count($dess)) {
248  $des = new ilMDDescription($this->getRBACId(), $this->getObjId());
249  $des->toXML($writer);
250  }
251 
252  $writer->xmlEndTag('Resource');
253  $writer->xmlEndTag('Relation');
254  }
getDescription(int $a_description_id)
xmlEndTag(string $tag)
Writes an endtag.
getIdentifier_(int $a_identifier__id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
+ Here is the call graph for this function:

◆ update()

ilMDRelation::update ( )

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

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

148  : bool
149  {
150  return $this->getMetaId() && $this->db->update(
151  'il_meta_relation',
152  $this->__getFields(),
153  array("meta_relation_id" => array('integer', $this->getMetaId()))
154  );
155  }
+ Here is the call graph for this function:

Field Documentation

◆ $kind

const string ilMDRelation::$kind = ''
private

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

Referenced by getKind().

◆ KIND_TRANSLATION

const ilMDRelation::KIND_TRANSLATION
private
Initial value:
= [
'ispartof' => 'IsPartOf'

Compatibility fix for legacy MD classes for new db tables.

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


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