コード例 #1
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");
 }
コード例 #2
0
 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;
 }