5include_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") .
 
  150                " AND tax_id = " . 
$ilDB->quote($this->getTaxonomyId(), 
"integer") .
 
  151                " AND component = " . 
$ilDB->quote($this->getComponentId(), 
"text") .
 
  152                " AND obj_id = " . 
$ilDB->quote($this->getObjectId(), 
"integer") .
 
  153                " AND item_type = " . 
$ilDB->quote($this->getItemType(), 
"text") .
 
  154                " ORDER BY order_nr ASC" 
  158                "SELECT * FROM tax_node_assignment " .
 
  159                " WHERE node_id = " . 
$ilDB->quote($a_node_id, 
"integer") .
 
  160                " AND tax_id = " . 
$ilDB->quote($this->getTaxonomyId(), 
"integer") .
 
  161                " AND component = " . 
$ilDB->quote($this->getComponentId(), 
"text") .
 
  162                " AND obj_id = " . 
$ilDB->quote($this->getObjectId(), 
"integer") .
 
  163                " AND item_type = " . 
$ilDB->quote($this->getItemType(), 
"text") .
 
  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") .
 
  190            " AND obj_id = " . 
$ilDB->quote($this->getObjectId(), 
"integer") .
 
  191            " AND tax_id = " . 
$ilDB->quote($this->getTaxonomyId(), 
"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") .
 
  235            " AND tax_id = " . 
$ilDB->quote($this->getTaxonomyId(), 
"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") .
 
  295            " AND tax_id = " . 
$ilDB->quote($this->getTaxonomyId(), 
"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") .
 
  315            " AND tax_id = " . 
$ilDB->quote($this->getTaxonomyId(), 
"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") .
 
  335            " WHERE component = " . 
$ilDB->quote($this->getComponentId(), 
"text") .
 
  336            " AND item_type = " . 
$ilDB->quote($this->getItemType(), 
"text") .
 
  337            " AND obj_id = " . 
$ilDB->quote($this->getObjectId(), 
"integer") .
 
  338            " AND node_id = " . 
$ilDB->quote($a_node_id, 
"integer") .
 
  339            " AND item_id = " . 
$ilDB->quote($a_item_id, 
"integer") .
 
  340            " AND tax_id = " . 
$ilDB->quote($this->getTaxonomyId(), 
"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") .
 
  360            " AND tax_id = " . 
$ilDB->quote($this->getTaxonomyId(), 
"integer")
 
  374            "DELETE FROM tax_node_assignment WHERE " .
 
  375            " node_id = " . 
$ilDB->quote($a_node_id, 
"integer") .
 
  376            " AND component = " . 
$ilDB->quote($this->getComponentId(), 
"text") .
 
  377            " AND obj_id = " . 
$ilDB->quote($this->getObjectId(), 
"integer") .
 
  378            " AND item_type = " . 
$ilDB->quote($this->getItemType(), 
"text")
 
  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") .
 
  412            " AND tax_id = " . 
$ilDB->quote($this->getTaxonomyId(), 
"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") .
 
  420                " WHERE component = " . 
$ilDB->quote($this->getComponentId(), 
"text") .
 
  421                " AND item_type = " . 
$ilDB->quote($this->getItemType(), 
"text") .
 
  422                " AND obj_id = " . 
$ilDB->quote($this->getObjectId(), 
"integer") .
 
  423                " AND node_id = " . 
$ilDB->quote($a_node_id, 
"integer") .
 
  424                " AND tax_id = " . 
$ilDB->quote($this->getTaxonomyId(), 
"integer") .
 
  425                " AND item_id = " . 
$ilDB->quote($rec[
"item_id"], 
"integer")
 
  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" 
  456        while ($row = 
$ilDB->fetchAssoc($set)) {
 
  457            $res[] = $row[
"obj_id"];
 
An exception for terminatinating execution or to throw for unit testing.
Taxonomy node <-> item assignment.
fixOrderNr($a_node_id)
Fix Order Nr.
getMaxOrderNr($a_node_id)
Get maximum order number.
deleteAssignmentsOfNode($a_node_id)
Delete assignments of node.
getAssignmentsOfNode($a_node_id)
Get assignments of node.
getObjectId()
Get object id.
getTaxonomyId()
Get taxonomy id.
__construct($a_component_id, $a_obj_id, $a_item_type, $a_tax_id)
Constructor.
setComponentId($a_val)
Set component id.
static findObjectsByNode($a_tax_id, array $a_node_ids, $a_item_type)
Find object which have assigned nodes.
getItemType()
Get item type.
setTaxonomyId($a_val)
Set taxonomy id.
deleteAssignment($a_node_id, $a_item_id)
Delete assignment.
deleteAssignmentsOfItem($a_item_id)
Delete assignments of item.
addAssignment($a_node_id, $a_item_id, $a_order_nr=0)
Add assignment.
setItemType($a_val)
Set item type.
setObjectId($a_val)
Set object id.
static deleteAllAssignmentsOfNode($a_node_id)
Delete assignments of node.
getComponentId()
Get component id.
getAssignmentsOfItem($a_item_id)
Get assignments for item.
setOrderNr($a_node_id, $a_item_id, $a_order_nr)
Set order nr.
Class for advanced editing exception handling in ILIAS.
foreach($_POST as $key=> $value) $res