ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 183 of file class.ilMDRelation.php.

184 {
185 return array('rbac_id' => array('integer',$this->getRBACId()),
186 'obj_id' => array('integer',$this->getObjId()),
187 'obj_type' => array('text',$this->getObjType()),
188 'kind' => array('text',$this->getKind()));
189 }

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

Referenced by save().

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

◆ __getFields() [2/2]

ilMDRelation::__getFields ( )

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

184 {
185 return array('rbac_id' => $this->getRBACId(),
186 'obj_id' => $this->getObjId(),
187 'obj_type' => ilUtil::prepareDBString($this->getObjType()),
188 'kind' => ilUtil::prepareDBString($this->getKind()));
189 }
static prepareDBString($a_str)
prepare a string for db writing (insert/update)

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

+ Here is the call graph for this function:

◆ _getIds() [1/2]

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

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

260 {
261 global $ilDB;
262
263 $query = "SELECT meta_relation_id FROM il_meta_relation ".
264 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,'integer')." ".
265 "AND obj_id = ".$ilDB->quote($a_obj_id ,'integer');
266
267 $res = $ilDB->query($query);
268 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
269 {
270 $ids[] = $row->meta_relation_id;
271 }
272 return $ids ? $ids : array();
273 }
global $ilDB

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

Referenced by ilMD\getRelationIds().

+ Here is the caller graph for this function:

◆ _getIds() [2/2]

ilMDRelation::_getIds (   $a_rbac_id,
  $a_obj_id 
)

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

242 {
243 global $ilDB;
244
245 $query = "SELECT meta_relation_id FROM il_meta_relation ".
246 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
247 "AND obj_id = ".$ilDB->quote($a_obj_id);
248
249 $res = $ilDB->query($query);
250 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
251 {
252 $ids[] = $row->meta_relation_id;
253 }
254 return $ids ? $ids : array();
255 }

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

◆ addDescription() [1/2]

& ilMDRelation::addDescription ( )

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

86 {
87 include_once 'Services/MetaData/classes/class.ilMDDescription.php';
88
89 $des = new ilMDDescription($this->getRBACId(),$this->getObjId(),$this->getObjType());
90 $des->setParentId($this->getMetaId());
91 $des->setParentType('meta_relation');
92
93 return $des;
94 }

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

+ Here is the call graph for this function:

◆ addDescription() [2/2]

& ilMDRelation::addDescription ( )

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

86 {
87 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDDescription.php';
88
89 $des = new ilMDDescription($this->getRBACId(),$this->getObjId(),$this->getObjType());
90 $des->setParentId($this->getMetaId());
91 $des->setParentType('meta_relation');
92
93 return $des;
94 }

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

+ Here is the call graph for this function:

◆ addIdentifier_() [1/2]

& ilMDRelation::addIdentifier_ ( )

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

56 {
57 include_once 'Services/MetaData/classes/class.ilMDIdentifier_.php';
58
59 $ide = new ilMDIdentifier_($this->getRBACId(),$this->getObjId(),$this->getObjType());
60 $ide->setParentId($this->getMetaId());
61 $ide->setParentType('meta_relation');
62
63 return $ide;
64 }

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

+ Here is the call graph for this function:

◆ addIdentifier_() [2/2]

& ilMDRelation::addIdentifier_ ( )

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

56 {
57 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDIdentifier_.php';
58
59 $ide = new ilMDIdentifier_($this->getRBACId(),$this->getObjId(),$this->getObjType());
60 $ide->setParentId($this->getMetaId());
61 $ide->setParentType('meta_relation');
62
63 return $ide;
64 }

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

+ Here is the call graph for this function:

◆ delete() [1/2]

ilMDRelation::delete ( )

Reimplemented from ilMDBase.

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

157 {
158 global $ilDB;
159
160 if($this->getMetaId())
161 {
162 $query = "DELETE FROM il_meta_relation ".
163 "WHERE meta_relation_id = ".$ilDB->quote($this->getMetaId() ,'integer');
164 $res = $ilDB->manipulate($query);
165
166 foreach($this->getIdentifier_Ids() as $id)
167 {
168 $ide = $this->getIdentifier_($id);
169 $ide->delete();
170 }
171 foreach($this->getDescriptionIds() as $id)
172 {
173 $des = $this->getDescription($id);
174 $des->delete();
175 }
176
177 return true;
178 }
179 return false;
180 }
& getIdentifier_($a_identifier__id)
& getDescription($a_description_id)

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

+ Here is the call graph for this function:

◆ delete() [2/2]

ilMDRelation::delete ( )

Reimplemented from ilMDBase.

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

156 {
157 global $ilDB;
158
159 if($this->getMetaId())
160 {
161 $query = "DELETE FROM il_meta_relation ".
162 "WHERE meta_relation_id = ".$ilDB->quote($this->getMetaId());
163
164 $this->db->query($query);
165
166 foreach($this->getIdentifier_Ids() as $id)
167 {
168 $ide = $this->getIdentifier_($id);
169 $ide->delete();
170 }
171 foreach($this->getDescriptionIds() as $id)
172 {
173 $des = $this->getDescription();
174 $des->delete();
175 }
176
177 return true;
178 }
179 return false;
180 }

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

+ Here is the call graph for this function:

◆ getDescription() [1/2]

& ilMDRelation::getDescription (   $a_description_id)

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

73 {
74 include_once 'Services/MetaData/classes/class.ilMDDescription.php';
75
76 if(!$a_description_id)
77 {
78 return false;
79 }
80 $des = new ilMDDescription();
81 $des->setMetaId($a_description_id);
82
83 return $des;
84 }

Referenced by delete(), and toXML().

+ Here is the caller graph for this function:

◆ getDescription() [2/2]

& ilMDRelation::getDescription (   $a_description_id)

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

73 {
74 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDDescription.php';
75
76 if(!$a_description_id)
77 {
78 return false;
79 }
80 $des = new ilMDDescription();
81 $des->setMetaId($a_description_id);
82
83 return $des;
84 }

◆ getDescriptionIds() [1/2]

& ilMDRelation::getDescriptionIds ( )

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

67 {
68 include_once 'Services/MetaData/classes/class.ilMDDescription.php';
69
70 return ilMdDescription::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_relation');
71 }

References 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:

◆ getDescriptionIds() [2/2]

& ilMDRelation::getDescriptionIds ( )

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

67 {
68 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDDescription.php';
69
70 return ilMdDescription::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_relation');
71 }

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

+ Here is the call 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/MetaData/classes/class.ilMDIdentifier_.php';
45
46 if(!$a_identifier__id)
47 {
48 return false;
49 }
50 $ide = new ilMDIdentifier_();
51 $ide->setMetaId($a_identifier__id);
52
53 return $ide;
54 }

Referenced by delete(), and toXML().

+ Here is the caller graph for this function:

◆ getIdentifier_() [2/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 {
48 return false;
49 }
50 $ide = new ilMDIdentifier_();
51 $ide->setMetaId($a_identifier__id);
52
53 return $ide;
54 }

◆ getIdentifier_Ids() [1/2]

& ilMDRelation::getIdentifier_Ids ( )

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

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)

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:

◆ getIdentifier_Ids() [2/2]

& ilMDRelation::getIdentifier_Ids ( )

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

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 }

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

+ Here is the call graph for this function:

◆ getKind() [1/2]

ilMDRelation::getKind ( )

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

120 {
121 return $this->kind;
122 }

Referenced by __getFields(), and toXML().

+ Here is the caller graph for this function:

◆ getKind() [2/2]

ilMDRelation::getKind ( )

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

120 {
121 return $this->kind;
122 }

◆ read() [1/2]

ilMDRelation::read ( )

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

192 {
193 global $ilDB;
194
195 if($this->getMetaId())
196 {
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 {
203 $this->setRBACId($row->rbac_id);
204 $this->setObjId($row->obj_id);
205 $this->setObjType($row->obj_type);
206 $this->setKind($row->kind);
207 }
208 }
209 return true;
210 }
setObjId($a_id)
setObjType($a_type)
setRBACId($a_id)

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

+ Here is the call graph for this function:

◆ read() [2/2]

ilMDRelation::read ( )

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

192 {
193 global $ilDB;
194
195 if($this->getMetaId())
196 {
197 $query = "SELECT * FROM il_meta_relation ".
198 "WHERE meta_relation_id = ".$ilDB->quote($this->getMetaId());
199
200 $res = $this->db->query($query);
201 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
202 {
203 $this->setRBACId($row->rbac_id);
204 $this->setObjId($row->obj_id);
205 $this->setObjType($row->obj_type);
206 $this->setKind(ilUtil::stripSlashes($row->kind));
207 }
208 }
209 return true;
210 }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

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

+ Here is the call graph for this function:

◆ save() [1/2]

ilMDRelation::save ( )

Reimplemented from ilMDBase.

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

126 {
127 global $ilDB;
128
129 $fields = $this->__getFields();
130 $fields['meta_relation_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_relation'));
131
132 if($this->db->insert('il_meta_relation',$fields))
133 {
134 $this->setMetaId($next_id);
135 return $this->getMetaId();
136 }
137 return false;
138 }
setMetaId($a_meta_id, $a_read_data=true)

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

+ Here is the call graph for this function:

◆ save() [2/2]

ilMDRelation::save ( )

Reimplemented from ilMDBase.

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

126 {
127 if($this->db->autoExecute('il_meta_relation',
128 $this->__getFields(),
130 {
131 $this->setMetaId($this->db->getLastInsertId());
132
133 return $this->getMetaId();
134 }
135 return false;
136 }

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

+ Here is the call graph for this function:

◆ setKind() [1/2]

ilMDRelation::setKind (   $a_kind)

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

97 {
98 switch($a_kind)
99 {
100 case 'IsPartOf':
101 case 'HasPart':
102 case 'IsVersionOf':
103 case 'HasVersion':
104 case 'IsFormatOf':
105 case 'HasFormat':
106 case 'References':
107 case 'IsReferencedBy':
108 case 'IsBasedOn':
109 case 'IsBasisFor':
110 case 'Requires':
111 case 'IsRequiredBy':
112 $this->kind = $a_kind;
113 return true;
114
115 default:
116 return false;
117 }
118 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setKind() [2/2]

ilMDRelation::setKind (   $a_kind)

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

97 {
98 switch($a_kind)
99 {
100 case 'IsPartOf':
101 case 'HasPart':
102 case 'IsVersionOf':
103 case 'HasVersion':
104 case 'IsFormatOf':
105 case 'HasFormat':
106 case 'References':
107 case 'IsReferencedBy':
108 case 'IsBasedOn':
109 case 'IsBasisFor':
110 case 'Requires':
111 case 'IsRequiredBy':
112 $this->kind = $a_kind;
113 return true;
114
115 default:
116 return false;
117 }
118 }

◆ toXML() [1/2]

ilMDRelation::toXML ( $writer)

Reimplemented from ilMDBase.

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

218 {
219 $writer->xmlStartTag('Relation',array('Kind' => $this->getKind()
220 ? $this->getKind()
221 : 'IsPartOf'));
222 $writer->xmlStartTag('Resource');
223
224 // Identifier_
225 $ides = $this->getIdentifier_Ids();
226 foreach($ides as $id)
227 {
228 $ide =& $this->getIdentifier_($id);
229 $ide->toXML($writer);
230 }
231 if(!count($ides))
232 {
233 include_once 'Services/MetaData/classes/class.ilMDIdentifier_.php';
234 $ide = new ilMDIdentifier_($this->getRBACId(),$this->getObjId());
235 $ide->toXML($writer);
236 }
237
238 // Description
239 $dess = $this->getDescriptionIds();
240 foreach($dess as $id)
241 {
242 $des =& $this->getDescription($id);
243 $des->toXML($writer);
244 }
245 if(!count($dess))
246 {
247 include_once 'Services/MetaData/classes/class.ilMDDescription.php';
248 $des = new ilMDDescription($this->getRBACId(),$this->getObjId());
249 $des->toXML($writer);
250 }
251
252 $writer->xmlEndTag('Resource');
253 $writer->xmlEndTag('Relation');
254 }

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

+ Here is the call graph for this function:

◆ toXML() [2/2]

ilMDRelation::toXML ( $writer)

Reimplemented from ilMDBase.

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

218 {
219 $writer->xmlStartTag('Relation',array('Kind' => $this->getKind()));
220 $writer->xmlStartTag('Resource');
221
222 // Identifier_
223 foreach($this->getIdentifier_Ids() as $id)
224 {
225 $ide =& $this->getIdentifier_($id);
226 $ide->toXML($writer);
227 }
228 // Description
229 foreach($this->getDescriptionIds() as $id)
230 {
231 $des =& $this->getDescription($id);
232 $des->toXML($writer);
233 }
234 $writer->xmlEndTag('Resource');
235 $writer->xmlEndTag('Relation');
236 }

References getDescription(), getDescriptionIds(), getIdentifier_(), getIdentifier_Ids(), and getKind().

+ Here is the call graph for this function:

◆ update() [1/2]

ilMDRelation::update ( )

Reimplemented from ilMDBase.

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

141 {
142 global $ilDB;
143
144 if($this->getMetaId())
145 {
146 if($this->db->update('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 }

References $ilDB, and ilMDBase\getMetaId().

+ Here is the call graph for this function:

◆ update() [2/2]

ilMDRelation::update ( )

Reimplemented from ilMDBase.

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

139 {
140 global $ilDB;
141
142 if($this->getMetaId())
143 {
144 if($this->db->autoExecute('il_meta_relation',
145 $this->__getFields(),
147 "meta_relation_id = ".$ilDB->quote($this->getMetaId())))
148 {
149 return true;
150 }
151 }
152 return false;
153 }

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

+ Here is the call graph for this function:

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