/**
  * 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->lectureID;
     if (!$course_id) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Missing course id');
         return false;
     }
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $GLOBALS['ilLog']->write(__METHOD__ . ': sid: ' . $this->getServer()->getServerId() . ' course_id: ' . $course_id . ' mid: ' . $this->mid);
     //$crs_obj_id = ilECSImport::_lookupObjId($this->getServer()->getServerId(), $course_id, $this->mid);
     $crs_obj_id = ilECSImport::lookupObjIdByContentId($this->getServer()->getServerId(), $this->mid, $course_id);
     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::lookupObjIdByContentId($this->getServer()->getServerId(), $this->getMid(), $course_id, $sub_id);
         $this->refreshAssignmentStatus($course_member, $obj_id, $sub_id, $assigned);
     }
     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;
     }
 }
 /**
  * Get import id of remote course
  * Return 0 if object isn't imported.
  * Searches for the (hopefully) unique content id of an imported object
  * @param type $a_content_id
  * @return type
  */
 protected function getImportId($a_content_id, $a_sub_id = NULL)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     return ilECSImport::lookupObjIdByContentId($this->getServer()->getServerId(), $this->getMid(), $a_content_id, $a_sub_id);
 }