/** * Init (read) current mappings */ protected function initMappings() { include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseMappingRule.php'; $mappings = array(); foreach (ilECSCourseMappingRule::getRuleRefIds($this->getSid(), $this->getMid()) as $ref_id) { $mappings[$ref_id] = array(); } foreach ($mappings as $ref_id => $tmp) { $this->mappings[$ref_id] = $GLOBALS['tree']->getPathId($ref_id, 1); } return true; }
/** * Sync attribute mapping * @param type $a_content_id * @param type $course */ protected function doAttributeMapping($a_content_id, $course) { // Check if course is already created $course_id = $course->lectureID; $obj_id = $this->getImportId($course_id); if ($obj_id) { // do update $GLOBALS['ilLog']->write(__METHOD__ . ' Performing update of already imported course.'); $refs = ilObject::_getAllReferences($obj_id); $ref = end($refs); return $this->doSync($a_content_id, $course, ilObject::_lookupObjId($GLOBALS['tree']->getParentId($ref))); } // Get all rules $matching_rule = 0; include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseMappingRule.php'; foreach (ilECSCourseMappingRule::getRuleRefIds($this->getServer()->getServerId(), $this->getMid()) as $ref_id) { if (ilECSCourseMappingRule::isMatching($course, $this->getServer()->getServerId(), $this->getMid(), $ref_id)) { $matching_rule = $ref_id; } } if (!$matching_rule) { // Put course in default category $GLOBALS['ilLog']->write(__METHOD__ . ': No matching attribute mapping rule found.'); $GLOBALS['ilLog']->write(__METHOD__ . ': Using course default category'); return $this->doSync($a_content_id, $course, ilObject::_lookupObjId($this->getMapping()->getDefaultCourseCategory())); } // map according mapping rules $parent_ref = ilECSCourseMappingRule::doMappings($course, $this->getServer()->getServerId(), $this->getMid(), $ref_id); $this->doSync($a_content_id, $course, ilObject::_lookupObjId($parent_ref)); return true; }