/** * check if econtent is imported for a specific mid * * @access public * @static * * @param int econtent id * @param int mid */ public static function _isImported($a_server_id, $a_econtent_id, $a_mid, $a_sub_id = 0) { return ilECSImport::_lookupObjId($a_server_id, $a_econtent_id, $a_mid, $a_sub_id); }
/** * Handle delete event * * called by ilTaskScheduler * * @param ilECSSetting $a_server * @param int $a_econtent_id * @param int $a_mid * @return boolean */ public function handleDelete(ilECSSetting $a_server, $a_econtent_id, $a_mid = 0) { global $tree, $ilLog; include_once './Services/WebServices/ECS/classes/class.ilECSImport.php'; // if mid is zero delete all obj_ids if (!$a_mid) { $obj_ids = ilECSImport::_lookupObjIds($a_server->getServerId(), $a_econtent_id); } else { $obj_ids = (array) ilECSImport::_lookupObjId($a_server->getServerId(), $a_econtent_id, $a_mid); } $ilLog->write(__METHOD__ . ': Received obj_ids ' . print_r($obj_ids, true)); foreach ($obj_ids as $obj_id) { $references = ilObject::_getAllReferences($obj_id); foreach ($references as $ref_id) { if ($tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id, false)) { $ilLog->write(__METHOD__ . ': Deleting obsolete remote course: ' . $tmp_obj->getTitle()); $tmp_obj->delete(); $tree->deleteTree($tree->getNodeData($ref_id)); } unset($tmp_obj); } } return true; }
/** * Sync category * @param ilECSNodeMappingAssignment $ass */ protected function syncCategory(ilECSNodeMappingAssignment $ass, $parent_id) { include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php'; $data = new ilECSCmsData($ass->getCSId()); // Check if node is imported => create // perform title update // perform position update include_once './Services/WebServices/ECS/classes/class.ilECSImport.php'; $obj_id = ilECSImport::_lookupObjId($this->getServer()->getServerId(), $data->getCmsId(), $this->mid); if ($obj_id) { $refs = ilObject::_getAllReferences($obj_id); $ref_id = end($refs); $cat = ilObjectFactory::getInstanceByRefId($ref_id, false); if ($cat instanceof ilObject and $this->default_settings['title_update']) { $GLOBALS['ilLog']->write(__METHOD__ . ': Updating cms category '); $GLOBALS['ilLog']->write(__METHOD__ . ': Title is ' . $data->getTitle()); $cat->deleteTranslation($GLOBALS['lng']->getDefaultLanguage()); $cat->addTranslation($data->getTitle(), $cat->getLongDescription(), $GLOBALS['lng']->getDefaultLanguage(), 1); $cat->setTitle($data->getTitle()); $cat->update(); } else { $GLOBALS['ilLog']->write(__METHOD__ . ': Updating cms category -> nothing to do'); } return $ref_id; } elseif ($this->getGlobalSettings()->isEmptyContainerCreationEnabled()) { $GLOBALS['ilLog']->write(__METHOD__ . ': Creating new cms category'); // Create category include_once './Modules/Category/classes/class.ilObjCategory.php'; $cat = new ilObjCategory(); $cat->setTitle($data->getTitle()); $cat->create(); // true for upload $cat->createReference(); $cat->putInTree($parent_id); $cat->setPermissions($parent_id); $cat->deleteTranslation($GLOBALS['lng']->getDEfaultLanguage()); $cat->addTranslation($data->getTitle(), $cat->getLongDescription(), $GLOBALS['lng']->getDefaultLanguage(), 1); // set imported $import = new ilECSImport($this->getServer()->getServerId(), $cat->getId()); $import->setMID($this->mid); $import->setEContentId($data->getCmsId()); $import->setImported(true); $import->save(); return $cat->getRefId(); } else { $GLOBALS['ilLog']->write(__METHOD__ . ': Creation of empty containers is disabled.'); return 0; } }
/** * Perform update * @param type $a_content_id */ protected function doUpdate($a_content_id, $course_member) { $GLOBALS['ilLog']->write(__METHOD__ . ': Starting ecs member update'); $course_id = (int) $course_member->courseID; if (!$course_id) { $GLOBALS['ilLog']->write(__METHOD__ . ': Missing course id'); return false; } include_once './Services/WebServices/ECS/classes/class.ilECSImport.php'; $crs_obj_id = ilECSImport::_lookupObjId($this->getServer()->getServerId(), $course_id, $this->mid); if (!$crs_obj_id) { // check for parallel scenario iv and create courses $GLOBALS['ilLog']->write(__METHOD__ . ': Missing assigned course with id ' . $course_id); return false; } $course = $this->readCourse($course_member); // Lookup already imported users and update their status $assignments = $this->readAssignments($course, $course_member); // iterate through all parallel groups foreach ((array) $assignments as $cms_id => $assigned) { $sub_id = $cms_id == $course_id ? 0 : $cms_id; include_once './Services/WebServices/ECS/classes/class.ilECSImport.php'; $obj_id = ilECSImport::_lookupObjId($this->getServer()->getServerId(), $course_id, $this->getMid(), $sub_id); $this->refreshAssignmentStatus($course_member, $obj_id, $sub_id, $assigned); } return true; }