42 string $a_component_id,
50 $this->db = (is_null($db))
54 if ($a_component_id ==
"") {
58 if ($a_item_type ==
"") {
74 $this->component_id = $a_val;
84 $this->item_type = $a_val;
94 $this->taxonomy_id = $a_val;
104 $this->obj_id = $a_val;
121 if (is_array($a_node_id)) {
123 "SELECT * FROM tax_node_assignment " .
124 " WHERE " .
$ilDB->in(
"node_id", $a_node_id,
false,
"integer") .
129 " ORDER BY order_nr ASC" 133 "SELECT * FROM tax_node_assignment " .
134 " WHERE node_id = " .
$ilDB->quote($a_node_id,
"integer") .
139 " ORDER BY order_nr ASC" 143 while ($rec =
$ilDB->fetchAssoc($set)) {
159 "SELECT * FROM tax_node_assignment" .
160 " WHERE component = " .
$ilDB->quote($this->getComponentId(),
"text") .
161 " AND item_type = " .
$ilDB->quote($this->getItemType(),
"text") .
162 " AND item_id = " .
$ilDB->quote($a_item_id,
"integer") .
167 while ($rec =
$ilDB->fetchAssoc($set)) {
177 public function addAssignment(
int $a_node_id,
int $a_item_id,
int $a_order_nr = 0): void
182 if ($a_node_id == 0 || $a_item_id == 0) {
188 "SELECT tax_tree_id FROM tax_tree " .
189 " WHERE child = " .
$ilDB->quote($a_node_id,
"integer")
191 $rec =
$ilDB->fetchAssoc($set);
193 throw new ilTaxonomyException(
'addAssignment: Node ID does not belong to current taxonomy.');
198 $set2 =
$ilDB->query(
199 $q =
"SELECT item_id FROM tax_node_assignment " .
200 " WHERE component = " .
$ilDB->quote($this->getComponentId(),
"text") .
201 " AND item_type = " .
$ilDB->quote($this->getItemType(),
"text") .
202 " AND obj_id = " .
$ilDB->quote($this->getObjectId(),
"integer") .
203 " AND node_id = " .
$ilDB->quote($a_node_id,
"integer") .
205 " AND item_id = " .
$ilDB->quote($a_item_id,
"integer")
207 if ($rec2 =
$ilDB->fetchAssoc($set2)) {
211 if ($a_order_nr == 0) {
216 "tax_node_assignment",
218 "node_id" => array(
"integer", $a_node_id),
220 "item_type" => array(
"text", $this->
getItemType()),
221 "obj_id" => array(
"integer", $this->
getObjectId()),
222 "item_id" => array(
"integer", $a_item_id)
226 "order_nr" => array(
"integer", $a_order_nr)
236 if ($a_node_id == 0 || $a_item_id == 0) {
242 "SELECT tax_tree_id FROM tax_tree " .
243 " WHERE child = " .
$ilDB->quote($a_node_id,
"integer")
245 $rec =
$ilDB->fetchAssoc($set);
247 throw new ilTaxonomyException(
'addAssignment: Node ID does not belong to current taxonomy.');
251 "DELETE FROM tax_node_assignment WHERE " .
252 " component = " .
$ilDB->quote($this->getComponentId(),
"text") .
253 " AND item_type = " .
$ilDB->quote($this->getItemType(),
"text") .
254 " AND obj_id = " .
$ilDB->quote($this->getObjectId(),
"integer") .
255 " AND item_id = " .
$ilDB->quote($a_item_id,
"integer") .
256 " AND node_id = " .
$ilDB->quote($a_node_id,
"integer") .
266 "SELECT max(order_nr) mnr FROM tax_node_assignment " .
267 " WHERE component = " .
$ilDB->quote($this->getComponentId(),
"text") .
268 " AND item_type = " .
$ilDB->quote($this->getItemType(),
"text") .
269 " AND obj_id = " .
$ilDB->quote($this->getObjectId(),
"integer") .
270 " AND node_id = " .
$ilDB->quote($a_node_id,
"integer") .
273 $rec =
$ilDB->fetchAssoc($set);
275 return (
int) $rec[
"mnr"];
278 public function setOrderNr(
int $a_node_id,
int $a_item_id,
int $a_order_nr): void
283 "UPDATE tax_node_assignment SET " .
284 " order_nr = " .
$ilDB->quote($a_order_nr,
"integer") .
288 " AND node_id = " .
$ilDB->quote($a_node_id,
"integer") .
289 " AND item_id = " .
$ilDB->quote($a_item_id,
"integer") .
299 "DELETE FROM tax_node_assignment WHERE " .
300 " component = " .
$ilDB->quote($this->getComponentId(),
"text") .
301 " AND item_type = " .
$ilDB->quote($this->getItemType(),
"text") .
302 " AND obj_id = " .
$ilDB->quote($this->getObjectId(),
"integer") .
303 " AND item_id = " .
$ilDB->quote($a_item_id,
"integer") .
313 "DELETE FROM tax_node_assignment WHERE " .
314 " node_id = " .
$ilDB->quote($a_node_id,
"integer") .
325 $ilDB = $DIC->database();
328 "DELETE FROM tax_node_assignment WHERE " .
329 " node_id = " .
$ilDB->quote($a_node_id,
"integer")
339 "SELECT * FROM tax_node_assignment " .
340 " WHERE component = " .
$ilDB->quote($this->getComponentId(),
"text") .
341 " AND item_type = " .
$ilDB->quote($this->getItemType(),
"text") .
342 " AND obj_id = " .
$ilDB->quote($this->getObjectId(),
"integer") .
343 " AND node_id = " .
$ilDB->quote($a_node_id,
"integer") .
345 " ORDER BY order_nr ASC" 348 while ($rec =
$ilDB->fetchAssoc($set)) {
350 "UPDATE tax_node_assignment SET " .
351 " order_nr = " .
$ilDB->quote($cnt,
"integer") .
355 " AND node_id = " .
$ilDB->quote($a_node_id,
"integer") .
357 " AND item_id = " .
$ilDB->quote($rec[
"item_id"],
"integer")
366 public static function findObjectsByNode(
int $a_tax_id, array $a_node_ids,
string $a_item_type): array
370 $ilDB = $DIC->database();
375 "SELECT * FROM tax_node_assignment" .
376 " WHERE " .
$ilDB->in(
"node_id", $a_node_ids,
"",
"integer") .
377 " AND tax_id = " .
$ilDB->quote($a_tax_id,
"integer") .
378 " AND item_type = " .
$ilDB->quote($a_item_type,
"text") .
379 " ORDER BY order_nr ASC" 381 while ($row =
$ilDB->fetchAssoc($set)) {
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
deleteAssignment(int $a_node_id, int $a_item_id)
static findObjectsByNode(int $a_tax_id, array $a_node_ids, string $a_item_type)
Find object which have assigned nodes.
addAssignment(int $a_node_id, int $a_item_id, int $a_order_nr=0)
Add assignment.
deleteAssignmentsOfItem(int $a_item_id)
static deleteAllAssignmentsOfNode(int $a_node_id)
getAssignmentsOfNode($a_node_id)
Get assignments of node.
setOrderNr(int $a_node_id, int $a_item_id, int $a_order_nr)
__construct(string $a_component_id, int $a_obj_id, string $a_item_type, int $a_tax_id, ilDBInterface $db=null)
Constructor.
deleteAssignmentsOfNode(int $a_node_id)
fixOrderNr(int $a_node_id)
getAssignmentsOfItem(int $a_item_id)
Get assignments for item.
getMaxOrderNr(int $a_node_id)
setItemType(string $a_val)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTaxonomyId(int $a_val)
setComponentId(string $a_val)