ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilMDRelation Class Reference
+ Inheritance diagram for ilMDRelation:
+ Collaboration diagram for ilMDRelation:

Public Member Functions

 ilMDRelation ($a_rbac_id=0, $a_obj_id=0, $a_obj_type='')
 
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)
 
 ilMDRelation ($a_rbac_id=0, $a_obj_id=0, $a_obj_type='')
 
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
 ilMDBase ($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)
 
 ilMDBase ($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)
 

Additional Inherited Members

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

Detailed Description

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

Member Function Documentation

◆ __getFields() [1/2]

ilMDRelation::__getFields ( )

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

192 {
193 return array('rbac_id' => array('integer',$this->getRBACId()),
194 'obj_id' => array('integer',$this->getObjId()),
195 'obj_type' => array('text',$this->getObjType()),
196 'kind' => array('text',$this->getKind()));
197 }

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 191 of file class.ilMDRelation.php.

192 {
193 return array('rbac_id' => $this->getRBACId(),
194 'obj_id' => $this->getObjId(),
195 'obj_type' => ilUtil::prepareDBString($this->getObjType()),
196 'kind' => ilUtil::prepareDBString($this->getKind()));
197 }
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]

ilMDRelation::_getIds (   $a_rbac_id,
  $a_obj_id 
)

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

268 {
269 global $ilDB;
270
271 $query = "SELECT meta_relation_id FROM il_meta_relation ".
272 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,'integer')." ".
273 "AND obj_id = ".$ilDB->quote($a_obj_id ,'integer');
274
275 $res = $ilDB->query($query);
276 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
277 {
278 $ids[] = $row->meta_relation_id;
279 }
280 return $ids ? $ids : array();
281 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB

References $ilDB, $query, $res, $row, and DB_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 249 of file class.ilMDRelation.php.

250 {
251 global $ilDB;
252
253 $query = "SELECT meta_relation_id FROM il_meta_relation ".
254 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
255 "AND obj_id = ".$ilDB->quote($a_obj_id);
256
257 $res = $ilDB->query($query);
258 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
259 {
260 $ids[] = $row->meta_relation_id;
261 }
262 return $ids ? $ids : array();
263 }

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

◆ addDescription() [1/2]

& ilMDRelation::addDescription ( )

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

94 {
95 include_once 'Services/MetaData/classes/class.ilMDDescription.php';
96
97 $des =& new ilMDDescription($this->getRBACId(),$this->getObjId(),$this->getObjType());
98 $des->setParentId($this->getMetaId());
99 $des->setParentType('meta_relation');
100
101 return $des;
102 }

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 93 of file class.ilMDRelation.php.

94 {
95 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDDescription.php';
96
97 $des =& new ilMDDescription($this->getRBACId(),$this->getObjId(),$this->getObjType());
98 $des->setParentId($this->getMetaId());
99 $des->setParentType('meta_relation');
100
101 return $des;
102 }

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 63 of file class.ilMDRelation.php.

64 {
65 include_once 'Services/MetaData/classes/class.ilMDIdentifier_.php';
66
67 $ide =& new ilMDIdentifier_($this->getRBACId(),$this->getObjId(),$this->getObjType());
68 $ide->setParentId($this->getMetaId());
69 $ide->setParentType('meta_relation');
70
71 return $ide;
72 }

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 63 of file class.ilMDRelation.php.

64 {
65 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDIdentifier_.php';
66
67 $ide =& new ilMDIdentifier_($this->getRBACId(),$this->getObjId(),$this->getObjType());
68 $ide->setParentId($this->getMetaId());
69 $ide->setParentType('meta_relation');
70
71 return $ide;
72 }

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 164 of file class.ilMDRelation.php.

165 {
166 global $ilDB;
167
168 if($this->getMetaId())
169 {
170 $query = "DELETE FROM il_meta_relation ".
171 "WHERE meta_relation_id = ".$ilDB->quote($this->getMetaId() ,'integer');
172 $res = $ilDB->manipulate($query);
173
174 foreach($this->getIdentifier_Ids() as $id)
175 {
176 $ide = $this->getIdentifier_($id);
177 $ide->delete();
178 }
179 foreach($this->getDescriptionIds() as $id)
180 {
181 $des = $this->getDescription($id);
182 $des->delete();
183 }
184
185 return true;
186 }
187 return false;
188 }
& 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 163 of file class.ilMDRelation.php.

164 {
165 global $ilDB;
166
167 if($this->getMetaId())
168 {
169 $query = "DELETE FROM il_meta_relation ".
170 "WHERE meta_relation_id = ".$ilDB->quote($this->getMetaId());
171
172 $this->db->query($query);
173
174 foreach($this->getIdentifier_Ids() as $id)
175 {
176 $ide = $this->getIdentifier_($id);
177 $ide->delete();
178 }
179 foreach($this->getDescriptionIds() as $id)
180 {
181 $des = $this->getDescription();
182 $des->delete();
183 }
184
185 return true;
186 }
187 return false;
188 }

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 80 of file class.ilMDRelation.php.

81 {
82 include_once 'Services/MetaData/classes/class.ilMDDescription.php';
83
84 if(!$a_description_id)
85 {
86 return false;
87 }
88 $des =& new ilMDDescription();
89 $des->setMetaId($a_description_id);
90
91 return $des;
92 }

Referenced by delete(), and toXML().

+ Here is the caller graph for this function:

◆ getDescription() [2/2]

& ilMDRelation::getDescription (   $a_description_id)

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

81 {
82 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDDescription.php';
83
84 if(!$a_description_id)
85 {
86 return false;
87 }
88 $des =& new ilMDDescription();
89 $des->setMetaId($a_description_id);
90
91 return $des;
92 }

◆ getDescriptionIds() [1/2]

& ilMDRelation::getDescriptionIds ( )

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

75 {
76 include_once 'Services/MetaData/classes/class.ilMDDescription.php';
77
78 return ilMdDescription::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_relation');
79 }

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 74 of file class.ilMDRelation.php.

75 {
76 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDDescription.php';
77
78 return ilMdDescription::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_relation');
79 }

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 50 of file class.ilMDRelation.php.

51 {
52 include_once 'Services/MetaData/classes/class.ilMDIdentifier_.php';
53
54 if(!$a_identifier__id)
55 {
56 return false;
57 }
58 $ide =& new ilMDIdentifier_();
59 $ide->setMetaId($a_identifier__id);
60
61 return $ide;
62 }

Referenced by delete(), and toXML().

+ Here is the caller graph for this function:

◆ getIdentifier_() [2/2]

& ilMDRelation::getIdentifier_ (   $a_identifier__id)

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

51 {
52 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDIdentifier_.php';
53
54 if(!$a_identifier__id)
55 {
56 return false;
57 }
58 $ide =& new ilMDIdentifier_();
59 $ide->setMetaId($a_identifier__id);
60
61 return $ide;
62 }

◆ getIdentifier_Ids() [1/2]

& ilMDRelation::getIdentifier_Ids ( )

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

45 {
46 include_once 'Services/MetaData/classes/class.ilMDIdentifier_.php';
47
48 return ilMDIdentifier_::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_relation');
49 }
_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 44 of file class.ilMDRelation.php.

45 {
46 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDIdentifier_.php';
47
48 return ilMDIdentifier_::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_relation');
49 }

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 127 of file class.ilMDRelation.php.

128 {
129 return $this->kind;
130 }

Referenced by __getFields(), and toXML().

+ Here is the caller graph for this function:

◆ getKind() [2/2]

ilMDRelation::getKind ( )

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

128 {
129 return $this->kind;
130 }

◆ ilMDRelation() [1/2]

ilMDRelation::ilMDRelation (   $a_rbac_id = 0,
  $a_obj_id = 0,
  $a_obj_type = '' 
)

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

36 {
37 parent::ilMDBase($a_rbac_id,
38 $a_obj_id,
39 $a_obj_type);
40 }

◆ ilMDRelation() [2/2]

ilMDRelation::ilMDRelation (   $a_rbac_id = 0,
  $a_obj_id = 0,
  $a_obj_type = '' 
)

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

36 {
37 parent::ilMDBase($a_rbac_id,
38 $a_obj_id,
39 $a_obj_type);
40 }

◆ read() [1/2]

ilMDRelation::read ( )

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

200 {
201 global $ilDB;
202
203 if($this->getMetaId())
204 {
205 $query = "SELECT * FROM il_meta_relation ".
206 "WHERE meta_relation_id = ".$ilDB->quote($this->getMetaId() ,'integer');
207
208 $res = $this->db->query($query);
209 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
210 {
211 $this->setRBACId($row->rbac_id);
212 $this->setObjId($row->obj_id);
213 $this->setObjType($row->obj_type);
214 $this->setKind($row->kind);
215 }
216 }
217 return true;
218 }
setObjId($a_id)
setObjType($a_type)
setRBACId($a_id)

References $ilDB, $query, $res, $row, DB_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 199 of file class.ilMDRelation.php.

200 {
201 global $ilDB;
202
203 if($this->getMetaId())
204 {
205 $query = "SELECT * FROM il_meta_relation ".
206 "WHERE meta_relation_id = ".$ilDB->quote($this->getMetaId());
207
208 $res = $this->db->query($query);
209 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
210 {
211 $this->setRBACId($row->rbac_id);
212 $this->setObjId($row->obj_id);
213 $this->setObjType($row->obj_type);
214 $this->setKind(ilUtil::stripSlashes($row->kind));
215 }
216 }
217 return true;
218 }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References $ilDB, $query, $res, $row, DB_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 133 of file class.ilMDRelation.php.

134 {
135 global $ilDB;
136
137 $fields = $this->__getFields();
138 $fields['meta_relation_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_relation'));
139
140 if($this->db->insert('il_meta_relation',$fields))
141 {
142 $this->setMetaId($next_id);
143 return $this->getMetaId();
144 }
145 return false;
146 }
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 133 of file class.ilMDRelation.php.

134 {
135 if($this->db->autoExecute('il_meta_relation',
136 $this->__getFields(),
137 DB_AUTOQUERY_INSERT))
138 {
139 $this->setMetaId($this->db->getLastInsertId());
140
141 return $this->getMetaId();
142 }
143 return false;
144 }

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

+ Here is the call graph for this function:

◆ setKind() [1/2]

ilMDRelation::setKind (   $a_kind)

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

105 {
106 switch($a_kind)
107 {
108 case 'IsPartOf':
109 case 'HasPart':
110 case 'IsVersionOf':
111 case 'HasVersion':
112 case 'IsFormatOf':
113 case 'HasFormat':
114 case 'References':
115 case 'IsReferencedBy':
116 case 'IsBasedOn':
117 case 'IsBasisFor':
118 case 'Requires':
119 case 'IsRequiredBy':
120 $this->kind = $a_kind;
121 return true;
122
123 default:
124 return false;
125 }
126 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setKind() [2/2]

ilMDRelation::setKind (   $a_kind)

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

105 {
106 switch($a_kind)
107 {
108 case 'IsPartOf':
109 case 'HasPart':
110 case 'IsVersionOf':
111 case 'HasVersion':
112 case 'IsFormatOf':
113 case 'HasFormat':
114 case 'References':
115 case 'IsReferencedBy':
116 case 'IsBasedOn':
117 case 'IsBasisFor':
118 case 'Requires':
119 case 'IsRequiredBy':
120 $this->kind = $a_kind;
121 return true;
122
123 default:
124 return false;
125 }
126 }

◆ toXML() [1/2]

ilMDRelation::toXML ( $writer)

Reimplemented from ilMDBase.

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

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

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 225 of file class.ilMDRelation.php.

226 {
227 $writer->xmlStartTag('Relation',array('Kind' => $this->getKind()));
228 $writer->xmlStartTag('Resource');
229
230 // Identifier_
231 foreach($this->getIdentifier_Ids() as $id)
232 {
233 $ide =& $this->getIdentifier_($id);
234 $ide->toXML($writer);
235 }
236 // Description
237 foreach($this->getDescriptionIds() as $id)
238 {
239 $des =& $this->getDescription($id);
240 $des->toXML($writer);
241 }
242 $writer->xmlEndTag('Resource');
243 $writer->xmlEndTag('Relation');
244 }

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 148 of file class.ilMDRelation.php.

149 {
150 global $ilDB;
151
152 if($this->getMetaId())
153 {
154 if($this->db->update('il_meta_relation',
155 $this->__getFields(),
156 array("meta_relation_id" => array('integer',$this->getMetaId()))))
157 {
158 return true;
159 }
160 }
161 return false;
162 }

References $ilDB, and ilMDBase\getMetaId().

+ Here is the call graph for this function:

◆ update() [2/2]

ilMDRelation::update ( )

Reimplemented from ilMDBase.

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

147 {
148 global $ilDB;
149
150 if($this->getMetaId())
151 {
152 if($this->db->autoExecute('il_meta_relation',
153 $this->__getFields(),
154 DB_AUTOQUERY_UPDATE,
155 "meta_relation_id = ".$ilDB->quote($this->getMetaId())))
156 {
157 return true;
158 }
159 }
160 return false;
161 }

References $ilDB, and ilMDBase\getMetaId().

+ Here is the call graph for this function:

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