/**
  * Get title for node id (needs to be overwritten, if explorer is not a tree eplorer
  *
  * @param
  * @return
  */
 function getTitleForNodeId($a_id)
 {
     include_once "./Services/Taxonomy/classes/class.ilTaxonomyNode.php";
     return ilTaxonomyNode::_lookupTitle($a_id);
 }
Esempio n. 2
0
 /**
  * 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");
 }
 /**
  * Delete taxonomy object
  */
 function doDelete()
 {
     global $ilDB;
     // delete usages
     self::deleteUsagesOfTaxonomy($this->getId());
     // get all nodes
     $tree = $this->getTree();
     $subtree = $tree->getSubTreeIds($tree->readRootId());
     $subtree[] = $tree->readRootId();
     // get root node data (important: must happen before we
     // delete the nodes
     $root_node_data = $tree->getNodeData($tree->readRootId());
     // delete all nodes
     include_once "./Services/Taxonomy/classes/class.ilTaxonomyNode.php";
     foreach ($subtree as $node_id) {
         // delete node (this also deletes its assignments)
         $node = new ilTaxonomyNode($node_id);
         $node->delete();
     }
     // delete the tree
     $tree->deleteTree($root_node_data);
     // delete taxonoymy properties record
     $ilDB->manipulate("DELETE FROM tax_data WHERE " . " id = " . $ilDB->quote($this->getId(), "integer"));
 }
 /**
  * Copy taxonomy node
  */
 function copy($a_tax_id = 0)
 {
     $taxn = new ilTaxonomyNode();
     $taxn->setTitle($this->getTitle());
     $taxn->setType($this->getType());
     $taxn->setOrderNr($this->getOrderNr());
     if ($a_tax_id == 0) {
         $taxn->setTaxonomyId($this->getTaxonomyId());
     } else {
         $taxn->setTaxonomyId($a_tax_id);
     }
     $taxn->create();
     return $taxn;
 }
 /**
  * Import record
  *
  * @param
  * @return
  */
 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 {
     //echo $a_entity;
     //var_dump($a_rec);
     switch ($a_entity) {
         case "tax":
             include_once "./Services/Taxonomy/classes/class.ilObjTaxonomy.php";
             //				if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
             //				{
             //					$newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
             //				}
             //				else
             //				{
             $newObj = new ilObjTaxonomy();
             $newObj->create();
             //				}
             $newObj->setTitle($a_rec["Title"]);
             $newObj->setDescription($a_rec["Description"]);
             $newObj->setSortingMode($a_rec["SortingMode"]);
             $newObj->update();
             $this->current_obj = $newObj;
             $a_mapping->addMapping("Services/Taxonomy", "tax", $a_rec["Id"], $newObj->getId());
             break;
         case "tax_tree":
             switch ($a_rec["Type"]) {
                 case "taxn":
                     $parent = (int) $a_mapping->getMapping("Services/Taxonomy", "tax_tree", $a_rec["Parent"]);
                     $tax_id = $a_mapping->getMapping("Services/Taxonomy", "tax", $a_rec["TaxId"]);
                     if ($parent == 0) {
                         $parent = $this->current_obj->getTree()->readRootId();
                     }
                     $node = new ilTaxonomyNode();
                     $node->setTitle($a_rec["Title"]);
                     $node->setOrderNr($a_rec["OrderNr"]);
                     $node->setTaxonomyId($tax_id);
                     $node->create();
                     ilTaxonomyNode::putInTree($tax_id, $node, (int) $parent, "", $a_rec["OrderNr"]);
                     $a_mapping->addMapping("Services/Taxonomy", "tax_tree", $a_rec["Child"], $node->getId());
                     break;
             }
         case "tax_node_assignment":
             $new_item_id = (int) $a_mapping->getMapping("Services/Taxonomy", "tax_item", $a_rec["Component"] . ":" . $a_rec["ItemType"] . ":" . $a_rec["ItemId"]);
             $new_node_id = (int) $a_mapping->getMapping("Services/Taxonomy", "tax_tree", $a_rec["NodeId"]);
             if ($new_item_id > 0 && $new_node_id > 0) {
                 include_once "./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php";
                 $node_ass = new ilTaxNodeAssignment($a_rec["Component"], $a_rec["ItemType"], $this->current_obj->getId());
                 $node_ass->addAssignment($new_node_id, $new_item_id);
             }
             break;
         case "tax_usage":
             $usage = $a_mapping->getMapping("Services/Taxonomy", "tax_usage_of_obj", $a_rec["ObjId"]);
             if ($usage != "") {
                 $usage .= ":";
             }
             $a_mapping->addMapping("Services/Taxonomy", "tax_usage_of_obj", $a_rec["ObjId"], $this->current_obj->getId());
             break;
     }
 }
 public function getFilteredObjects()
 {
     include_once "Services/Taxonomy/classes/class.ilTaxonomyTree.php";
     include_once "Services/Taxonomy/classes/class.ilTaxNodeAssignment.php";
     include_once "Services/Taxonomy/classes/class.ilTaxonomyNode.php";
     $tax_obj_ids = $tax_map = array();
     // :TODO: this could be smarter
     foreach ($this->selection as $node_id) {
         $node = new ilTaxonomyNode($node_id);
         $tax_map[$node->getTaxonomyId()][] = $node_id;
     }
     foreach ($tax_map as $tax_id => $node_ids) {
         $tax_tree = new ilTaxonomyTree($tax_id);
         // combine taxonomy nodes OR
         $tax_nodes = array();
         foreach ($node_ids as $node_id) {
             $tax_nodes = array_merge($tax_nodes, $tax_tree->getSubTreeIds($node_id));
             $tax_nodes[] = $node_id;
         }
         $tax_obj_ids[$tax_id] = ilTaxNodeAssignment::findObjectsByNode($tax_id, $tax_nodes, "obj");
     }
     // combine taxonomies AND
     $obj_ids = null;
     foreach ($tax_obj_ids as $tax_objs) {
         if ($obj_ids === null) {
             $obj_ids = $tax_objs;
         } else {
             $obj_ids = array_intersect($obj_ids, $tax_objs);
         }
     }
     return (array) $obj_ids;
 }