/**
  * Set new course object imported
  * @param int $a_content_id
  * @param ilObjCourse $crs
  */
 protected function setImported($a_content_id, $object, $a_ecs_id = 0, $a_sub_id = 0)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $import = new ilECSImport($this->getServer()->getServerId(), is_object($object) ? $object->getId() : 0);
     $GLOBALS['ilLog']->write(__METHOD__ . ': Imported with ecs id ' . $a_ecs_id);
     $import->setSubId($a_sub_id);
     $import->setMID($this->getMid());
     $import->setEContentId($a_ecs_id);
     $import->setContentId($a_content_id);
     $import->setImported(true);
     $import->save();
     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::lookupObjIdByContentId($this->getServer()->getServerId(), $this->mid, $data->getCmsId());
     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->setContentId($data->getCmsId());
         $import->setImported(true);
         $import->save();
         return $cat->getRefId();
     } else {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Creation of empty containers is disabled.');
         return 0;
     }
 }
Exemplo n.º 3
0
 protected function updateCustomFromECSContent(ilECSSetting $a_server, $a_ecs_content)
 {
     // add custom values
     $this->setAvailabilityType($a_ecs_content->status == 'online' ? self::ACTIVATION_UNLIMITED : self::ACTIVATION_OFFLINE);
     // :TODO: ACTIVATION_LIMITED is currently not supported in ECS yet
     // adv. metadata
     include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php';
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSetting.php';
     $definition = ilECSUtils::getEContentDefinition($this->getECSObjectType());
     $this->importMetadataFromJson($a_ecs_content, $a_server, $definition, ilECSDataMappingSetting::MAPPING_IMPORT_RCRS);
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $import = new ilECSImport($a_server->getServerId(), $this->getId());
     $import->setContentId($a_ecs_content->courseID);
     $import->save();
 }