5 include_once(
"./Services/Taxonomy/exceptions/class.ilTaxonomyException.php");
28 function __construct($a_component_id, $a_obj_id, $a_item_type, $a_tax_id)
30 if ($a_component_id ==
"")
35 if ($a_item_type ==
"")
40 if ((
int) $a_tax_id == 0)
58 $this->component_id = $a_val;
68 return $this->component_id;
78 $this->item_type = $a_val;
88 return $this->item_type;
98 $this->taxonomy_id = $a_val;
108 return $this->taxonomy_id;
118 $this->obj_id = $a_val;
128 return $this->obj_id;
141 if (is_array($a_node_id))
143 $set = $ilDB->query(
"SELECT * FROM tax_node_assignment ".
144 " WHERE ".$ilDB->in(
"node_id", $a_node_id,
false,
"integer").
145 " AND tax_id = ".$ilDB->quote($this->
getTaxonomyId(),
"integer").
146 " AND component = ".$ilDB->quote($this->
getComponentId(),
"text").
147 " AND obj_id = ".$ilDB->quote($this->
getObjectId(),
"integer").
148 " AND item_type = ".$ilDB->quote($this->
getItemType(),
"text").
149 " ORDER BY order_nr ASC"
154 $set = $ilDB->query(
"SELECT * FROM tax_node_assignment ".
155 " WHERE node_id = ".$ilDB->quote($a_node_id,
"integer").
156 " AND tax_id = ".$ilDB->quote($this->
getTaxonomyId(),
"integer").
157 " AND component = ".$ilDB->quote($this->
getComponentId(),
"text").
158 " AND obj_id = ".$ilDB->quote($this->
getObjectId(),
"integer").
159 " AND item_type = ".$ilDB->quote($this->
getItemType(),
"text").
160 " ORDER BY order_nr ASC"
164 while ($rec = $ilDB->fetchAssoc($set))
182 $set = $ilDB->query(
"SELECT * FROM tax_node_assignment".
183 " WHERE component = ".$ilDB->quote($this->getComponentId(),
"text").
184 " AND item_type = ".$ilDB->quote($this->getItemType(),
"text").
185 " AND item_id = ".$ilDB->quote($a_item_id,
"integer").
186 " AND obj_id = ".$ilDB->quote($this->
getObjectId(),
"integer").
187 " AND tax_id = ".$ilDB->quote($this->
getTaxonomyId(),
"integer")
190 while ($rec = $ilDB->fetchAssoc($set))
210 if ((
int) $a_node_id == 0 || (
int) $a_item_id == 0)
216 $set = $ilDB->query(
"SELECT tax_tree_id FROM tax_tree ".
217 " WHERE child = ".$ilDB->quote($a_node_id,
"integer")
219 $rec = $ilDB->fetchAssoc($set);
222 throw new ilTaxonomyException(
'addAssignment: Node ID does not belong to current taxonomy.');
227 $set2 = $ilDB->query($q =
"SELECT item_id FROM tax_node_assignment ".
228 " WHERE component = ".$ilDB->quote($this->getComponentId(),
"text").
229 " AND item_type = ".$ilDB->quote($this->getItemType(),
"text").
230 " AND obj_id = ".$ilDB->quote($this->getObjectId(),
"integer").
231 " AND node_id = ".$ilDB->quote($a_node_id,
"integer").
232 " AND tax_id = ".$ilDB->quote($this->
getTaxonomyId(),
"integer").
233 " AND item_id = ".$ilDB->quote($a_item_id,
"integer")
235 if ($rec2 = $ilDB->fetchAssoc($set2))
240 if ($a_order_nr == 0)
245 $ilDB->replace(
"tax_node_assignment",
247 "node_id" => array(
"integer", $a_node_id),
249 "item_type" => array(
"text", $this->
getItemType()),
250 "obj_id" => array(
"integer", $this->
getObjectId()),
251 "item_id" => array(
"integer", $a_item_id)
255 "order_nr" => array(
"integer", $a_order_nr)
272 if ((
int) $a_node_id == 0 || (
int) $a_item_id == 0)
278 $set = $ilDB->query(
"SELECT tax_tree_id FROM tax_tree ".
279 " WHERE child = ".$ilDB->quote($a_node_id,
"integer")
281 $rec = $ilDB->fetchAssoc($set);
284 throw new ilTaxonomyException(
'addAssignment: Node ID does not belong to current taxonomy.');
287 $ilDB->manipulate(
"DELETE FROM tax_node_assignment WHERE ".
288 " component = ".$ilDB->quote($this->getComponentId(),
"text").
289 " AND item_type = ".$ilDB->quote($this->getItemType(),
"text").
290 " AND obj_id = ".$ilDB->quote($this->getObjectId(),
"integer").
291 " AND item_id = ".$ilDB->quote($a_item_id,
"integer").
292 " AND node_id = ".$ilDB->quote($a_node_id,
"integer").
293 " AND tax_id = ".$ilDB->quote($this->
getTaxonomyId(),
"integer")
307 $set = $ilDB->query(
"SELECT max(order_nr) mnr FROM tax_node_assignment ".
308 " WHERE component = ".$ilDB->quote($this->getComponentId(),
"text").
309 " AND item_type = ".$ilDB->quote($this->getItemType(),
"text").
310 " AND obj_id = ".$ilDB->quote($this->getObjectId(),
"integer").
311 " AND node_id = ".$ilDB->quote($a_node_id,
"integer").
312 " AND tax_id = ".$ilDB->quote($this->
getTaxonomyId(),
"integer")
314 $rec = $ilDB->fetchAssoc($set);
316 return (
int) $rec[
"mnr"];
329 $ilDB->manipulate(
"UPDATE tax_node_assignment SET ".
330 " order_nr = ".$ilDB->quote($a_order_nr,
"integer").
331 " WHERE component = ".$ilDB->quote($this->
getComponentId(),
"text").
332 " AND item_type = ".$ilDB->quote($this->
getItemType(),
"text").
333 " AND obj_id = ".$ilDB->quote($this->
getObjectId(),
"integer").
334 " AND node_id = ".$ilDB->quote($a_node_id,
"integer").
335 " AND item_id = ".$ilDB->quote($a_item_id,
"integer").
336 " AND tax_id = ".$ilDB->quote($this->
getTaxonomyId(),
"integer")
350 $ilDB->manipulate(
"DELETE FROM tax_node_assignment WHERE ".
351 " component = ".$ilDB->quote($this->getComponentId(),
"text").
352 " AND item_type = ".$ilDB->quote($this->getItemType(),
"text").
353 " AND obj_id = ".$ilDB->quote($this->getObjectId(),
"integer").
354 " AND item_id = ".$ilDB->quote($a_item_id,
"integer").
355 " AND tax_id = ".$ilDB->quote($this->
getTaxonomyId(),
"integer")
368 $ilDB->manipulate(
"DELETE FROM tax_node_assignment WHERE ".
369 " node_id = ".$ilDB->quote($a_node_id,
"integer").
370 " AND component = ".$ilDB->quote($this->
getComponentId(),
"text").
371 " AND obj_id = ".$ilDB->quote($this->
getObjectId(),
"integer").
372 " AND item_type = ".$ilDB->quote($this->
getItemType(),
"text")
385 $ilDB->manipulate(
"DELETE FROM tax_node_assignment WHERE ".
386 " node_id = ".$ilDB->quote($a_node_id,
"integer")
397 $set = $ilDB->query(
"SELECT * FROM tax_node_assignment ".
398 " WHERE component = ".$ilDB->quote($this->getComponentId(),
"text").
399 " AND item_type = ".$ilDB->quote($this->getItemType(),
"text").
400 " AND obj_id = ".$ilDB->quote($this->getObjectId(),
"integer").
401 " AND node_id = ".$ilDB->quote($a_node_id,
"integer").
402 " AND tax_id = ".$ilDB->quote($this->
getTaxonomyId(),
"integer").
403 " ORDER BY order_nr ASC"
406 while ($rec = $ilDB->fetchAssoc($set))
408 $ilDB->manipulate(
"UPDATE tax_node_assignment SET ".
409 " order_nr = ".$ilDB->quote($cnt,
"integer").
410 " WHERE component = ".$ilDB->quote($this->
getComponentId(),
"text").
411 " AND item_type = ".$ilDB->quote($this->
getItemType(),
"text").
412 " AND obj_id = ".$ilDB->quote($this->
getObjectId(),
"integer").
413 " AND node_id = ".$ilDB->quote($a_node_id,
"integer").
414 " AND tax_id = ".$ilDB->quote($this->
getTaxonomyId(),
"integer").
415 " AND item_id = ".$ilDB->quote($rec[
"item_id"],
"integer")
437 $set = $ilDB->query(
"SELECT * FROM tax_node_assignment".
438 " WHERE ".$ilDB->in(
"node_id", $a_node_ids,
"",
"integer").
439 " AND tax_id = ".$ilDB->quote($a_tax_id,
"integer").
440 " AND item_type = ".$ilDB->quote($a_item_type,
"text").
441 " ORDER BY order_nr ASC"
443 while(
$row = $ilDB->fetchAssoc($set))