ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilMDRelation Class Reference
+ Inheritance diagram for ilMDRelation:
+ Collaboration diagram for ilMDRelation:

Public Member Functions

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

Static Public Member Functions

static _getIds ($a_rbac_id, $a_obj_id)
 

Additional Inherited Members

- Data Fields inherited from ilMDBase
 $rbac_id
 
 $obj_id
 
 $obj_type
 
 $export_mode = false
 
- Protected Attributes inherited from ilMDBase
 $log
 

Detailed Description

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

Member Function Documentation

◆ __getFields() [1/2]

ilMDRelation::__getFields ( )

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

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

Referenced by save().

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  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __getFields() [2/2]

ilMDRelation::__getFields ( )

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

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

179  {
180  return array('rbac_id' => $this->getRBACId(),
181  'obj_id' => $this->getObjId(),
182  'obj_type' => ilUtil::prepareDBString($this->getObjType()),
183  'kind' => ilUtil::prepareDBString($this->getKind()));
184  }
Create styles array
The data for the language used.
static prepareDBString($a_str)
prepare a string for db writing (insert/update)
+ Here is the call graph for this function:

◆ _getIds() [1/2]

ilMDRelation::_getIds (   $a_rbac_id,
  $a_obj_id 
)

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

References $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

233  {
234  global $ilDB;
235 
236  $query = "SELECT meta_relation_id FROM il_meta_relation " .
237  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id) . " " .
238  "AND obj_id = " . $ilDB->quote($a_obj_id);
239 
240  $res = $ilDB->query($query);
241  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
242  $ids[] = $row->meta_relation_id;
243  }
244  return $ids ? $ids : array();
245  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB

◆ _getIds() [2/2]

static ilMDRelation::_getIds (   $a_rbac_id,
  $a_obj_id 
)
static

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

References $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilMD\getRelationIds().

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  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ addDescription() [1/2]

& ilMDRelation::addDescription ( )

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

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

84  {
85  include_once 'Services/Migration/DBUpdate_426/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  }
+ Here is the call graph for this function:

◆ addDescription() [2/2]

& ilMDRelation::addDescription ( )

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

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

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  }
+ Here is the call graph for this function:

◆ addIdentifier_() [1/2]

& ilMDRelation::addIdentifier_ ( )

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

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

55  {
56  include_once 'Services/Migration/DBUpdate_426/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  }
+ Here is the call graph for this function:

◆ addIdentifier_() [2/2]

& ilMDRelation::addIdentifier_ ( )

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

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

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  }
+ Here is the call graph for this function:

◆ delete() [1/2]

ilMDRelation::delete ( )

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

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

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  }
& getIdentifier_($a_identifier__id)
if(!array_key_exists('StateId', $_REQUEST)) $id
foreach($_POST as $key=> $value) $res
$query
global $ilDB
& getDescription($a_description_id)
+ Here is the call graph for this function:

◆ delete() [2/2]

ilMDRelation::delete ( )

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

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

154  {
155  global $ilDB;
156 
157  if ($this->getMetaId()) {
158  $query = "DELETE FROM il_meta_relation " .
159  "WHERE meta_relation_id = " . $ilDB->quote($this->getMetaId());
160 
161  $this->db->query($query);
162 
163  foreach ($this->getIdentifier_Ids() as $id) {
164  $ide = $this->getIdentifier_($id);
165  $ide->delete();
166  }
167  foreach ($this->getDescriptionIds() as $id) {
168  $des = $this->getDescription();
169  $des->delete();
170  }
171 
172  return true;
173  }
174  return false;
175  }
& getIdentifier_($a_identifier__id)
if(!array_key_exists('StateId', $_REQUEST)) $id
$query
global $ilDB
& getDescription($a_description_id)
+ Here is the call graph for this function:

◆ getDescription() [1/2]

& ilMDRelation::getDescription (   $a_description_id)

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

Referenced by delete(), and toXML().

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  }
+ Here is the caller graph for this function:

◆ getDescription() [2/2]

& ilMDRelation::getDescription (   $a_description_id)

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

72  {
73  include_once 'Services/Migration/DBUpdate_426/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  }

◆ getDescriptionIds() [1/2]

& ilMDRelation::getDescriptionIds ( )

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

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

66  {
67  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDDescription.php';
68 
69  return ilMdDescription::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_relation');
70  }
+ Here is the call graph for this function:

◆ getDescriptionIds() [2/2]

& ilMDRelation::getDescriptionIds ( )

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

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

Referenced by delete(), and toXML().

66  {
67  include_once 'Services/MetaData/classes/class.ilMDDescription.php';
68 
69  return ilMdDescription::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_relation');
70  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIdentifier_() [1/2]

& ilMDRelation::getIdentifier_ (   $a_identifier__id)

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

43  {
44  include_once 'Services/Migration/DBUpdate_426/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  }

◆ getIdentifier_() [2/2]

& ilMDRelation::getIdentifier_ (   $a_identifier__id)

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

Referenced by delete(), and toXML().

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  }
+ Here is the caller graph for this function:

◆ getIdentifier_Ids() [1/2]

& ilMDRelation::getIdentifier_Ids ( )

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

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

Referenced by delete(), and toXML().

37  {
38  include_once 'Services/MetaData/classes/class.ilMDIdentifier_.php';
39 
40  return ilMDIdentifier_::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_relation');
41  }
static _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIdentifier_Ids() [2/2]

& ilMDRelation::getIdentifier_Ids ( )

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

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

37  {
38  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDIdentifier_.php';
39 
40  return ilMDIdentifier_::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_relation');
41  }
static _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
+ Here is the call graph for this function:

◆ getKind() [1/2]

ilMDRelation::getKind ( )

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

Referenced by __getFields(), and toXML().

117  {
118  return $this->kind;
119  }
+ Here is the caller graph for this function:

◆ getKind() [2/2]

ilMDRelation::getKind ( )

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

117  {
118  return $this->kind;
119  }

◆ read() [1/2]

ilMDRelation::read ( )

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

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

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  }
setObjType($a_type)
foreach($_POST as $key=> $value) $res
setObjId($a_id)
setRBACId($a_id)
$query
global $ilDB
+ Here is the call graph for this function:

◆ read() [2/2]

ilMDRelation::read ( )

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

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

187  {
188  global $ilDB;
189 
190  if ($this->getMetaId()) {
191  $query = "SELECT * FROM il_meta_relation " .
192  "WHERE meta_relation_id = " . $ilDB->quote($this->getMetaId());
193 
194  $res = $this->db->query($query);
195  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
196  $this->setRBACId($row->rbac_id);
197  $this->setObjId($row->obj_id);
198  $this->setObjType($row->obj_type);
199  $this->setKind(ilUtil::stripSlashes($row->kind));
200  }
201  }
202  return true;
203  }
setObjType($a_type)
foreach($_POST as $key=> $value) $res
setObjId($a_id)
setRBACId($a_id)
$query
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $ilDB
+ Here is the call graph for this function:

◆ save() [1/2]

ilMDRelation::save ( )

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

References $ilDB, __getFields(), array, ilMDBase\getMetaId(), and ilMDBase\setMetaId().

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  }
setMetaId($a_meta_id, $a_read_data=true)
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ save() [2/2]

ilMDRelation::save ( )

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

References ilMDBase\getMetaId(), ilDBConstants\MDB2_AUTOQUERY_INSERT, and ilMDBase\setMetaId().

123  {
124  if ($this->db->autoExecute(
125  'il_meta_relation',
126  $this->__getFields(),
128  )) {
129  $this->setMetaId($this->db->getLastInsertId());
130 
131  return $this->getMetaId();
132  }
133  return false;
134  }
setMetaId($a_meta_id, $a_read_data=true)
+ Here is the call graph for this function:

◆ setKind() [1/2]

ilMDRelation::setKind (   $a_kind)

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

Referenced by read().

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  }
+ Here is the caller graph for this function:

◆ setKind() [2/2]

ilMDRelation::setKind (   $a_kind)

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

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  }

◆ toXML() [1/2]

ilMDRelation::toXML ( $writer)

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

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

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  }
& getIdentifier_($a_identifier__id)
if(!array_key_exists('StateId', $_REQUEST)) $id
Create styles array
The data for the language used.
& getDescription($a_description_id)
+ Here is the call graph for this function:

◆ toXML() [2/2]

ilMDRelation::toXML ( $writer)

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

References $id, array, getDescription(), getDescriptionIds(), getIdentifier_(), getIdentifier_Ids(), and getKind().

211  {
212  $writer->xmlStartTag('Relation', array('Kind' => $this->getKind()));
213  $writer->xmlStartTag('Resource');
214 
215  // Identifier_
216  foreach ($this->getIdentifier_Ids() as $id) {
217  $ide =&$this->getIdentifier_($id);
218  $ide->toXML($writer);
219  }
220  // Description
221  foreach ($this->getDescriptionIds() as $id) {
222  $des =&$this->getDescription($id);
223  $des->toXML($writer);
224  }
225  $writer->xmlEndTag('Resource');
226  $writer->xmlEndTag('Relation');
227  }
& getIdentifier_($a_identifier__id)
if(!array_key_exists('StateId', $_REQUEST)) $id
Create styles array
The data for the language used.
& getDescription($a_description_id)
+ Here is the call graph for this function:

◆ update() [1/2]

ilMDRelation::update ( )

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

References $ilDB, ilMDBase\getMetaId(), and ilDBConstants\MDB2_AUTOQUERY_UPDATE.

137  {
138  global $ilDB;
139 
140  if ($this->getMetaId()) {
141  if ($this->db->autoExecute(
142  'il_meta_relation',
143  $this->__getFields(),
145  "meta_relation_id = " . $ilDB->quote($this->getMetaId())
146  )) {
147  return true;
148  }
149  }
150  return false;
151  }
global $ilDB
+ Here is the call graph for this function:

◆ update() [2/2]

ilMDRelation::update ( )

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

References $ilDB, array, and ilMDBase\getMetaId().

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  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

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