/** * Sync node * @param type $cs_id * @param type $setting */ protected function syncNode($tree_obj_id, $parent_id, $a_mapped = false) { $childs = $this->getTree()->getChilds($tree_obj_id); $assignment = new ilECSNodeMappingAssignment($this->getServer()->getServerId(), $this->mid, $this->tree_id, $tree_obj_id); if ($assignment->getRefId()) { $parent_id = $assignment->getRefId(); } // information for deeper levels if ($assignment->isMapped()) { $a_mapped = true; } if ($a_mapped) { $parent_id = $this->syncCategory($assignment, $parent_id); } // iterate through childs foreach ($childs as $node) { $this->syncNode($node['child'], $parent_id, $a_mapped); } return true; }
/** * Sync node to top * @param type $tree_id * @param type $parent_id * @return int obj_id of container */ protected function syncNodeToTop($tree_id, $cms_id) { $obj_id = $this->getImportId($cms_id); if ($obj_id) { // node already imported return $obj_id; } $tobj_id = ilECSCmsData::lookupObjId($this->getServer()->getServerId(), $this->getMid(), $tree_id, $cms_id); // node is not imported $GLOBALS['ilLog']->write(__METHOD__ . ': ecs node with id ' . $cms_id . ' is not imported for mid ' . $this->getMid() . ' tree_id ' . $tree_id); // check for mapping: if mapping is available create category include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignment.php'; $ass = new ilECSNodeMappingAssignment($this->getServer()->getServerId(), $this->getMid(), $tree_id, $tobj_id); if ($ass->isMapped()) { $GLOBALS['ilLog']->write(__METHOD__ . ': node is mapped'); return $this->syncCategory($tobj_id, $ass->getRefId()); } // Start recursion to top include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php'; $tree = new ilECSCmsTree($tree_id); $parent_tobj_id = $tree->getParentId($tobj_id); if ($parent_tobj_id) { $cms_ids = ilECSCmsData::lookupCmsIds(array($parent_tobj_id)); $obj_id = $this->syncNodeToTop($tree_id, $cms_ids[0]); } if ($obj_id) { $refs = ilObject::_getAllReferences($obj_id); $ref_id = end($refs); return $this->syncCategory($tobj_id, $ref_id); } return 0; }