/** * Paste items (move operation) */ function pasteItems() { global $lng, $ilCtrl; //var_dump($_GET); //var_dump($_POST); if ($_GET["move_ids"] != "") { $move_ids = explode(",", $_GET["move_ids"]); $tax = $this->getCurrentTaxonomy(); $tree = $tax->getTree(); include_once "./Services/Taxonomy/classes/class.ilTaxonomyNode.php"; $target_node = new ilTaxonomyNode((int) $_GET["tax_node"]); foreach ($move_ids as $m_id) { // cross check taxonomy $node = new ilTaxonomyNode((int) $m_id); if ($node->getTaxonomyId() == $tax->getId() && ($target_node->getTaxonomyId() == $tax->getId() || $target_node->getId() == $tree->readRootId())) { // check if target is not within the selected nodes if ($tree->isGrandChild((int) $m_id, $target_node->getId())) { ilUtil::sendFailure($lng->txt("tax_target_within_nodes"), true); $this->ctrl->redirect($this, "listNodes"); } // if target is not current place, move $parent_id = $tree->getParentId((int) $m_id); if ($parent_id != $target_node->getId()) { $tree->moveTree((int) $m_id, $target_node->getId()); ilTaxonomyNode::fixOrderNumbers($tax->getId(), $target_node->getId()); ilTaxonomyNode::fixOrderNumbers($tax->getId(), $parent_id); } } } } ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true); $ilCtrl->redirect($this, "listNodes"); }
/** * Create a new taxonomy */ function doCreate() { global $ilDB; // create tax data record $ilDB->manipulate("INSERT INTO tax_data " . "(id, sorting_mode, item_sorting) VALUES (" . $ilDB->quote($this->getId(), "integer") . "," . $ilDB->quote((int) $this->getSortingMode(), "integer") . "," . $ilDB->quote((int) $this->getItemSorting(), "integer") . ")"); // create the taxonomy tree include_once "./Services/Taxonomy/classes/class.ilTaxonomyNode.php"; $node = new ilTaxonomyNode(); $node->setType(""); // empty type $node->setTitle("Root node for taxonomy " . $this->getId()); $node->setTaxonomyId($this->getId()); $node->create(); include_once "./Services/Taxonomy/classes/class.ilTaxonomyTree.php"; $tax_tree = new ilTaxonomyTree($this->getId()); $tax_tree->addTree($this->getId(), $node->getId()); }