5 include_once(
"./Services/Taxonomy/exceptions/class.ilTaxonomyException.php");
33 public function __construct($a_component_id, $a_obj_id, $a_item_type, $a_tax_id)
37 $this->db = $DIC->database();
38 if ($a_component_id ==
"") {
42 if ($a_item_type ==
"") {
46 if ((
int) $a_tax_id == 0) {
63 $this->component_id = $a_val;
73 return $this->component_id;
83 $this->item_type = $a_val;
93 return $this->item_type;
103 $this->taxonomy_id = $a_val;
113 return $this->taxonomy_id;
123 $this->obj_id = $a_val;
133 return $this->obj_id;
146 if (is_array($a_node_id)) {
148 "SELECT * FROM tax_node_assignment " .
149 " WHERE " .
$ilDB->in(
"node_id", $a_node_id,
false,
"integer") .
154 " ORDER BY order_nr ASC" 158 "SELECT * FROM tax_node_assignment " .
159 " WHERE node_id = " .
$ilDB->quote($a_node_id,
"integer") .
164 " ORDER BY order_nr ASC" 168 while ($rec =
$ilDB->fetchAssoc($set)) {
186 "SELECT * FROM tax_node_assignment" .
187 " WHERE component = " .
$ilDB->quote($this->getComponentId(),
"text") .
188 " AND item_type = " .
$ilDB->quote($this->getItemType(),
"text") .
189 " AND item_id = " .
$ilDB->quote($a_item_id,
"integer") .
194 while ($rec =
$ilDB->fetchAssoc($set)) {
213 if ((
int) $a_node_id == 0 || (
int) $a_item_id == 0) {
219 "SELECT tax_tree_id FROM tax_tree " .
220 " WHERE child = " .
$ilDB->quote($a_node_id,
"integer")
222 $rec =
$ilDB->fetchAssoc($set);
224 throw new ilTaxonomyException(
'addAssignment: Node ID does not belong to current taxonomy.');
229 $set2 =
$ilDB->query(
230 $q =
"SELECT item_id FROM tax_node_assignment " .
231 " WHERE component = " .
$ilDB->quote($this->getComponentId(),
"text") .
232 " AND item_type = " .
$ilDB->quote($this->getItemType(),
"text") .
233 " AND obj_id = " .
$ilDB->quote($this->getObjectId(),
"integer") .
234 " AND node_id = " .
$ilDB->quote($a_node_id,
"integer") .
236 " AND item_id = " .
$ilDB->quote($a_item_id,
"integer")
238 if ($rec2 =
$ilDB->fetchAssoc($set2)) {
242 if ($a_order_nr == 0) {
247 "tax_node_assignment",
249 "node_id" => array(
"integer", $a_node_id),
251 "item_type" => array(
"text", $this->
getItemType()),
252 "obj_id" => array(
"integer", $this->
getObjectId()),
253 "item_id" => array(
"integer", $a_item_id)
257 "order_nr" => array(
"integer", $a_order_nr)
274 if ((
int) $a_node_id == 0 || (
int) $a_item_id == 0) {
280 "SELECT tax_tree_id FROM tax_tree " .
281 " WHERE child = " .
$ilDB->quote($a_node_id,
"integer")
283 $rec =
$ilDB->fetchAssoc($set);
285 throw new ilTaxonomyException(
'addAssignment: Node ID does not belong to current taxonomy.');
289 "DELETE FROM tax_node_assignment WHERE " .
290 " component = " .
$ilDB->quote($this->getComponentId(),
"text") .
291 " AND item_type = " .
$ilDB->quote($this->getItemType(),
"text") .
292 " AND obj_id = " .
$ilDB->quote($this->getObjectId(),
"integer") .
293 " AND item_id = " .
$ilDB->quote($a_item_id,
"integer") .
294 " AND node_id = " .
$ilDB->quote($a_node_id,
"integer") .
310 "SELECT max(order_nr) mnr FROM tax_node_assignment " .
311 " WHERE component = " .
$ilDB->quote($this->getComponentId(),
"text") .
312 " AND item_type = " .
$ilDB->quote($this->getItemType(),
"text") .
313 " AND obj_id = " .
$ilDB->quote($this->getObjectId(),
"integer") .
314 " AND node_id = " .
$ilDB->quote($a_node_id,
"integer") .
317 $rec =
$ilDB->fetchAssoc($set);
319 return (
int) $rec[
"mnr"];
328 public function setOrderNr($a_node_id, $a_item_id, $a_order_nr)
333 "UPDATE tax_node_assignment SET " .
334 " order_nr = " .
$ilDB->quote($a_order_nr,
"integer") .
338 " AND node_id = " .
$ilDB->quote($a_node_id,
"integer") .
339 " AND item_id = " .
$ilDB->quote($a_item_id,
"integer") .
355 "DELETE FROM tax_node_assignment WHERE " .
356 " component = " .
$ilDB->quote($this->getComponentId(),
"text") .
357 " AND item_type = " .
$ilDB->quote($this->getItemType(),
"text") .
358 " AND obj_id = " .
$ilDB->quote($this->getObjectId(),
"integer") .
359 " AND item_id = " .
$ilDB->quote($a_item_id,
"integer") .
374 "DELETE FROM tax_node_assignment WHERE " .
375 " node_id = " .
$ilDB->quote($a_node_id,
"integer") .
391 $ilDB = $DIC->database();
394 "DELETE FROM tax_node_assignment WHERE " .
395 " node_id = " .
$ilDB->quote($a_node_id,
"integer")
407 "SELECT * FROM tax_node_assignment " .
408 " WHERE component = " .
$ilDB->quote($this->getComponentId(),
"text") .
409 " AND item_type = " .
$ilDB->quote($this->getItemType(),
"text") .
410 " AND obj_id = " .
$ilDB->quote($this->getObjectId(),
"integer") .
411 " AND node_id = " .
$ilDB->quote($a_node_id,
"integer") .
413 " ORDER BY order_nr ASC" 416 while ($rec =
$ilDB->fetchAssoc($set)) {
418 "UPDATE tax_node_assignment SET " .
419 " order_nr = " .
$ilDB->quote($cnt,
"integer") .
423 " AND node_id = " .
$ilDB->quote($a_node_id,
"integer") .
425 " AND item_id = " .
$ilDB->quote($rec[
"item_id"],
"integer")
445 $ilDB = $DIC->database();
450 "SELECT * FROM tax_node_assignment" .
451 " WHERE " .
$ilDB->in(
"node_id", $a_node_ids,
"",
"integer") .
452 " AND tax_id = " .
$ilDB->quote($a_tax_id,
"integer") .
453 " AND item_type = " .
$ilDB->quote($a_item_type,
"text") .
454 " ORDER BY order_nr ASC" getAssignmentsOfItem($a_item_id)
Get assignments for item.
addAssignment($a_node_id, $a_item_id, $a_order_nr=0)
Add assignment.
getMaxOrderNr($a_node_id)
Get maximum order number.
Taxonomy node <-> item assignment.
getItemType()
Get item type.
setOrderNr($a_node_id, $a_item_id, $a_order_nr)
Set order nr.
setTaxonomyId($a_val)
Set taxonomy id.
setComponentId($a_val)
Set component id.
getObjectId()
Get object id.
static findObjectsByNode($a_tax_id, array $a_node_ids, $a_item_type)
Find object which have assigned nodes.
getAssignmentsOfNode($a_node_id)
Get assignments of node.
deleteAssignmentsOfItem($a_item_id)
Delete assignments of item.
foreach($_POST as $key=> $value) $res
setObjectId($a_val)
Set object id.
setItemType($a_val)
Set item type.
getTaxonomyId()
Get taxonomy id.
fixOrderNr($a_node_id)
Fix Order Nr.
__construct($a_component_id, $a_obj_id, $a_item_type, $a_tax_id)
Constructor.
deleteAssignment($a_node_id, $a_item_id)
Delete assignment.
deleteAssignmentsOfNode($a_node_id)
Delete assignments of node.
Class for advanced editing exception handling in ILIAS.
getComponentId()
Get component id.
static deleteAllAssignmentsOfNode($a_node_id)
Delete assignments of node.